-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgff_trna_parse_dir.py
36 lines (31 loc) · 1.09 KB
/
gff_trna_parse_dir.py
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
#!/usr/bin/env python
import warnings
import sys, argparse, os, subprocess
from collections import defaultdict
parser = argparse.ArgumentParser(description="")
#~ parser.add_argument("query", help="Query FASTA")
parser.add_argument("dir", help="Target dir")
#~ parser.add_argument("--tblastn", default=False, action="store_true", help="Use TBLASTN instead of BLASTP")
#~ parser.add_argument("--blastn", default=False, action="store_true", help="Use BLASTN instead of BLASTP")
#~ parser.add_argument("--eval", default="1E-5", help="Evalue")
args = parser.parse_args()
trnas = defaultdict(lambda : defaultdict(int))
trnas_list = set()
for f1 in sorted(os.listdir(args.dir)):
if f1.find(".gff") != -1:
with open(args.dir+"/"+f1, "r") as f:
for l in f:
gene = l.split()[2]
if gene == "gene":
trna = l.split()[-1][l.split()[-1].find("noncoding-")+10:l.split()[-1].find("-gene-")]
trnas[f1][trna] += 1
trnas_list.add(trna)
print "",
for trna in sorted(trnas_list):
print trna,
print
for f in sorted(trnas.keys()):
print f,
for trna in sorted(trnas_list):
print trnas[f][trna],
print