Skip to content

Commit 37dceaa

Browse files
committed
separate script folder, add executables
1 parent c367db2 commit 37dceaa

9 files changed

Lines changed: 56 additions & 31 deletions

File tree

.Rhistory

Whitespace-only changes.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
import sys
88
import argparse
99
import os, errno
10-
from viralverify import check_circular
10+
11+
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'scripts'))
12+
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'db'))
13+
14+
15+
import check_circular
1116

1217
def parse_args(args):
1318
###### Command Line Argument Parser

viralverify.py renamed to bin/viralverify

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/usr/bin/env python3
2-
import os, errno
2+
33
import sys
4+
import os, errno
5+
6+
7+
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'scripts'))
8+
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'db'))
9+
10+
print(sys.path)
11+
412
import argparse
513
import collections
614
from math import log
@@ -9,6 +17,7 @@
917
import operator
1018
import fastaparser
1119
import logging
20+
from check_circular import check_circular
1221

1322
def parse_args(args):
1423
###### Command Line Argument Parser
@@ -31,34 +40,6 @@ def parse_args(args):
3140

3241

3342

34-
def check_circular(file, name):
35-
contigs = fastaparser.read_fasta(file)
36-
count = []
37-
circular_contigs = {}
38-
input_fasta = name + "_input_with_circ.fasta"
39-
40-
with open(input_fasta, 'w') as output:
41-
42-
for contig in contigs:
43-
circular_contigs[contig[0].split(" ")[0][1:]] = [len(contig[1]), "-"]
44-
for kval in range (200,50, -1):
45-
if kval >= len(contig[1]) or len(contig[1]) < 500:
46-
continue
47-
start = contig[1][:kval]
48-
end = contig[1][-kval:]
49-
50-
if start == end:
51-
circular_contigs[contig[0].split(" ")[0][1:]] = [len(contig[1]), "+"]
52-
break
53-
54-
55-
output.write(contig[0]+"\n")
56-
if circular_contigs[contig[0].split(" ")[0][1:]][1] == "-":
57-
output.write(contig[1]+"\n")
58-
elif circular_contigs[contig[0].split(" ")[0][1:]][1] == "+":
59-
output.write(contig[1]+contig[1][kval:5000]+"\n")
60-
61-
return(circular_contigs)
6243

6344

6445

@@ -106,7 +87,7 @@ def get_table_from_tblout(tblout_pfam):
10687

10788

10889
def naive_bayes(input_list, unc_score):
109-
tr=os.path.dirname(os.path.abspath(__file__)) + "/classifier_table_uniq.txt"
90+
tr = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'db',"classifier_table_uniq.txt")
11091

11192
with open(tr, 'r') as infile:
11293
table=infile.readlines()

scripts/check_circular.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
def check_circular(file, name):
2+
import fastaparser
3+
contigs = fastaparser.read_fasta(file)
4+
count = []
5+
circular_contigs = {}
6+
input_fasta = name + "_input_with_circ.fasta"
7+
8+
with open(input_fasta, 'w') as output:
9+
10+
for contig in contigs:
11+
circular_contigs[contig[0].split(" ")[0][1:]] = [len(contig[1]), "-"]
12+
for kval in range (200,50, -1):
13+
if kval >= len(contig[1]) or len(contig[1]) < 500:
14+
continue
15+
start = contig[1][:kval]
16+
end = contig[1][-kval:]
17+
18+
if start == end:
19+
circular_contigs[contig[0].split(" ")[0][1:]] = [len(contig[1]), "+"]
20+
break
21+
22+
23+
output.write(contig[0]+"\n")
24+
if circular_contigs[contig[0].split(" ")[0][1:]][1] == "-":
25+
output.write(contig[1]+"\n")
26+
elif circular_contigs[contig[0].split(" ")[0][1:]][1] == "+":
27+
output.write(contig[1]+contig[1][kval:5000]+"\n")
28+
29+
return(circular_contigs)
30+
31+
32+
def main():
33+
import sys
34+
check_circular(sys.argv[1], sys.argv[2])
35+
36+
37+
if __name__ == "__main__":
38+
main()
39+
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)