-
Notifications
You must be signed in to change notification settings - Fork 1
/
processLastz.py
42 lines (34 loc) · 1.16 KB
/
processLastz.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
import argparse
import os
def main():
parser = argparse.ArgumentParser(description="")
parser.add_argument("-r", "--ref", required=True)
parser.add_argument("-fi", "--fai", required=True)
parser.add_argument("-w", "--workdir", required=True)
parser.add_argument("-a", "--alpha", required=True)
args = parser.parse_args()
ref = args.ref
fai = args.fai
workdir = args.workdir
alpha = args.alpha
chrs = []
with open(fai,'r') as f:
while True:
line = f.readline()[:-1]
if not line:
break
items = line.split('\t')
if line.startswith('chr'):
chrs.append(items[0])
for i in chrs:
if i == 'chrM':
continue
cmd = 'samtools faidx ' + ref + ' ' + i + ' > ' + workdir + '/' + i + '.fa'
os.system(cmd)
cmd = 'lastz ' + workdir + '/' + i + '.fa' + ' ' + alpha + ' ' + \
'--format=general:score,name1,strand1,size1,start1,' \
'end1,name2,strand2,identity,' \
'length1,align1' + ' > ' + workdir + '/' + i + '.xls'
os.system(cmd)
if __name__ == '__main__':
main()