Skip to content

Commit

Permalink
better message formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
snacktavish committed Aug 10, 2019
1 parent d3b4b4f commit 55b37a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion physcraper/aligntreetax.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from physcraper.helpers import standardize_label, to_string, debug

_VERBOSE = 1
_DEBUG = 1
_DEBUG = 0

def generate_ATT_from_files(seqaln,
mattype,
Expand Down
2 changes: 1 addition & 1 deletion physcraper/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import contextlib


_DEBUG = 1
_DEBUG = 0
def debug(msg):
"""short debugging command
"""
Expand Down
13 changes: 7 additions & 6 deletions physcraper/scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ def read_local_blast_query(self, fn_path):
fn.write("blast_threshold_not_passed: {}, {}, {}\n".format(sscinames, gb_acc, gi_id))
fn.close()
else:
sys.stdout.write("skipping acc {}, incorrect format\n".format(gb_acc))
pass
#sys.stdout.write("skipping acc {}, unexpected format\n".format(gb_acc))



Expand Down Expand Up @@ -652,18 +653,18 @@ def seq_dict_build(self, seq, new_otu_label, seq_dict):
reason = "seq {} is supersequence of original seq {}, "\
"both kept in alignment ".format(new_otu_label, otu_lab)
if _VERBOSE or _DEBUG:
sys.stdout.write(reason)
sys.stdout.write("\n" + reason)
elif existing_tax_id != tax_new_seq: # different taxa
reason = "seq {} is supersequence of {}, but different taxon ".format(new_otu_label, otu_lab)
if _VERBOSE or _DEBUG:
sys.stdout.write(reason)
sys.stdout.write("\n" + reason)
#can still be added
else:
# new seq s a super sequence, delet old one and add new one. DO NOT KEEP CHECKING
del seq_dict[otu_lab]
seq_dict[new_otu_label] = seq
self.data.remove_taxa_aln_tre(otu_lab)
reason = "seq {} is supersequence of {}, {} added and {} removed ".format(new_otu_label, otu_lab, new_otu_label, otu_lab)
reason = "\nseq {} is supersequence of {}, {} added and {} removed ".format(new_otu_label, otu_lab, new_otu_label, otu_lab)
if _VERBOSE or _DEBUG:
sys.stdout.write(reason)
self.data.otu_dict[otu_lab]['^physcraper:status'] = "deleted, {} is supersequence ".format(new_otu_label)
Expand Down Expand Up @@ -737,13 +738,13 @@ def filter_seqs(self, tmp_dict, threshold=5, type="random"):
aln_sp_d = self.make_sp_dict(aln_otus)
debug("There are {} taxa in aln".format(len(aln_sp_d)))
alltax = set(new_sp_d.keys()).union(aln_sp_d.keys())
debug("The total set of taxa counts {}".format(len(alltax)))
sys.stdout.write("{} taxa in orginal alignment; {} taxa in updated alignemnt {}, keeping max {} seq per taxon".format(len(aln_sp_d), len(alltax)), threshold)
for tax_id in new_sp_d:
debug(" {} new seqs for taxon {}".format(len(new_sp_d[tax_id]), tax_id))
tax_otus = []
current_num = len(aln_sp_d.get(tax_id, []))
if current_num > threshold:
sys.stdout.write("no sequences added for taxon {}, as {} already in alignmenet".format(tax_id, current_num))
# sys.stdout.write("no sequences added for taxon {}, as {} already in alignmenet".format(tax_id, current_num))
pass #already enough
else:
count = threshold - len(aln_sp_d.get(tax_id,[]))
Expand Down

0 comments on commit 55b37a3

Please sign in to comment.