diff --git a/mOTUlizer/__init__.py b/mOTUlizer/__init__.py index 6b2783f..4ece098 100644 --- a/mOTUlizer/__init__.py +++ b/mOTUlizer/__init__.py @@ -10,7 +10,7 @@ if os.path.exists(".git"): label = subprocess.check_output(["git", "describe", "--tags"]).strip().decode() else: - label = "0.2.3" + label = "0.2.4" os.chdir(cwd) diff --git a/mOTUlizer/bin/mOTUlize.py b/mOTUlizer/bin/mOTUlize.py index 785f6bf..cfff52d 100755 --- a/mOTUlizer/bin/mOTUlize.py +++ b/mOTUlizer/bin/mOTUlize.py @@ -10,6 +10,7 @@ import multiprocessing from mOTUlizer.classes import * from mOTUlizer.utils import * +from mOTUlizer.config import FASTA_EXTS from mOTUlizer.classes.MetaBin import MetaBin from mOTUlizer.classes.mOTU import mOTU from mOTUlizer import __version__ @@ -28,7 +29,6 @@ """ -fasta_exts = [".fna", ".fa", ".fasta", ".fna", ".ffn"] def motulize(args): #parse and check your amino-acid files @@ -73,8 +73,8 @@ def motulize(args): for l in handle: if "query" not in l: ll = l.split("\t") - g1 = ".".join(os.path.basename(ll[0]).split(".")[:-1]) if any([ll[0].endswith(ext) for ext in fasta_exts]) else ll[0] - g2 = ".".join(os.path.basename(ll[1]).split(".")[:-1]) if any([ll[1].endswith(ext) for ext in fasta_exts]) else ll[1] + g1 = ".".join(os.path.basename(ll[0]).split(".")[:-1]) if any([ll[0].endswith(ext) for ext in FASTA_EXTS]) else ll[0] + g2 = ".".join(os.path.basename(ll[1]).split(".")[:-1]) if any([ll[1].endswith(ext) for ext in FASTA_EXTS]) else ll[1] dist = float(ll[2]) dist_dict[(g1,g2)] = dist else : diff --git a/mOTUlizer/classes/MetaBin.py b/mOTUlizer/classes/MetaBin.py index f86d6db..ef8dade 100644 --- a/mOTUlizer/classes/MetaBin.py +++ b/mOTUlizer/classes/MetaBin.py @@ -4,6 +4,7 @@ from subprocess import Popen, PIPE, call import os import shutil +from mOTUlizer.config import FASTA_EXTS class MetaBin: def __repr__(self) : @@ -81,7 +82,10 @@ def get_anis(cls, bins, outfile = None, method = "fastANI", block_size = 500, th os.remove(b1_tfile) with open(fastani_file) as handle: handle.readline() - out_dists = {(l.split()[0], l.strip().split()[1]) : float(l.split()[2]) for l in handle} + out_dists = {(os.path.basename(l.split()[0]), os.path.basename(l.strip().split()[1])) : float(l.split()[2]) for l in handle} + out_dists = {( ".".join(k[0].split(".")[:-1]) if any([k[0].endswith(ext) for ext in FASTA_EXTS]) else k[0], + ".".join(k[1].split(".")[:-1]) if any([k[1].endswith(ext) for ext in FASTA_EXTS]) else k[1] ): v + for k,v in out_dists.items() } # tfile = lambda k : ".".join(k.split(".")[:-1]) if (k.endswith(".fna") or k.endswith(".fa") or k.endswith(".fasta") or k.endswith(".fna") or k.endswith(".ffn")) else k # out_dists = {(tfile(k[0]),tfile(k[1])) : v for k,v in out_dists.items()} if outfile is None: diff --git a/mOTUlizer/config.py b/mOTUlizer/config.py index 70811a5..8b8db8e 100644 --- a/mOTUlizer/config.py +++ b/mOTUlizer/config.py @@ -1,2 +1,3 @@ MIN_PROB = -1000 # log10 of prob of impossible event DB_FOLDER = "/home/moritz/dbs/" +FASTA_EXTS = [".fna", ".fa", ".fasta", ".fna", ".ffn"]