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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |