Hello! I'm trying to format a code in which I'm trying to create a reverse decoy sequence. So far this is what I've come up with:

#! usr/bin/perl -w use strict; open (INPUT, "proteins.txt") or die "Couldn't open proteins.txt for re +ading: $! \n"; open (OUTPUT, ">reverse_decoy.txt") or die "Couldn't open reverse_deco +y.txt for writing: $! \n"; my @protein = <INPUT>; print OUTPUT "@protein \n"; foreach my $protein (@protein) { if ($protein =~ s/^>(.*\n)/> REVERSE DECOY $1/g) { my $header = $protein; print OUTPUT "$header"; } else { my $sequence = $protein; $sequence =~ s/\n//; my @reversed_sequence = split(/\s+/, reverse($sequence)); print OUTPUT "@reversed_sequence\n"; }} close INPUT; close OUTPUT;

My main difficulty is that even if it reverses the sequence, it only reverses each line, instead of reversing the entire file. For example: >Sequence 1 ABCDEFG HIJKLMN OUTPUT: >Reverse Decoy Sequence 1 GFEDCBA NMLKJIH Goal: >Reverse Decoy Sequence 1 NMLKJIH GFEDCBA If there's any way to switch my order of lines, I think that would help a lot! This way the lines will already be reversed, and then the order of them will be too.


In reply to Switching the Order of Lines by BeckyLynn

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.