http://qs321.pair.com?node_id=774362

sainath has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: perl script
by Transient (Hermit) on Jun 24, 2009 at 11:48 UTC
    What have you tried thus far?

    You'd probably want to take a look at using split to gather what you need.
Re: perl script
by citromatik (Curate) on Jun 24, 2009 at 12:04 UTC
    perl -lne '/gi\|(\d+)\|/ && push @sofar,$1}{$,=",";print @sofar' <yourfile>

    citromatik

      I used a similar idea but did as follows:

      my $file = '...the OPs File example..." #used as a string # to simplify my # test my @gi_ids = $file =~/gi\|(\d+)\|/g;

      That leaves the list @gi_ids containing all of the gi id's that were in the string (i.e., it finds 4 gi id's in the OPs example).

      Just another possible strategy. It looks to me like all of the respondents' ideas would work fine. Mine is just another variation.

      Hope that helps.

      ack Albuquerque, NM
Re: perl script
by leslie (Pilgrim) on Jun 24, 2009 at 12:58 UTC
    Hi firend,
    You can use this code..,
    use strict; use warnings; use Data::Dumper; my($File,$FILE_FH,$data,@total_data,$new,@gi); $File="./fasta.txt"; open $FILE_FH, '<', $File or die "Failed to Open File $File for $!"; $data=<$FILE_FH>; @total_data=split(/gi\|(\d+)\|/,$data); foreach $new(@total_data) { push @gi,$new if($new =~ /^\d+$/); } print Dumper @gi;