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
10 weeks 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 • 180 views
ADD COMMENTlink modified 10 weeks ago by Nitin Narwade330 • written 10 weeks 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 6 weeks ago • written 6 weeks ago by Vijay Lakhujani3.4k
gravatar for Nitin Narwade
10 weeks ago by
Nitin Narwade330
NCCS, Pune
Nitin Narwade330 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 10 weeks ago by Nitin Narwade330
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: 1749 users visited in the last hour