Skip to content

Commit

Permalink
Addressing edits
Browse files Browse the repository at this point in the history
  • Loading branch information
golu099 committed Apr 9, 2024
1 parent cdaddf4 commit 3801db2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions classify/blast.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ def get_hits_pipe(self, inPipe, db, threads=None, task=None, outfmt='6', max_tar
# If read_id is defined, strip tab output to just query read ID names and emit (default)
last_read_id = None
for line in output.decode('UTF-8').splitlines():
line = line.strip()

if output_type == 'read_id':
#Split line by tab, and take the first element
read_id = line.split('\t')[0]
# Only emit if it is not a duplicate of the previous read ID
if read_id != last_read_id:
last_read_id = read_id
yield read_id
#Yield the full line without stripping whitespace
elif output_type == 'full_line':
yield line

Expand All @@ -107,10 +107,9 @@ def get_hits_bam(self, inBam, db, threads=None):
threads=threads)

def get_hits_fasta(self, inFasta, db, threads=None, task=None, outfmt='6', max_target_seqs=1, output_type='read_id'):
_log.debug("Executing get_hits_fasta function.")
_log.debug(f"get_hits_fasta called with outfmt: {outfmt}")
_log.debug(f"Executing get_hits_fasta function. Called with outfmt: {outfmt}")
with open(inFasta, 'rt') as inf:
for hit in self.get_hits_pipe(inf, db, threads=threads, task=None, outfmt=outfmt, max_target_seqs=1, output_type=output_type):
for hit in self.get_hits_pipe(inf, db, threads=threads, task=None, outfmt=outfmt, max_target_seqs=max_target_seqs, output_type=output_type):
yield hit


Expand Down
2 changes: 1 addition & 1 deletion taxon_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def chunk_blast_hits(inFasta, db, blast_hits_output, threads=None, chunkSize=100
else:
#Pipe tools together and run blastn multithreaded
with open(blast_hits_output, 'wt') as outf:
for output in classify.blast.BlastnTool().get_hits_fasta(inFasta, db, threads,task=None, outfmt='6', max_target_seqs=1, output_type=output_type):
for output in classify.blast.BlastnTool().get_hits_fasta(inFasta, db, threads, task=task, outfmt=outfmt, max_target_seqs=max_target_seqs, output_type=output_type):
#Account for read_ids extract only or full blast output run. Default = read_lines.
if output_type == 'read_id':
# Extract the first clmn in the output (assuming its the read ID)
Expand Down

0 comments on commit 3801db2

Please sign in to comment.