garyboyd has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Combining 3 files
by Sewi (Friar) on Jun 23, 2011 at 08:47 UTC | |
by garyboyd (Acolyte) on Jun 23, 2011 at 14:52 UTC | |
by garyboyd (Acolyte) on Jun 24, 2011 at 08:22 UTC | |
by Anonymous Monk on Jun 24, 2011 at 10:06 UTC | |
by garyboyd (Acolyte) on Jun 27, 2011 at 09:11 UTC | |
by Anonymous Monk on Jun 27, 2011 at 10:27 UTC | |
| |
|
Re: Combining 3 files
by Anonymous Monk on Jun 23, 2011 at 09:12 UTC |