-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* modify scripts to include log file option * fix parsing and output * fix issues with logging * fixed output * remove -c from scripts, update README * little fixes * upversion pip, show compatibility with python 2.7
- Loading branch information
Showing
14 changed files
with
545 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
import pandas as pd | ||
from settings import MONGODB as db | ||
import re | ||
from subprocess import Popen, PIPE | ||
|
||
species = db["genes"].distinct("species") | ||
name_dict = {sub(r"[. -\(\)]", "_", x):x for x in species} | ||
|
||
l = len(species) | ||
data = {s:[0 for x in range(l)] for s in species} | ||
dm = pd.DataFrame(data, index=species) | ||
dm = pd.read_csv("/Users/KBLaptop/Desktop/ani_matrix.csv", index_col=0) | ||
|
||
d = "/Users/KBLaptop/Desktop/ani" | ||
for f1 in os.listdir(d): | ||
for f2 in os.listdir(d): | ||
if f1.endswith(".fna") and f2.endswith(".fna"): | ||
s1 = name_dict[f1[:-4]] | ||
s2 = name_dict[f2[:-4]] | ||
if s1 == "Glutamicibacter arilaitensis Re117" or s2 == "Glutamicibacter arilaitensis Re117": | ||
if s1.split()[0] == s2.split()[0]: | ||
print(s1) | ||
print(s2) | ||
if s1 == s2: | ||
dm.loc[s1, s2] = 100.0 | ||
pass | ||
else: | ||
dist = Popen( | ||
['ruby', '/Users/KBLaptop/computation/Science/enveomics/Scripts/ani.rb', | ||
'--seq1', os.path.join(d, f1), | ||
'--seq2', os.path.join(d, f2), | ||
'--auto', '--quiet'], | ||
stdout=PIPE # xml output | ||
).communicate()[0] | ||
|
||
try: | ||
print(float(dist.strip())) | ||
dm.loc[s1, s2] = float(dist.strip()) | ||
except ValueError: | ||
pass | ||
|
||
dm.to_csv("/Users/KBLaptop/Desktop/ani_matrix.csv") |
Oops, something went wrong.