Skip to content

Commit

Permalink
separate script folder, add executables
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeraiko committed Aug 21, 2021
1 parent c367db2 commit 37dceaa
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 31 deletions.
Empty file added .Rhistory
Empty file.
7 changes: 6 additions & 1 deletion training_script.py → bin/training_script
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import sys
import argparse
import os, errno
from viralverify import check_circular

sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'scripts'))
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'db'))


import check_circular

def parse_args(args):
###### Command Line Argument Parser
Expand Down
41 changes: 11 additions & 30 deletions viralverify.py → bin/viralverify
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/usr/bin/env python3
import os, errno

import sys
import os, errno


sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'scripts'))
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'db'))

print(sys.path)

import argparse
import collections
from math import log
Expand All @@ -9,6 +17,7 @@
import operator
import fastaparser
import logging
from check_circular import check_circular

def parse_args(args):
###### Command Line Argument Parser
Expand All @@ -31,34 +40,6 @@ def parse_args(args):



def check_circular(file, name):
contigs = fastaparser.read_fasta(file)
count = []
circular_contigs = {}
input_fasta = name + "_input_with_circ.fasta"

with open(input_fasta, 'w') as output:

for contig in contigs:
circular_contigs[contig[0].split(" ")[0][1:]] = [len(contig[1]), "-"]
for kval in range (200,50, -1):
if kval >= len(contig[1]) or len(contig[1]) < 500:
continue
start = contig[1][:kval]
end = contig[1][-kval:]

if start == end:
circular_contigs[contig[0].split(" ")[0][1:]] = [len(contig[1]), "+"]
break


output.write(contig[0]+"\n")
if circular_contigs[contig[0].split(" ")[0][1:]][1] == "-":
output.write(contig[1]+"\n")
elif circular_contigs[contig[0].split(" ")[0][1:]][1] == "+":
output.write(contig[1]+contig[1][kval:5000]+"\n")

return(circular_contigs)



Expand Down Expand Up @@ -106,7 +87,7 @@ def get_table_from_tblout(tblout_pfam):


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

with open(tr, 'r') as infile:
table=infile.readlines()
Expand Down
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions scripts/check_circular.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
def check_circular(file, name):
import fastaparser
contigs = fastaparser.read_fasta(file)
count = []
circular_contigs = {}
input_fasta = name + "_input_with_circ.fasta"

with open(input_fasta, 'w') as output:

for contig in contigs:
circular_contigs[contig[0].split(" ")[0][1:]] = [len(contig[1]), "-"]
for kval in range (200,50, -1):
if kval >= len(contig[1]) or len(contig[1]) < 500:
continue
start = contig[1][:kval]
end = contig[1][-kval:]

if start == end:
circular_contigs[contig[0].split(" ")[0][1:]] = [len(contig[1]), "+"]
break


output.write(contig[0]+"\n")
if circular_contigs[contig[0].split(" ")[0][1:]][1] == "-":
output.write(contig[1]+"\n")
elif circular_contigs[contig[0].split(" ")[0][1:]][1] == "+":
output.write(contig[1]+contig[1][kval:5000]+"\n")

return(circular_contigs)


def main():
import sys
check_circular(sys.argv[1], sys.argv[2])


if __name__ == "__main__":
main()

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 37dceaa

Please sign in to comment.