Oh brothers, I seek your programming wisdom!! I am trying to obtain nucleotide sequences from a big (20Mb sequence) fasta file and write them to different files. I use the Bio::SeqIO module from BioPerl to specify the positions of the sequence that I want to get, and I couple the output to be written into a file. However, the big problem is that Bio::SeqIO takes some time to find the coordinates and then obtain the sequence. So what my script does is that while Bio::SeqIO is looking for the specified positions, my script while is already sending it to search for new positions, making Bio::SeqIO not retrieve any sequence (it's obviously looking for the initial positions!) and then the files are written empty. How can I do this, oh wise brothers???? There should be a way to make Bio::SeqIO retrieve the sequence and then write it, and then allow the flow to continue. I was thinking to make the Bio::SeqIO part a program that accepts input and then call system to run it, and possibly use fork(). But I don't know how fork() works!!! Here's my script:

#usr/local/bin/perl -w use strict; use Bio::SeqIO; #headers format #4 133005667 133005842 open(FILE,"/home/sakti/Desktop/trackseq_129S5_129S1/129S5ref_129S1qry_ +chr4_nonredundant") || die "cannot open file"; my $seqio = Bio::SeqIO->new(-file => "/home/sakti/Desktop/trackseq_129 +S5_129S1/135_155_129S5.fasta", -format => "fasta"); while(<FILE>){ chomp($_); my @temp_data = split (/\s+/,$_); #Make name for the N files like 4_3000027_3020133.fsa my $name="4_".$temp_data[1]."_".$temp_data[2].".fasta"; open (CORE,">$name"); while(my $seq = $seqio->next_seq) { print CORE $seq->subseq($temp_data[1],$temp_data[2]), "\n"; } close(CORE); } close(FILE);

I also thought about making the script sleep for some seconds while the SeqIO worked, but I would like the script to be doing better than that... I'll be eternally grateful for your help!!!


In reply to Make a perl script wait until one of the processes finishes by Sakti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.