As posted, the code is a cut-and-paste of a command line session. It is intended to show source code and invocation switches, pragmata, etc., command line input (to @ARGV), and command line output. The source code is everything between the pair of  " (double-quotes). (Note that these are the only double-quotes in the posted code section.)

I don't know what you are doing to run the code, but try this:

  1. Download the posted code section using the  [download] link just after it.
  2. Edit out the first " and everything before it, and also the last " and everything after it. What remains should be the entire source code.
  3. Save the edited file.
  4. Invoke the edited file with the samealmost the same command line invocation used originally (Update: do not include the  -e switch as I originally wrote below!) and with the sample input you want, e.g.:
        perl -wMstrict -l  your_file.pl  GGGGaaaaaaCatttatatat  atatataaatttttATtcccc
  5. Examine output. Experiment with various different input data. Play with variations on the source code. Enjoy!

In fact, here's the edited section of code that should be all ready to go, just use the  [download] link and save to a file of your choice:

die 'Please enter exactly two sequences' unless @ARGV == 2; ;; my ($seq1, $seq2) = map uc, @ARGV; die 'Please enter only ATCG sequences' if grep /[^ATCG]/, $seq1, $seq2 +; ;; die 'Sequence lengths differ' if length $seq1 != length $seq2; ;; (my $comp = $seq2) =~ tr/ATCG/TAGC/; my $mask = $seq1 ^ reverse $comp; ;; if ($mask !~ m{ [^\000] }xms) { print 'The sequences are reverse-complementary'; exit; } ;; $mask =~ tr{\000-\377}{_^}; print 'Sequences are non-reverse-complementary at these locations:'; print qq{@ARGV}; print qq{$mask }, ''.reverse $mask;

Update: I just downloaded and saved the code block immediately above in this reply and went through the steps listed above (except it doesn't have to be edited), and it works. Be sure not to use the  -e switch when invoking a file; it is used for command-line source code statements. HTH.


In reply to Re^3: Reverse Complement by AnomalousMonk
in thread Reverse Complement by stamp1982

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.