Python program to find the indexes of Cys in the given mutlifasta sequences
# Program to find the indexes of Cys in the given mutlifasta sequences
fasta = open('out.fa', 'r+')
for line in fasta.read().split('\n'):
if line.startswith(">"):
header = line
print(header)
else:
indexes = []
for i in range(0, len(line)-1):
if line[i] == 'C':
indexes.append(i+1)
print("Cys : ", indexes)
• 1,322 views
•
link
1 answer
You will need BioPython for this to work.
import sys
from Bio import SeqIO
FastaFile = open(sys.argv[1], 'r')
for seqs in SeqIO.parse(FastaFile, 'fasta'):
indexes = []
name = seqs.id
seq = seqs.seq
seqLen = len(seqs)
for z in range(seqLen):
if seq[z]=='c' or seq[z]=='C':
indexes.append(z+1)
print('>%s' % name)
print(indexes)
Save as Cys_index.py and run:
python Cys_index.py out.fa
• 0 views
•
link
Log in to answer this question.
Is there a question?