Python program to find the indexes of Cys in the given mutlifasta sequences

Python program to find the indexes of Cys in the given mutlifasta sequences

1

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)                


a


indexes


file


given


in


cys


multifasta

• 35 views

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


Login
before adding your answer.

Read more here: Source link