Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am just comparing the sequences part of each but wish to extract the sequence and the annotation of those that are unique. I have written a script which extracts unique sequences but am failing to extract the annotation. Please can anyone help.>atc:AGR_pTi_39_1-45_FD cctttcaagtcatagaacaccggggcatgtacaacttggggaagg >atc:AGR_pTi_47_1-45_FD ccttacaggtcattgagcacagaggaatgttcaatttagggaaac >atc:AGR_pTi_39_1-45_F cctttcaagtcatagaacaccggggcatgtacaacttgggga +agg >atc:AGR_pTi_47_1-45_F ccttacaggtcattgagcacagaggaatgttcaatttaggga +aac >atc:AGR_pTi_39_1-45_RD cctttcaagtcatagaacaccggggcatgtacaacttggggaagg >atc:AGR_pTi_47_1-45_RD ccttacaggtcattgagcacagaggaatgttcaatttagggaaac >atc:AGR_pTi_39_1-45_R cctttcaagtcatagaacaccggggcatgtacaacttggggaagg
# my code so far #!/usr/bin/perl -w + open (FILEHANDLE, $ARGV[0]) or die "unable to open file"; open (OUTFILE, ">$ARGV[1]") or die; + + my $line; my @array; + my @seqs; + while (<FILEHANDLE>) { $line = $_; chomp ($line); + + if ($line =~ /(\S+)(\s+)(\w+)/) { + + push @seqs, "$3 "; + + } + + + } + foreach my $item (@seqs) { unless ($seen{$item}) { $seen{$item} = 1; push (@uniq, $item); push @uniq, "\n"; } + + + else { + push (@duplicates, $item); push @duplicates, "\n"; + + } } + print @uniq; + print OUTFILE "@duplicates\n"; + + close FILEHANDLE; close OUTFILE; exit;
BazB added readmore tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: extracting duplicates from a list
by kvale (Monsignor) on Feb 20, 2004 at 16:55 UTC | |
|
Re: extracting duplicates from a list
by falsa_utopia (Initiate) on Feb 20, 2004 at 21:26 UTC | |
|
Re: extracting duplicates from a list
by pelagic (Priest) on Feb 20, 2004 at 16:42 UTC |