Question: I need help for a command that I wrote in perl
0
gravatar for mark2020
2.0 years ago by
mark20200
mark20200 wrote:

I wanna extract the header line from 2 protein sequences for example: I created the file, then I gave the file name, then I wanna extract header, then from the second sequence.

here I showed what's the header in below:

gi|628601924|ref|NP_001278775.1| DNA-binding protein Ikaros isoform 16 [Homo sapiens] These are my protein fasta with heder that i wanna extract the header from them:

gi|628601924|ref|NP_001278775.1| DNA-binding protein Ikaros isoform 16 [Homo sapiens] MDADEGQDMSQVSGKESPPVSDTPDEGDEPMPIPEDLSTTSGGQQSSKSDRVVVTYGADDFRDFHAIIPK SFSLLEL

gi|628601926|ref|NP_001278776.1| DNA-binding protein Ikaros isoform 16 [Homo sapiens] MDADEGQDMSQVSGKESPPVSDTPDEGDEPMPIPEDLSTTSGGQQSSKSDRVVVTYGADDFRDFHAIIPK SFSLLEL

I wrote this command:

   print "Please enter a file name: ";
   $file = <>;
   open INFILE, $file;

   $line = <INFILE>;

   while (defined($line = <INFILE>)){
   }
   chomp $line;

if ($line =~ /^>(S+)\s*(.*)$/;){

 $id = $1; # what should I write here to activate these $1 and $2

 $description = $2;

   print substr($1 $2); #what else should I add here
   }

   } else {# I need to write some thing here, like this it's not header don't  extract it 

   }
   next; # is this enough for going to the next sequence 

   close INFILE;
software error • 863 views
ADD COMMENTlink modified 2.0 years ago by geek_y8.7k • written 2.0 years ago by mark20200
2

If you just need the header line then you could grep ">" .. no need for PERL.

ADD REPLYlink written 2.0 years ago by genomax57k
1

Why only perl? Is this homework? BTW, this was answered many a times in this forum.

ADD REPLYlink written 2.0 years ago by venu5.6k
1

This sounds suspiciously homework-y.

ADD REPLYlink written 2.0 years ago by Chris Fields1.9k

thanks for your comments I edited my question.

ADD REPLYlink written 2.0 years ago by mark20200

Please use ADD REPLY/ADD COMMENT when responding to existing posts to keep threads logically organized.

The original question is still unanswered. Is this a homework question?

Hint: If you just need to print the header line then check to see if the line begins with "^>" otherwise go to next line.

ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by genomax57k
0
gravatar for Eric Lim
2.0 years ago by
Eric Lim1.1k
Boston
Eric Lim1.1k wrote:

Google 'perl grep command line'.

ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by Eric Lim1.1k
3

When a question is suspiciously specific (e.g. need PERL solution) we try to encourage the OP to research a solution on their own (unless they provide an explanation that makes a compelling case). It is not helpful to provide a ready solution, especially if this is part of a homework assignment.

ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by genomax57k
1

I know, but it's Friday and I want to be nice. Answer changed.

ADD REPLYlink written 2.0 years ago by Eric Lim1.1k
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: 685 users visited in the last hour