-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrepeat_masker_run_big_microsat.py
executable file
·44 lines (35 loc) · 1.4 KB
/
repeat_masker_run_big_microsat.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
37
38
39
40
41
42
43
#!/usr/bin/python
import sys, os
from subprocess import call
from commands import getstatusoutput
from os import listdir
from os.path import isfile, join
print "\nUsage: repeat_masker_run_big.py ListOfSequences NumberOfThreads\n"
try:
lista = sys.argv[1]
except:
lista = raw_input("Introduce list of fastq.gz files: ")
try:
threads = sys.argv[2]
except:
threads = raw_input("Intruduce number of threads: ")
files = open(lista).readlines()
for file in files:
file = file[:-1]
n_nucs = getstatusoutput("""grep -v ">" %s | wc | awk '{print $3-$1}'""" % (file))
n_nucs = int(n_nucs[1])
n_division = n_nucs/10**8
if n_division > 0:
call("faSplit sequence %s %s %s" % (file,str(n_division+1),file+".split.."), shell=True)
onlyfiles = [f for f in listdir(".") if isfile(join(".",f))]
splits = []
for f in onlyfiles:
if f.startswith(file+".split.") and f.endswith(".fa"):
splits.append(f)
splits.sort()
for n in range(0,len(splits)):
call("RepeatMasker -pa %s -a -int -no_is %s" % (threads, splits[n]), shell=True)
call("cat %s >> %s" % (splits[n]+".align",file+".align"), shell=True)
elif n_division == 0:
call("RepeatMasker -pa %s -a -int -no_is %s" % (threads, file), shell=True)
call("calcDivergenceFromAlign.pl -s %s %s" % (file+".align.divsum", file+".align"), shell=True)