Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

perl script

by sainath (Initiate)
on Jun 24, 2009 at 11:45 UTC ( #774362=perlquestion: print w/replies, xml ) Need Help??

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://774362]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2022-06-25 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (83 votes). Check out past polls.

    Notices?