-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecialgene.py
More file actions
60 lines (50 loc) · 1.74 KB
/
specialgene.py
File metadata and controls
60 lines (50 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import subprocess as sp
import csv
from helpers import timestamp
def special_gene_search(
input, input_path, mob_out_path, rep_out_path, con_out_path, mob_write_path,
rep_write_path, con_write_path, db_path, err_file
):
try:
n, frag = input
input_file = f'{input_path}/{n}'
mob_db_file = f"{db_path}/mobilization"
rep_db_file = f"{db_path}/replication"
con_db_file = f"{db_path}/conjugation"
mob_out_file = f"{mob_out_path}/{n}.mob.hmm.out"
rep_out_file = f"{rep_out_path}/{n}.rep.hmm.out"
con_out_file = f"{con_out_path}/{n}.con.hmm.out"
mob_write_file = f"{mob_write_path}/{n}"
rep_write_file = f"{rep_write_path}/{n}"
con_write_file = f"{con_write_path}/{n}"
mob_cmd = [
'hmmsearch',
'--noali',
'--cpu', '1',
'-E', '1E-10',
'--tblout', str(mob_out_file),
str(mob_db_file),
str(input_file)
]
proc = sp.run(
mob_cmd,
stdout=sp.PIPE,
stderr=sp.PIPE,
universal_newlines=True
)
tsvfile = open(mob_out_file)
fh = csv.reader(tsvfile, delimiter="\t")
lengths = []
bitscores = []
count = 0
for line in fh:
# if(line[0][0] != '#'):
print(line)
# cols = line[0].strip().split()
# lengths.append(abs(int(cols[8])- int(cols[7])))
# bitscores.append(float(cols[14]))
# count+=1
tsvfile.close()
except Exception as err:
with open(err_file, 'a') as fout:
fout.write(f"{timestamp()} Error calculating rrna factor for file:{n} {err}\n")