Click here to get back home

Help: Content extraction

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Help: Content extraction Amy Lee 05-09-2008
Posted by John W. Krahn on May 10, 2008, 8:21 am
Please log in for more thread options
Amy Lee wrote:
>
> I have a problem while I'm processing my sequence file. The file content
> is like this.
>
>> seq1
> ACGGTC
> ACTG
>> seq2
> CGATCC
> ACCTC
>> seq3
> ......
>
> And I hope make every sequence into a single file. For example, a file
> "seq1" content is
>> seq1
> ACGGTC
> ACTG
> And a file "seq2" content is
>> seq2
> CGATCC
> ACCTC
> and so on.

while ( <> ) {
if ( /^>(.+)/ ) {
open my $OUT, '>>', $1 or die "Cannot open '$1' $!";
select $OUT;
}
print;
}



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Posted by Amy Lee on May 10, 2008, 11:01 am
Please log in for more thread options
On Sat, 10 May 2008 12:21:05 +0000, John W. Krahn wrote:

> Amy Lee wrote:
>>
>> I have a problem while I'm processing my sequence file. The file content
>> is like this.
>>
>>> seq1
>> ACGGTC
>> ACTG
>>> seq2
>> CGATCC
>> ACCTC
>>> seq3
>> ......
>>
>> And I hope make every sequence into a single file. For example, a file
>> "seq1" content is
>>> seq1
>> ACGGTC
>> ACTG
>> And a file "seq2" content is
>>> seq2
>> CGATCC
>> ACCTC
>> and so on.
>
> while ( <> ) {
> if ( /^>(.+)/ ) {
> open my $OUT, '>>', $1 or die "Cannot open '$1' $!";
> select $OUT;
> }
> print;
> }
>
>
>
> John
Thank you very much~
I've solved this problem.

Regards,

Amy Lee

Posted by Amy Lee on May 10, 2008, 11:03 am
Please log in for more thread options
On Sat, 10 May 2008 23:01:21 +0800, Amy Lee wrote:

> On Sat, 10 May 2008 12:21:05 +0000, John W. Krahn wrote:
>
>> Amy Lee wrote:
>>>
>>> I have a problem while I'm processing my sequence file. The file content
>>> is like this.
>>>
>>>> seq1
>>> ACGGTC
>>> ACTG
>>>> seq2
>>> CGATCC
>>> ACCTC
>>>> seq3
>>> ......
>>>
>>> And I hope make every sequence into a single file. For example, a file
>>> "seq1" content is
>>>> seq1
>>> ACGGTC
>>> ACTG
>>> And a file "seq2" content is
>>>> seq2
>>> CGATCC
>>> ACCTC
>>> and so on.
>>
>> while ( <> ) {
>> if ( /^>(.+)/ ) {
>> open my $OUT, '>>', $1 or die "Cannot open '$1' $!";
>> select $OUT;
>> }
>> print;
>> }
>>
>>
>>
>> John
> Thank you very much~
> I've solved this problem.
>
> Regards,
>
> Amy Lee

Anyway, could you tell me how to find out the usage of "select" function?

Thank you.

Posted by Jürgen Exner on May 10, 2008, 12:03 pm
Please log in for more thread options
>Anyway, could you tell me how to find out the usage of "select" function?

The usage of each perl function is described in the first line(s) of the
manual page for this function. It doesn't explicitely say "Usage" as in
Unix man pages, but it has the same format:
        select FILEHANDLE

Sometimes, if a function is overloaded, there may be additional usages
farther down the page, too, e.g.
        select RBITS,WBITS,EBITS,TIMEOUT

jue

Similar ThreadsPosted
hiw do i perform this extraction August 21, 2006, 4:12 am
FTP Link Extraction January 20, 2007, 10:06 am
Statistics Extraction January 23, 2007, 3:25 pm
Pattern extraction March 10, 2008, 4:14 am
Pattern extraction March 10, 2008, 4:42 am
Whats the way of wildcard HoH extraction? January 17, 2005, 3:36 pm
Extraction of bits using unpack August 17, 2005, 10:08 am
extraction of hostnames in hostfile January 2, 2006, 1:11 am
Column extraction in perl September 15, 2006, 12:31 pm
Extraction Fields from a file January 12, 2007, 4:16 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap