Hi perl monks, I would like to combine the information from 3 tab-delimited files. Some of the entries are duplicated, so I would like to select one of these from each file based on specific criteria

eg:

File1:

>3841 29 58.786702607127 GAGTAGTTCATAATAAAGAGGAGGCTGGT >3841 28 58.3143841442903 AGTAGTTCATAATAAAGAGGAGGCTGGT >486 26 59.8238809443041 CATTTTTCCTGAGCGTTTTCCTGAGC >486 25 59.1450485783588 ATTTTTCCTGAGCGTTTTCCTGAGC >486 24 58.9556227674582 TTTTTCCTGAGCGTTTTCCTGAGC >486 23 58.6081353592492 TTTTCCTGAGCGTTTTCCTGAGC >486 22 58.2296488444454 TTTCCTGAGCGTTTTCCTGAGC >136 25 Tm=59.8064145079347 CGAACAGAGGTCTCATGGAGAAACG

File2:

>3841 29 58.5812405420724 GAGTAGTTCATAATAAAGAGGAGGCTGGA >3841 28 58.0989000498791 AGTAGTTCATAATAAAGAGGAGGCTGGA >486 26 58.9706961902307 CATTTTTCCTGAGCGTTTTCCTGAGT >486 25 58.2353328662615 ATTTTTCCTGAGCGTTTTCCTGAGT >486 24 58.0079403206259 TTTTTCCTGAGCGTTTTCCTGAGT >136 25 59.2231929175504 CGAACAGAGGTCTCATGGAGAAACA >253 36 59.6147860412319 CAGAGATGATTTGTGCATTATAATTGTAATTTGGGT

File3:

>3841 26 58.289789463114 CCAGGTTATTTATTTCAGCGGGAACT >486 23 58.6732344878087 GCAAATGGCTCTAAGGATCAGCC >294 21 58.8403250231655 GTCGGAGCTCTCTCAGAACCC >253 25 58.3051993710611 CACTCGAGTTGCAGTTATGTTCCTC >287 21 59.5292339759331 TCCTTAGCCAGACGAACACGC >544 21 59.5408471700017 TACAGCAGGTCAACCCGTTCG >856 19 58.7421506440351 GGTGAGGATGTCGCCCTCA

So the script would search through File 3 line by line and compare column1 (the >number with the entries in column1 of files 1 and 2). If there are duplicate >number entries, a single >contig entry from files 1 and 2 would be selected based on the relative value to the number in column 3.

For example the first entry of File 3 is >3841 with a value of 58.289789463114

File 1 has two entries for >3841 and the second has a value in column 3, closest to the File 3 entry (58.3143841442903) so this would be selected.

File 2 also has two entries for >3841 and in this case the second entry would be selected as the value in column 3 (58.0989000498791) is closest to the column 3 value in File3.

The script would then print out a tab de-limited file with the following format:

>3841 AGTAGTTCATAATAAAGAGGAGGCTGGT AGTAGTTCATAATAAAGAGGAGGCTGGA +CCAGGTTATTTATTTCAGCGGGAACT >486 TTTTCCTGAGCGTTTTCCTGAGC CATTTTTCCTGAGCGTTTTCCTGAGT GCAAATGG +CTCTAAGGATCAGCC

Any help from the monks on this would be appreciated.


In reply to Combining 3 files by garyboyd

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.