-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathORF_Picker.py
More file actions
49 lines (39 loc) · 991 Bytes
/
ORF_Picker.py
File metadata and controls
49 lines (39 loc) · 991 Bytes
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
48
49
import os
for file in os.listdir():
if file.endswith(".trimmed"):
data = list()
tempHeader = ""
tempSeq = ""
with open(file) as fh:
for line in fh:
line = line.strip("\n")
if line.startswith(">"):
if tempSeq == "":
tempHeader = line
elif tempSeq != "":
data.append(tuple([tempHeader, tempSeq]))
tempHeader = line
tempSeq = ""
else:
tempSeq += line
data.append(tuple([tempHeader, tempSeq]))
tempHeader = ""
tempSeq = ""
pickedList = list()
geneIDList = list()
for entry in data:
header = entry[0]
header = header.strip('\n')
header = header.split("|")
header = header[1].split(":")
geneID = header[0]
if geneID not in geneIDList:
geneIDList.append(geneID)
pickedList.append(tuple([geneID, entry[1]]))
else:
continue
newFile = open(file + ".picked", "w")
for entry in pickedList:
newFile.write('>' + entry[0] + '\n')
newFile.write(entry[1] + '\n')
newFile.close()