in reply to Re^3: An overlapping regex capture
in thread An overlapping regex capture

But the thing is, I want to be able to capture the full fasta sequence title (>hsa_circ_0000001|chr1:1080738-1080845-|None|None) along with the sequence and print that into a file and I want to capture a part of the sequence title and use it to name the file (hsa_circ_0000001) excluding '>'.

If I use your method surely I will not be able to print the full fasta sequence title followed by a newline and then the sequence in my newly created file, because $id will become (hsa_circ_0000001), whereas I need to be able to capture both (hsa_circ_0000001) and (>hsa_circ_0000001|chr1:1080738-1080845-|None|None) and apply them seamlessly as the new files are created in my loop.

Pete.

Replies are listed 'Best First'.
Re^5: An overlapping regex capture
by Discipulus (Canon) on Jun 21, 2017 at 21:21 UTC
    If so create a new variable for the filename, just before creating the file, as in
    foreach $id (keys %id2seq){ # here the last good possibility to cut $id: my $filename = (split /\|/, $id)[0]; ...

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.