Note that there are some explanatory texts on larger screens.

plurals
  1. PODealing with the lone carriage return as end of line symbol
    text
    copied!<p>So I have a program that gets rid of extra line breaks in fasta files copy and pasted from the web. If you don't know what a fasta file should look like, it should be a greater than symbol followed by anything (this is usually title info), then new line. The new line should contain your complete sequence (for biology DNA or amino acid) in one line, and repeat.</p> <p>Anyway, the problem is I need the program to be flexible enough to deal with anything:<code>\r</code>, <code>\n</code>, or <code>\r\n</code>. The <code>chomp</code> statement with underscores on either side is the command that removes the excess lines in the sequence portion. How can I make that chomp get rid of all three of the the options (<code>\r</code>, <code>\n</code>, <code>\r\n</code>)? Can I set <code>$\ = @linefeeds</code> and have <code>@linefeeds = "\r", "\n", "\r\n";</code>?</p> <p>I have read up online, I know that this topic as been covered before, but I just can't seem to get it to work.</p> <p>Here is my code to do so in a file:</p> <pre><code>print "Please enter file name, using the full pathway, to save your cleaned fasta file to:\n"; chomp( $new_file = &lt;STDIN&gt; ); open( New_File, "+&gt;$new_file" ) or die "Couldn't create file. Check permissions on location.\n"; #process the file line by line, chomping all lines that do not contain "greater than" and #removing all white space from lines that do not contain "greater than" my $firstline = 1; while ( my $lines = &lt;FASTA&gt; ) { foreach ($lines) { if ( !/&gt;/ ) { _chomp($lines);_ $lines =~ s/ //g; print New_File "$lines"; } else { if ( $firstline == 1 ) { print New_File "$lines"; $firstline = 0; } else { print New_File "\n$lines"; next; } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload