in reply to find reverse complement of every 2nd line

To someone who isn't an expert in Bioinformatics, can you please tell me how you would compute the reverse complement in the first place? Explain that, and show what code you have so far, and I or someone else here will help you find a solution.


Dave

  • Comment on Re: find reverse complement of every 2nd line

Replies are listed 'Best First'.
Re^2: find reverse complement of every 2nd line
by bingalee (Acolyte) on Jul 09, 2013 at 23:12 UTC

    Hey Dave. For the reverse complement the code will be something like this

    my $raw=<IN>; $rev= reverse $raw; $rev=~tr/ATGCatgc/TACGtacg/;

    my problem actually is doing this only to every other line and not the entire file

    this is what i came up with, but it doesnt work

    while(@inf=<IN>) { if(i%2==1) { $inf[i]=reverse $inf[i]; } }

    In this i was just trying to find the reverse to see if this code performs the action on the lines I want it to.. but no luck. Im still thinking of any other way. Any suggestions?

      variables in Perl need sigils, so it must be $i not just i

      (using strict and warnings should have prevented you)

      and you need to increment it with ++$i within the loop.

      As an alternative you could just test $. % 2 since $. automatically holds the line-number.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      my problem actually is doing this only to every other line and not the entire file

      The special variable $. (documented in perldoc perlvar) keeps count of the line numbers, so you can do something like:
      while(<IN>) { next if $. % 2; # skip odd lines # do the processing }
      Cheers,
      Rob