Skip to content

Commit

Permalink
Updated gtf/gff3 name parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kcleal committed Jul 31, 2024
1 parent 034211f commit 8a2a294
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 11 deletions.
56 changes: 45 additions & 11 deletions src/hts_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,9 +1464,15 @@ namespace HGW {
b.strand = 0;
}
for (const auto &item : Utils::split(b.parts[8], ';')) {

if (kind == GFF3_NOI) {
std::vector<std::string> keyval = Utils::split(item, '=');
if (keyval[0] == "ID") {
if (keyval[0] == "Name") {
b.parent = keyval[1];
b.name = keyval[1];
break;
}
else if (keyval[0] == "ID") {
b.name = keyval[1];
}
else if (keyval[0] == "Parent") {
Expand All @@ -1475,15 +1481,38 @@ namespace HGW {
}
} else {
std::vector<std::string> keyval = Utils::split(item, ' ');
if (keyval[0] == "transcript_id") {
b.name = keyval[1];
}
else if (keyval[0] == "gene_id") {
if (keyval[0] == "gene_name") {
b.parent = keyval[1];
b.name = keyval[1];
break;
} else if (keyval[0] == "gene_id") {
b.parent = keyval[1];
b.name = keyval[1];
} else if (keyval[0] == "transcript_id") {
b.name = keyval[1];
}
}

// if (kind == GFF3_NOI) {
// std::vector<std::string> keyval = Utils::split(item, '=');
// if (keyval[0] == "ID") {
// b.name = keyval[1];
// }
// else if (keyval[0] == "Parent") {
// b.parent = keyval[1];
// break;
// }
// } else {
// std::vector<std::string> keyval = Utils::split(item, ' ');
// if (keyval[0] == "transcript_id") {
// b.name = keyval[1];
// }
// else if (keyval[0] == "gene_id") {
// b.parent = keyval[1];
// break;
// }
// }

}
allBlocks[b.chrom].add(b.start, b.end, b);
}
Expand Down Expand Up @@ -1640,6 +1669,7 @@ namespace HGW {
return;
}
strand = 0;

if (kind > BCF_IDX) { // non indexed cached VCF_NOI / BED_NOI / GFF3 (todo) / GW_LABEL / STDIN?
// add_to_dict==false, only BED and GW_LABEL files supported (iterate whole file)
if (!add_to_dict) {
Expand Down Expand Up @@ -1819,23 +1849,27 @@ namespace HGW {
for (const auto &item : Utils::split(parts[8], ';')) {
if (kind == GFF3_IDX) {
std::vector<std::string> keyval = Utils::split(item, '=');
if (keyval[0] == "ID") {
rid = keyval[1];
} else if (keyval[0] == "Name") {
if (keyval[0] == "Name") {
parent = keyval[1];
rid = keyval[1];
rid = keyval[1];
break;
}
else if (keyval[0] == "ID") {
rid = keyval[1];
}
else if (keyval[0] == "Parent") {
parent = keyval[1];
break;
}
} else {
std::vector<std::string> keyval = Utils::split(item, ' ');
if (keyval[0] == "gene_id") {
if (keyval[0] == "gene_name") {
parent = keyval[1];
rid = keyval[1];
rid = keyval[1];
break;
} else if (keyval[0] == "gene_id") {
parent = keyval[1];
rid = keyval[1];
} else if (keyval[0] == "transcript_id") {
rid = keyval[1];
}
Expand Down
Loading

0 comments on commit 8a2a294

Please sign in to comment.