Python program to find the indexes of Cys in the given mutlifasta sequences
1
0
Entering edit mode
12 months ago
devhimd • 0

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)                
a indexes file given in cys multifasta • 470 views
ADD COMMENT
0
Entering edit mode

Is there a question?

ADD REPLY
0
Entering edit mode
12 months ago
Mensur Dlakic ★ 20k

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
ADD COMMENT

Login before adding your answer.

Traffic: 2058 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6