Hi guys,
I am a complete perl novice so forgive me in advance. I have been searching the web and haven't been able to find a solution.
I have a really big text file called "HGDP.txt" that looks like this:
1 51 Brahui A C A A T
1 51 Brahui A C A G T
3 51 Brahui A C A G C
3 51 Brahui A C G A T
5 51 Brahui A C G A T
5 51 Brahui A C G G C
7 51 Brahui A C G A T
7 51 Brahui A C G G T
9 51 Brahui A C G G T
9 51 Brahui A C G G T
Except that the total number of columns are 2,841. I want to use perl to generate another output file whereby if the first column is of equal value (i.e. duplicates of 1, 3, 5...etc.) then I want to merge the two lines together with a "/" character as a delimiter. For example:
1 51 Brahui A/A C/C A/A A/G T/T
3 51 Brahui A/A C/C A/G G/A C/T
Is there a way to do that?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.