Question: about bioperl script for extracting sequences from a fasta file(get orf output file) with ids which has less than 30 amino acids
gravatar for yaminivadapally
4 months 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 • 227 views
ADD COMMENTlink modified 4 months ago by Nitin Narwade380 • written 4 months ago by yaminivadapally0

Smell of a homework assignment ! Although, Nitin Narwade has answered your question, you are supposed to write your own code and ask for help in case of errors or problems. You cannot ask for the complete ready made solution. This is not the way this forum is supposed to be used.

For trivial tasks like this , I would recommend using tools like seqkit however, if that is your programming assignment, please make some efforts or show us your efforts here before posting.

ADD REPLYlink modified 3 months ago • written 3 months ago by Vijay Lakhujani3.6k
gravatar for Nitin Narwade
4 months ago by
Nitin Narwade380
NCCS, Pune
Nitin Narwade380 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
        seq += line
if(len(seq) < 30):
    fwrite.write (header + "\n" + seq + "\n")

ADD COMMENTlink written 4 months ago by Nitin Narwade380
Please log in to add an answer.


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