Skip to content

Commit

Permalink
feat: instead of failing on an unknown contig, try new gene (#11)
Browse files Browse the repository at this point in the history
* feat: instead of failing on an unknown contig, try new gene

* chore: remove unused parameter
  • Loading branch information
a-frantz authored Apr 5, 2021
1 parent 8040c74 commit 6ff35a5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ngsderive/commands/strandedness.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def get_filtered_reads_from_region(samfile, gene, min_quality=30, apply_filters=
yield read


def disqualify_gene(gene, gff):
def disqualify_gene(gene, gff, samfile):
if gene["seqname"] not in samfile.references:
return True

# if there are overlapping features on the positive and negative strand
# ignore this gene.
hits = gff.query(gene["seqname"], gene["start"], gene["end"])
Expand Down Expand Up @@ -75,7 +78,6 @@ def determine_strandedness(
min_mapq=30,
minimum_reads_per_gene=10,
split_by_rg=False,
only_protein_coding_genes=True,
max_iterations_per_try=1000,
):
try:
Expand Down Expand Up @@ -131,7 +133,7 @@ def determine_strandedness(
if gene["gene_id"] in checked_genes:
continue

if disqualify_gene(gene, gff):
if disqualify_gene(gene, gff, samfile):
continue

logging.debug("== Candidate Gene ==")
Expand Down Expand Up @@ -346,7 +348,6 @@ def main(
min_mapq=min_mapq,
minimum_reads_per_gene=minimum_reads_per_gene,
split_by_rg=split_by_rg,
only_protein_coding_genes=only_protein_coding_genes,
max_iterations_per_try=max_iterations_per_try,
)

Expand Down

0 comments on commit 6ff35a5

Please sign in to comment.