i want to replace name of the sequences in fasta file after '>' sign with the protein id within the header line.i wrote a perl script but it only prints the firstline of the sequence itself(given below).
I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:
I'm biased, but Perl is also not the easiest language to start with as a beginner (consider python).
Can you show us your input data too (just 3 or 4 sequences would do). It's not clear where the headers are coming from (I'm guessing they're already in the fasta and you're just deleting part of the header judging by your perl substitution.
Thankyou so much..your script works perfectly. ;)
Even though i've merged the multifasta sequence as single sequence,then my program also worked nicely.
perl -lne activates perl in execute mode and new line read
( condition ) ? exec1 : exec2 this is a if-then-else abbreviated, if condition, then do exec1, otherwise do exec2
m/>.+\[protein_id=(.+?)\]/ this is a regular expression evaluation, looks for a line with >, then followed by any chars (.+) and looks for a string [protein_id=, the text after that will be recorded in in a match variable ($1), it is marked as any char but expanded until a ] is seen (.+?)].
Finally, if the match exists, it will print a new line as >$1, otherwise will print the line as read
I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:
Thanks a lot... Please help me on my program
Is there a reason you aren’t just using
Bio::Perl
?Hii.. I'm a beginner in Perl scripting and scripting in general.Also i'm not familiar with bioperl modules. that's why..
It's generally easier to use something that already exists, rather than reinventing the wheel.
I'm biased, but Perl is also not the easiest language to start with as a beginner (consider python).
Can you show us your input data too (just 3 or 4 sequences would do). It's not clear where the headers are coming from (I'm guessing they're already in the fasta and you're just deleting part of the header judging by your perl substitution.
Here with the example of my input file..
and the output should be like the following.. thanks.
An example of your input file and how do you want the output could be helpful.
BTW I proficient in Perl and Python, still using primarily Perl ;)