comparison bin/piPipe.pl @ 21:2bd100775c36 draft

Uploaded
author romaingred
date Fri, 20 Oct 2017 08:34:50 -0400
parents 198009598544
children 7dd78ad2875f
comparison
equal deleted inserted replaced
20:509d95c26dab 21:2bd100775c36
18 18
19 my ( @fastq, @fastq_n, $dir, $min, $max, $mis, $misTE, $help, $Pcheck, $Dcheck, $mapnumf, $html_out); 19 my ( @fastq, @fastq_n, $dir, $min, $max, $mis, $misTE, $help, $Pcheck, $Dcheck, $mapnumf, $html_out);
20 my ( $ref, $tRNAs, $rRNAs, $snRNAs, $miRNAs, $exons, $TE ); 20 my ( $ref, $tRNAs, $rRNAs, $snRNAs, $miRNAs, $exons, $TE );
21 my ( $si_min, $si_max, $pi_min, $pi_max ); 21 my ( $si_min, $si_max, $pi_min, $pi_max );
22 my ( $build_index, $build_tRNAs, $build_rRNAs, $build_snRNAs, $build_miRNAs, $build_exons, $build_TE ); 22 my ( $build_index, $build_tRNAs, $build_rRNAs, $build_snRNAs, $build_miRNAs, $build_exons, $build_TE );
23 my $max_procs = 4; 23 my $max_procs = 8;
24 24
25 ( $build_index, $build_tRNAs, $build_rRNAs, $build_snRNAs, $build_miRNAs, $build_exons, $build_TE ) = (0,0,0,0,0,0,0); 25 ( $build_index, $build_tRNAs, $build_rRNAs, $build_snRNAs, $build_miRNAs, $build_exons, $build_TE ) = (0,0,0,0,0,0,0);
26 ( $min, $max, $mis, $misTE, $si_min, $si_max, $pi_min, $pi_max, $dir ) = ( 18, 29, 0, 3, 21, 21, 23, 29 ); 26 ( $min, $max, $mis, $misTE, $si_min, $si_max, $pi_min, $pi_max, $dir ) = ( 18, 29, 0, 3, 21, 21, 23, 29 );
27 $Pcheck ='true'; 27 $Pcheck ='true';
28 28
71 my %toBuild; 71 my %toBuild;
72 @toBuild{ ( $ref, $tRNAs, $rRNAs, $snRNAs, $miRNAs, $exons, $TE ) } = ( $build_index, $build_tRNAs, $build_rRNAs, $build_snRNAs, $build_miRNAs, $build_exons, $build_TE ) ; 72 @toBuild{ ( $ref, $tRNAs, $rRNAs, $snRNAs, $miRNAs, $exons, $TE ) } = ( $build_index, $build_tRNAs, $build_rRNAs, $build_snRNAs, $build_miRNAs, $build_exons, $build_TE ) ;
73 to_build ( \%toBuild, $report ); 73 to_build ( \%toBuild, $report );
74 74
75 my $proc_child = ceil($max_procs / scalar(@fastq)); 75 my $proc_child = ceil($max_procs / scalar(@fastq));
76 my $proc_grand_child = ceil($proc_child/5); 76 my $proc_grand_child = ceil($proc_child/4);
77 my $pm = Parallel::ForkManager->new($max_procs); 77 my $pm = Parallel::ForkManager->new($max_procs);
78 my $pm3 = Parallel::ForkManager->new($proc_grand_child); 78 my $pm2 = Parallel::ForkManager->new($proc_grand_child);
79 79
80 $pm->run_on_finish( sub { 80 $pm->run_on_finish( sub {
81 my ($pid, $exit_code, $ident) = @_; 81 my ($pid, $exit_code, $ident) = @_;
82 print $report "Fastq fork $ident just finished ". 82 print $report "Fastq fork $ident just finished ".
83 "with PID $pid and exit code: $exit_code\n"; 83 "with PID $pid and exit code: $exit_code\n";
85 }); 85 });
86 $pm->run_on_start( sub { 86 $pm->run_on_start( sub {
87 my ($pid,$ident)=@_; 87 my ($pid,$ident)=@_;
88 print $report "Fastq fork : $ident started, pid: $pid\n"; 88 print $report "Fastq fork : $ident started, pid: $pid\n";
89 }); 89 });
90 $pm3->run_on_finish( sub { 90 $pm2->run_on_finish( sub {
91 my ($pid, $exit_code, $ident) = @_; 91 my ($pid, $exit_code, $ident) = @_;
92 print $report "** Subgroup fork $ident just finished ". 92 print $report "** Subgroup fork $ident just finished ".
93 "with PID $pid and exit code: $exit_code\n"; 93 "with PID $pid and exit code: $exit_code\n";
94 die "Something went wrong!\n" if $exit_code != 0; 94 die "Something went wrong!\n" if $exit_code != 0;
95 }); 95 });
96 $pm3->run_on_start( sub { 96 $pm2->run_on_start( sub {
97 my ($pid,$ident)=@_; 97 my ($pid,$ident)=@_;
98 print $report "** Subgroup fork $ident started, pid: $pid\n"; 98 print $report "** Subgroup fork $ident started, pid: $pid\n";
99 }); 99 });
100 100
101 101
180 foreach my $grand_child ( 0 .. $#types ) 180 foreach my $grand_child ( 0 .. $#types )
181 { 181 {
182 my $type_dir = $group_dir.$types_names[$grand_child].'/'; 182 my $type_dir = $group_dir.$types_names[$grand_child].'/';
183 my $type_prefix = $types_names[$grand_child].'-'; 183 my $type_prefix = $types_names[$grand_child].'-';
184 mkdir $type_dir; 184 mkdir $type_dir;
185 185 $pm2->start($types[$grand_child]) and next;
186 my ( $type_sam_genome, $type_sam_TEs, $type_sam_exons ) = ( $type_dir.$type_prefix.'genome.sam', $type_dir.$type_prefix.'TEs.sam', $type_dir.$type_prefix.'exons.sam' ); 186 my ( $type_sam_genome, $type_sam_TEs, $type_sam_exons ) = ( $type_dir.$type_prefix.'genome.sam', $type_dir.$type_prefix.'TEs.sam', $type_dir.$type_prefix.'exons.sam' );
187 my ( $type_sam_uni_genome, $type_sam_uni_TEs, $type_sam_uni_exons ) = ( $type_dir.$type_prefix.'genome_unique.sam', $type_dir.$type_prefix.'TEs_unique.sam', $type_dir.$type_prefix.'exons_unique.sam' ); 187 my ( $type_sam_uni_genome, $type_sam_uni_TEs, $type_sam_uni_exons ) = ( $type_dir.$type_prefix.'genome_unique.sam', $type_dir.$type_prefix.'TEs_unique.sam', $type_dir.$type_prefix.'exons_unique.sam' );
188 my ( $type_uni_genome_fastq, $type_uni_TEs_fastq, $type_uni_exons_fastq ) = ( $fq_collection.$type_prefix.'genome_uni.fastq', $fq_collection.$type_prefix.'TEs_uni.fastq', $fq_collection.$type_prefix.'exons_uni.fastq'); 188 my ( $type_uni_genome_fastq, $type_uni_TEs_fastq, $type_uni_exons_fastq ) = ( $fq_collection.$type_prefix.'genome_uni.fastq', $fq_collection.$type_prefix.'TEs_uni.fastq', $fq_collection.$type_prefix.'exons_uni.fastq');
189 my ( $type_genome_fastq, $type_TEs_fastq, $type_exons_fastq ) = ( $fq_collection.$type_prefix.'genome.fastq', $fq_collection.$type_prefix.'TEs.fastq', $fq_collection.$type_prefix.'exons.fastq'); 189 my ( $type_genome_fastq, $type_TEs_fastq, $type_exons_fastq ) = ( $fq_collection.$type_prefix.'genome.fastq', $fq_collection.$type_prefix.'TEs.fastq', $fq_collection.$type_prefix.'exons.fastq');
190 my $type_sequence_hashP = get_fastq_seq ( $types[$grand_child] ); 190 my $type_sequence_hashP = get_fastq_seq ( $types[$grand_child] );
238 238
239 #HTML Details 239 #HTML Details
240 my $prefix_details_pages = $dir.$fastq_n[$child].'-'.$types_names[$grand_child]; 240 my $prefix_details_pages = $dir.$fastq_n[$child].'-'.$types_names[$grand_child];
241 details_pages ( $type_dir, $prefix_details_pages, \@fastq_n, $fastq_n[$child], $misTE, $dir ); 241 details_pages ( $type_dir, $prefix_details_pages, \@fastq_n, $fastq_n[$child], $misTE, $dir );
242 242
243 $pm3->finish($grand_child); 243 $pm2->finish();
244 } 244 }
245 $pm3->wait_all_children; 245 $pm2->wait_all_children;
246 246
247 if ( $Pcheck eq 'true' ) 247 if ( $Pcheck eq 'true' )
248 { 248 {
249 my $ppp = $group_dir.'PPPartners/'; mkdir $ppp; 249 my $ppp = $group_dir.'PPPartners/'; mkdir $ppp;
250 print $report "ping_pong_partners $group_dir/bonafide_reads/TEs.sam $ppp\n"; 250 print $report "ping_pong_partners $group_dir/bonafide_reads/TEs.sam $ppp\n";
259 copy ($index_page, $html_out) if $child == 0; 259 copy ($index_page, $html_out) if $child == 0;
260 #HTML Menu 260 #HTML Menu
261 my $menu_page = $dir.$fastq_n[$child].'-sub.html'; 261 my $menu_page = $dir.$fastq_n[$child].'-sub.html';
262 menu_page ( $group_dir, $menu_page, \@fastq_n, $fastq_n[$child], $min, $max, $si_min, $si_max, $pi_min, $pi_max, $dir ); 262 menu_page ( $group_dir, $menu_page, \@fastq_n, $fastq_n[$child], $min, $max, $si_min, $si_max, $pi_min, $pi_max, $dir );
263 263
264 $pm->finish($child); # pass an exit code to finish 264 $pm->finish(); # pass an exit code to finish
265 } 265 }
266 $pm->wait_all_children; 266 $pm->wait_all_children;
267 267
268 print $report "Job done!\n"; 268 print $report "Job done!\n";
269 close $report; 269 close $report;