Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Simple regular expression that isn't simple

by l3v3l (Monk)
on Feb 28, 2006 at 17:05 UTC ( #533416=note: print w/replies, xml ) Need Help??


in reply to Simple regular expression that isn't simple

Your input seems to match your output ... is that what you were intending? or are you trying to do something like the following:
# Choose any Range of FASTA records # Called as perl script_name.pl --start start_line --end end_line file +_name # both --start and --end are optional; # no --start => start reading from end of file, end at --end # no --end => start reading from --start, read to end of file # neither => print every line use warnings; use strict; use Getopt::Long; my ($start, $end) = (undef, undef); GetOptions( "start=i" => \$start, "end=i" => \$end, ); $/='>'; while(<>) { if( (!defined($start) || $start <= $.) && (!defined($end) || $. <= $end) ) { print; } }
or, here are some liners to data munge fasta records that may be closer to what you are looking for:
# Choose first N FASTA records perl -ne 'BEGIN {$/=">";$o=0}{chomp;$o<N?(/^$/?next:print">$_"):last;$ +o++}' EXAMPLE.fa
# Choose the Nth FASTA record perl -0x3E -e 'chomp(@lines = <>);print $lines[N]' EXAMPLE.fa
# Choose any Range of FASTA records perl -0x3E -e 'chomp(@l=<>);for(STrange..ENDrange){print "record $_ is + >$l[$_]\n"}' EXAMPLE.fa perl -0x3E -e 'chomp(@l=<>);print @l[STrange..ENDrange]' EXAMPLE.fa
# show the number of FASTA records in a given FASTA file perl -0x3E -e '@l=grep/\s/,<>;print "$ARGV contains ".scalar(@l)." rec +ords\n"' EXAMPLE.fa

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2022-05-18 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (70 votes). Check out past polls.

    Notices?