Skip to content

Commit

Permalink
debugging in perl
Browse files Browse the repository at this point in the history
  • Loading branch information
lee212 committed Feb 7, 2016
1 parent a1b4fbe commit 71829d7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
24 changes: 24 additions & 0 deletions mgescan/nonltr/lib/Prompt.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package Prompt;
use strict;
use warnings;

use Exporter qw(import);

our @EXPORT_OK = qw(prompt_yn);

# http://stackoverflow.com/a/18104317
sub prompt {
my ($query) = @_; # take a prompt string as argument
local $| = 1; # activate autoflush to immediately show the prompt
print $query;
chomp(my $answer = <STDIN>);
return $answer;
}

sub prompt_yn {
my ($query) = @_;
my $answer = prompt("$query (Y/n): ");
return lc($answer) ne 'n';
}

1;
31 changes: 25 additions & 6 deletions mgescan/nonltr/run_MGEScan.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
use Cwd 'abs_path';
use File::Basename;
use Sys::Hostname;
use lib (dirname abs_path $0) . '/lib';
use Prompt qw(prompt_yn);

my $program_dir = dirname(abs_path($0))."/";


############################################
# INPUT
############################################
Expand Down Expand Up @@ -99,7 +102,10 @@
my $plus_dna_file = $plus_dna_dir.$name;
my $command = $program_dir."run_hmm.pl --dna=".$plus_dna_file." --out=".$plus_out_dir." --hmmerv=".$hmmerv;
printf $command."\n" if ($debug);
#system($command);
if ($debug and not prompt_yn("continue?")) {
exit;
}
system($command);
}
}
}
Expand All @@ -112,7 +118,10 @@

my $command = $program_dir."post_process.pl --dna=".$plus_dna_dir." --out=".$plus_out_dir." --rev=0";
printf $command."\n" if ($debug);
#system($command);
if ($debug and not prompt_yn("continue?")) {
exit;
}
system($command);


############################################
Expand All @@ -136,8 +145,12 @@
if ($name !~ /^\./){
my $minus_dna_file = $minus_dna_dir.$name;
my $command = $program_dir."run_hmm.pl --dna=".$minus_dna_file." --out=".$minus_out_dir." --hmmerv=".$hmmerv;
#system($command);
printf $command."\n" if ($debug);
if ($debug and not prompt_yn("continue?")) {
exit;
}
system($command);

}
}
}
Expand All @@ -147,16 +160,22 @@
system("rm -f ".$minus_out_dir."out1/qqqqq.*");

my $command = $program_dir."post_process.pl --dna=".$minus_dna_dir." --out=".$minus_out_dir." --rev=1";
printf $command."\n";
#system($command);
printf $command."\n" if ($debug);
if ($debug and not prompt_yn("continue?")) {
exit;
}
system($command);

###########################################
#validation for Q value
###########################################

my $command = $program_dir."post_process2.pl --data_dir=".$main_data_dir." --hmmerv=".$hmmerv;
#system($command);
printf $command."\n" if ($debug);
if ($debug and not prompt_yn("continue?")) {
exit;
}
system($command);

system("rm -rf ".$minus_dna_dir);

Expand Down
11 changes: 3 additions & 8 deletions mgescan/nonltr/run_hmm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Cwd 'abs_path';
use File::Basename;
use File::Temp qw/ tempfile unlink0 /;
user prompt;

my $pdir = dirname(abs_path($0))."/";
my $phmm_dir = $pdir."pHMM/";
Expand Down Expand Up @@ -68,16 +69,9 @@
close(OUT);
}

$command = $pdir."match_pos.pl -rt=".$domain_rt_pos_file." -ape=".$domain_ape_pos_file;
#system($command);
###########################################################
# run hmm
###########################################################
#print "Running HMM...\n";

$out_file = $out1_dir.$dna_name;
$command = $pdir."hmm/MGEScan -m ".$pdir."hmm/chr.hmm -s ".$dna_file." -r ".$domain_rt_pos_file." -a ".$domain_ape_pos_file." -o ".$out_file." -p ".$pdir." -d ".$out1_dir." -v ".$hmmerv;
#print $command."\n";
print $command."\n" if ($debug);
system($command);
}

Expand Down Expand Up @@ -249,3 +243,4 @@ sub get_sequence{ # file name, variable for seq, variable for head
close(GENOME);
}


0 comments on commit 71829d7

Please sign in to comment.