-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreClustering.py
More file actions
42 lines (30 loc) · 936 Bytes
/
Copy pathpreClustering.py
File metadata and controls
42 lines (30 loc) · 936 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
'''
@auther: Samaneh
'''
from Bio import SeqIO
def prepareNamesList(clusterNamesFile):
idList = []
lines = clusterNamesFile.readlines()
for line in lines:
words = line.split()
if len(words)==1:
idList.append(words[0])
return idList
def filtering(isolatedList):
sprot = "/home/samaneh/AHRD/data/db/uniprot_sprot.fasta"
reducedSprot = open("/home/samaneh/AHRD/data/db/uniprot_sprot_filteredForClustering.fasta", "w")
removingList = []
for record in SeqIO.parse(sprot, "fasta"):
for name in isolatedList:
if name in record.name:
removingList.append(record.id)
for record in SeqIO.parse(sprot,"fasta"):
if record.id not in removingList:
SeqIO.write(record, reducedSprot, "fasta" )
reducedSprot.close()
def handler():
clusterFile = open("/home/samaneh/AHRD/clustering/clusters.txt","r")
isolatedList = prepareNamesList(clusterFile)
filtering(isolatedList)
if __name__ == "__main__":
handler()