Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Count the sequence length of each entry in the file

by wazat (Monk)
on Oct 02, 2020 at 23:44 UTC ( #11122497=note: print w/replies, xml ) Need Help??


in reply to Re^2: Count the sequence length of each entry in the file
in thread Count the sequence length of each entry in the file

When you strip off the header the line endings remain. Try deleting "\n" characters. If on windows also delete "\r" characters.
# Remove fasta header line if ( $para =~ s/^>(.*)//m ){ $name = $1; }; # Remove comment line(s) $para =~ s/^\s*#.*//mg; $para =~ tr/\r\n//d;

Replies are listed 'Best First'.
Re^4: Count the sequence length of each entry in the file
by haukex (Bishop) on Oct 03, 2020 at 07:44 UTC
    If on windows also delete "\r" characters.

    This is not necessary as the PerlIO :crlf layer is default on Windows and converts CRLF to LF on input. One can disable the translation with binmode or the :raw pseudolayer, but that's not the case in any of the code shown here. See also Newlines in perlport, and note that chomp also handles paragraph mode correctly.

      You're right about CRLF conversion. If I'm using perl on windows it is often via cygwin. In that case perl defaults to UNIX behaviour.

      The poster didn't provide much in the way of detail, but embedded CRLF might explain the difference of 4. It's hard to tell the details.

      I wasn't aware of chomp's behaviour. I seldom use paragraph mode. Thanks for that detail.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11122497]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2020-11-30 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?