Skip to content

Commit

Permalink
some output formating
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzbuck committed Jul 8, 2021
1 parent 6abf901 commit fe9fd82
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Binary file modified example_files/example_PAN.db
Binary file not shown.
6 changes: 4 additions & 2 deletions mOTUlizer/bin/anvi-script-compute-bayesian-pan-core
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def main(args):

if args.num_bootstraps :
motu.roc_values(boots=args.num_bootstraps)
rocs = motu.roc_values(0)
run.warning("You ran the bootstrap option for the pangenome predition, if you have no output file the results are only shown here :", lc = "gray")
for k,v in rocs.items() :
run.info(k,"{:.2f}".format(v) if k != 'nb_bootstraps' else v, lc = "gray")

if args.store_in_db:
data2add = {g: {'Gene_cluster_type' : 'CORE' if g in motu.core else 'ACCESSORY', 'Gene_cluster_type_LLR' : motu.likelies[g]} for g in pan.gene_cluster_names}
Expand All @@ -147,8 +151,6 @@ def main(args):
print(motu.pretty_pan_table(), file = handle)
run.info("Output file", args.output_file, mc="green", nl_before=1)

if args.num_bootstraps > 0:
print(motu.roc_values(0))


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion mOTUlizer/classes/MockData.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MockmOTU(mOTU):
def __repr__(self) :
return "< MockmOTU with {n} genomes, of average {c}% completness, with core/genome_len of {r} >".format(c = 100*self.mean_completeness, n = len(self), r = self.ratio)
return "< MockmOTU with {n} genomes, of average {c}% completness>".format(c = 100*self.mean_completeness, n = len(self))

def __init__(self, name, core_len, nb_genomes, completeness, max_it = 20, accessory = None, method = None):

Expand Down
9 changes: 7 additions & 2 deletions mOTUlizer/classes/mOTU.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,13 @@ def __core_likelyhood(self, max_it = 20, likeli_cutof = 0 ):
core_len = new_core_len

if not self.quiet:
json.dump({ self.name : {"nb_mags" : len(self), "core_len" : core_len, "mean_starting_completeness" : mean([b.checkm_complet for b in self]), "mean_new_completness" : mean([b.new_completness for b in self]), "LHR" : sum([l if l > 0 else -l for l in likelies.values()]), "mean_est_binsize" : mean([100*len(b.gene_clusterss)/b.new_completness for b in self])}}, sys.stderr )
print(file = sys.stderr)
pp = "\nYour {name}-run for {nb_mags} genomes (with mean initial completeness {mean_start:.2f}) resulted\n"
pp += "in a core of {core_len} traits with a total sum of loglikelihood-ratios {llhr:.2f} and a corrected \n"
pp += "mean completness of {mean_new:.2f}, resulting to a estimated mean traits per genome count of {trait_count:.2f}\n"
pp = pp.format(name = self.name, nb_mags = len(self), core_len = core_len, mean_start = mean([b.checkm_complet for b in self]),
mean_new = mean([b.new_completness for b in self]), llhr = sum([l if l > 0 else -l for l in likelies.values()]),
trait_count = mean([100*len(b.gene_clusterss)/b.new_completness for b in self]))
print(pp, file = sys.stderr)
self.iterations = i -1
return likelies

Expand Down

0 comments on commit fe9fd82

Please sign in to comment.