Hi PerlMonks,

There are four samples (sample1...sample4) each with a different name. Sample 1 & 2 have the same sequence i.e. ATGC. Likewise, sample 3 & 4 have same sequence i.e. CCGG. My interest is to retain only the sample 1 with sequence ATGC and reject sample 2 as the latter shares the same sequence with sample 1. Same is the case for sample 3 & sample 4 i.e. I wish to retain sample 3 and reject sample 4. I am at my wit's end to fix this problem. I am looking forward to suggestions from perl monks regarding this problem.

I have written a script t2.pl (given below) to separate the header and the sequence. Here goes the script:

#!/usr/bin/perl use warnings; use strict; my $a=">sample1 ..sequence ATGC fun >sample2 ..sequence ATGC fun >sample3 ..sequence CCGG fun >sample4 ..sequence CCGG fun"; while ($a=~ />.*?fun/gs) {my $trial1=$&; my $trial2=$&; while ($trial1=~ />.*sequence/gs) {my $header=$&; $trial2=~ s/($header)//gs; my $seq=$trial2; $seq=~ s/\s//; $seq=~ s/fun//; print "\n Header: $header Sequence: $seq\n"; } } # code?? exit;

I have got the results like:

C:\Users\x\Desktop>t2.pl Header: >sample1 ..sequence Sequence: ATGC Header: >sample2 ..sequence Sequence: ATGC Header: >sample3 ..sequence Sequence: CCGG Header: >sample4 ..sequence Sequence: CCGG

But the expected results should look like:

>sample1 ..sequence ATGC >sample3 ..sequence CCGG

In reply to How does one get only the non-redundant (non-repeating) entries with header? by supriyoch_2008

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.