-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplitChromV1.3.py
44 lines (37 loc) · 964 Bytes
/
SplitChromV1.3.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
44
###############
# Functions #
###############
import sys
def SplitChrom(filename):
F = open(filename, "r")
i = 0
R = open("Report.txt", "w")
Genome = F.readlines()
Lines = ""
names = []
for line in Genome:
line = line.strip()
if len(line) == 0:
continue
if line[0] == ">":
R.close()
if line[1:20] in names:
i = i + 1
FILE = line[1:20] + "_" + str(i) + ".txt"
else:
names.append(line[1:20])
FILE = line[1:20] + ".txt"
R = open(FILE, "w")
R.write(">" + FILE + "\n")
Lines = Lines + FILE + "\n"
else:
R.write(line)
R.close()
R = open("ChromosomeList.txt", "w")
R.write(Lines)
R.close()
###############
# Arguments #
###############
filename = sys.argv[1]
SplitChrom(filename)