-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractClustersDescriptions.py
More file actions
52 lines (38 loc) · 1.11 KB
/
Copy pathextractClustersDescriptions.py
File metadata and controls
52 lines (38 loc) · 1.11 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
48
'''
@auther: Samaneh
This module reads the cluster file generated by CD-HIT software and extract sequences'
names of the clusters into a text file
'''
from Bio import SeqIO
import pandas as pd
import numpy as np
import xlsxwriter
import re
##################################################################################
def extraction(clusterFile):
sepFile = open("/home/samaneh/AHRD/clustering/clusters.txt","w")
clstr = clusterFile.readlines()
temprow = 0
clstrNumber = "Null"
seqIdList = []
for line in file:
if ">Cluster" in line:
if clstrNumber != "Null":
seqIdDict[clstrNumber]=seqIdList
l = len(seqIdList)
for i in range (0,l):
sepFile.write(seqIdList[i])
sepFile.write(" ")
sepFile.write("\n")
seqIdList = []
clstrNumber = re.sub("\>[A-Za-z]*\s","",line)
if ">sp|" in line:
line = re.sub(".*>sp\|","",line)
seqId = re.sub("\|.*","",line)
seqId = seqId.strip("\n")
seqIdList.append(seqId)
def main():
clstrFile = open("/home/samaneh/AHRD/clustering/uniprot_sprot_clusterd.clstr","r")
extraction(clstrFile)
if __name__ == "__main__":
main()