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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |