A more readable version of the question:

Hello Monks, I have a problem and I would greatly appreciate your wisdom to solve it. So, I am reading from a fasta file (containing protein seqeunces) while looping over and trying to print protein sequences.

My problem is: When trying to print each protein sequence that I have in my hash, the sequences are broken down as follows:

Protein sequence:STARTXXXXX Protein Sequence: XXXXXXXXX Protein sequence: XXXXXXEND

Question: How could I avoid this?

Here is my script:

use warnings; my %database; my $protein_id = ""; my $line = ""; my $datbase_filename = ""; my $start = ">DDB"; my $end = ""; #input1: open the file containg the protein sequences. print "Please enter the path to the fasta file of protein sequences\n" +; #put the file name into $filenam $database_filename = <STDIN>; chomp($database_filename); #remove newline #open the file containing protein sequences in fasta format open(MYFILE1, "<$database_filename") or die "Unable to open $database_filename: $!\n"; while (<MYFILE1>) { chomp; #remove newline $line = $_; print "Line i: $_\n"; #test if (($line =~ m/^>DDB/) and ($line =~ m/to\s\d+$/)) { $protein_id = $line; print "protein ID: $protein_id\n"; #test } else { # associating the protein sequence in my %proteins to its ID $proteins{$protein_id} = $line; print "sequence: $line\n"; #test } } exit;
Many thanks in advance.

In reply to Re: printing fasta sequences from Hash by kroach
in thread printing fasta sequences from Hash by Bijgom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.