Question: about bioperl script for extracting sequences from a fasta file(get orf output file) with ids which has less than 30 amino acids
0
gravatar for yaminivadapally
12 days ago by
yaminivadapally0 wrote:

i want the script to get sequences from a fasta file which is an output of jemboss(get orf) which has less than 30 amino acids

rna-seq bioperl python • 88 views
ADD COMMENTlink modified 12 days ago by Nitin Narwade270 • written 12 days ago by yaminivadapally0
4
gravatar for Nitin Narwade
12 days ago by
Nitin Narwade270
NCCS, Pune
Nitin Narwade270 wrote:

A plain python code:

fread = open("inputFileName.fasta", "r")
fwrite = open("output.fasta", "w")

header = ""
seq = ""

for line in fread:
    line = line.strip()
    if(line[0] == ">"):     
        if(header != ""):
            if(len(seq) < 30):
                fwrite.write (header + "\n" + seq + "\n")
            header = ""
            seq = ""
        header = line
    else:
        seq += line
if(len(seq) < 30):
    fwrite.write (header + "\n" + seq + "\n")

fread.close()
fwrite.close()
ADD COMMENTlink written 12 days ago by Nitin Narwade270
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1511 users visited in the last hour