|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
How to extract duplicate lines from a text file?by rnaeye (Monk) |
| on Mar 01, 2011 at 05:27 UTC ( #890680=perlquestion: print w/ replies, xml ) | Need Help?? |
|
rnaeye has asked for the
wisdom of the Perl Monks concerning the following question:
Hi, I am a geneticist/biochemist and trying to use Perl to analyze DNA sequence data. I have a giant text file (99 million lines; ~ 7GB). The file contains DNA sequences. I need to extract duplicate lines based on the BeadIDs from input file and print it into different file. BeadIDs are written in field one (first column), for example followings are BeadIDs:
Real Input file looks like this (total ~99 million lines):
The output that I would like to have is shown below (BeadIDs must be repeated exactly TWICE, not unique, not triplicate, not quadruplicate, but I want the entire line not only column one):
I have written a code that would choose duplicate lines if my input file had only single column(field). However, as you can see my actual file has 7 fields, and I need to choose the duplicate lines based on first field, and print the entire line. Sor far, I could come up with following script that would work on a single column file. However, my Perl knowledge is not advance enough to come up for a solution when input file is in 7 field format. My code so far:
I was wondering if you guys could make me suggestions. Thanks for your help. ~Erbay
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||