I need help for a command that I wrote in perl
1
0
Entering edit mode
8.1 years ago
mark2020 • 0

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 • 2.1k views
ADD COMMENT
2
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode

This sounds suspiciously homework-y.

ADD REPLY
0
Entering edit mode

thanks for your comments I edited my question.

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
8.1 years ago
Eric Lim ★ 2.2k

Google 'perl grep command line'.

ADD COMMENT
3
Entering edit mode

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 REPLY
1
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1362 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