-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCombinedMasked.py
More file actions
executable file
·48 lines (35 loc) · 1.03 KB
/
CombinedMasked.py
File metadata and controls
executable file
·48 lines (35 loc) · 1.03 KB
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
44
45
46
47
#!/usr/bin/env python
import sys
fileList=sys.argv[1]
outputFile=sys.argv[2]
chroms={}
ifl=open(fileList)
inFiles=ifl.readlines()
for line in inFiles:
tmp=open(line.rstrip())
header=tmp.readline()[1:]
vals=header.split("/")
pre="/".join(vals[:-1])
suf=int(vals[-1])
print(suf)
tmp.close()
if pre not in chroms:
chroms[pre] = {}
chroms[pre][suf] = line.rstrip()
outFile=open(outputFile,'w')
for pre in chroms:
outFile.write(">" + pre + "\n")
nParts=max(chroms[pre].keys())
seq=""
for i in range(0,nParts+1):
partFile=open(chroms[pre][i])
print("appending " + str(pre) + " " + str(i))
partFile.readline()
seq+="".join([l.strip() for l in partFile.readlines()])
print("chrom " + pre + " has length " + str(len(seq)))
last=int(len(seq)/60)
chromSeq="\n".join([seq[j*60:(j+1)*60] for j in range(0,last) ])
if len(seq) % 60 != 0:
chromSeq += "\n" + seq[last*60:]
chromSeq += "\n"
outFile.write(chromSeq)