From db01e4e59d1d095a16e3e857d4d30561020d4f6e Mon Sep 17 00:00:00 2001 From: hassanamr Date: Mon, 19 Dec 2016 11:14:11 +0100 Subject: [PATCH 1/3] updated code to support fasta36, and added help function to show help --- targetfinder.pl | 40 ++++++++++++++++++++++++++++------------ targetfinder_threads.pl | 27 +++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/targetfinder.pl b/targetfinder.pl index 471e722..1c345de 100755 --- a/targetfinder.pl +++ b/targetfinder.pl @@ -1,8 +1,7 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use warnings; use File::Temp qw(tempfile); -use File::Which; use Getopt::Std; use constant DEBUG => 0; @@ -19,14 +18,7 @@ } # Smith-Waterman alignment programs (with threads) -my $fasta = "ssearch35_t"; - -# Does the executable $fasta exist? -my $exists = which($fasta); -if (!$exists) { - print STDERR "Aligner $fasta was not found in \$PATH.\n\n"; - exit 1; -} +my $fasta = "ssearch36"; if (DEBUG) { open (LOG, ">targetfinder.log") or die " Cannot open targetfinder.log: $!\n\n"; @@ -240,7 +232,7 @@ sub fasta { my $input = shift; my $db = shift; my @output; - open FASTA, "$fasta -n -H -Q -f -16 -r +15/-10 -g -10 -w 100 -W 25 -E 100000 -i -U -T $threads $input $db 1 2> /dev/null |"; + open FASTA, "$fasta -n -H -Q -f -16 -r +15/-10 -g -10 -w 100 -W 25 -E 100000 -i -U $input $db 1 2> /dev/null |"; while () { print LOG $_ if (DEBUG); push (@output, $_); @@ -686,7 +678,7 @@ sub print_json { ######################################## sub var_check { if ($opt{'h'}) { - var_error(); + show_help(); } if ($opt{'s'}) { $sRNA = $opt{'s'}; @@ -749,6 +741,30 @@ sub var_error { exit 1; } +######################################## +# Function: show_help +# Error message/instructions to print +######################################## +sub show_help { + print "\n\n"; + print "TargetFinder: Plant small RNA target prediction tool.\n\n"; + print "Usage: targetfinder.pl -s -d [options]\n\n"; + print "Options: -s Small RNA sequence (RNA or DNA, 5'->3')\n"; + print " -d Target sequence database file (FASTA-format)\n"; + print " -q Query sequence name (DEFAULT = 'query')\n"; + print " -c Prediction score cutoff value (DEFAULT = 4)\n"; + print " -t Threads for parallel Smith-Waterman searches (DEFAULT = 1)\n"; + print " -p Output format for small RNA-target pairs (DEFAULT = 'classic')\n"; + print " Available options: 'classic' (Original TargetFinder base-pairing format)\n"; + print " 'gff' (Generic Feature Format)\n"; + print " 'json' (JavaScript Object Notation)\n"; + print " 'table' (Tab-deliminated Format)\n"; + print " -r Search reverse strand for targets?. Use this option if the database is genomic DNA.\n"; + print " -h Print this menu\n"; + print "\n\n"; + exit 0; +} + ################################################################################ # End subroutines ################################################################################ diff --git a/targetfinder_threads.pl b/targetfinder_threads.pl index a310f27..0032740 100755 --- a/targetfinder_threads.pl +++ b/targetfinder_threads.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use warnings; use Getopt::Std; @@ -112,7 +112,7 @@ sub targetfinder { ######################################## sub var_check { if ($opt{'h'}) { - var_error(); + show_help(); } if ($opt{'f'}) { $file = $opt{'f'}; @@ -174,6 +174,29 @@ sub var_error { exit 1; } +######################################## +# Function: show_help +# Error message/instructions to print +######################################## +sub show_help { + print "\n\n"; + print "TargetFinder: Plant small RNA target prediction tool.\n\n"; + print "Usage: targetfinder.pl -s -d [options]\n\n"; + print "Options: -s Small RNA sequence (RNA or DNA, 5'->3')\n"; + print " -d Target sequence database file (FASTA-format)\n"; + print " -q Query sequence name (DEFAULT = 'query')\n"; + print " -c Prediction score cutoff value (DEFAULT = 4)\n"; + print " -t Threads for parallel Smith-Waterman searches (DEFAULT = 1)\n"; + print " -p Output format for small RNA-target pairs (DEFAULT = 'classic')\n"; + print " Available options: 'classic' (Original TargetFinder base-pairing format)\n"; + print " 'gff' (Generic Feature Format)\n"; + print " 'json' (JavaScript Object Notation)\n"; + print " 'table' (Tab-deliminated Format)\n"; + print " -r Search reverse strand for targets?. Use this option if the database is genomic DNA.\n"; + print " -h Print this menu\n"; + print "\n\n"; + exit 0; +} ################################################################################ # End subroutines ################################################################################ From 8ef4cad65d1b1350f4417861be8e533018abe46a Mon Sep 17 00:00:00 2001 From: hassanamr Date: Mon, 19 Dec 2016 11:20:47 +0100 Subject: [PATCH 2/3] keeping the code from the current wip version --- targetfinder.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/targetfinder.pl b/targetfinder.pl index 1c345de..220ab8d 100755 --- a/targetfinder.pl +++ b/targetfinder.pl @@ -2,6 +2,7 @@ use strict; use warnings; use File::Temp qw(tempfile); +use File::Which; use Getopt::Std; use constant DEBUG => 0; @@ -19,6 +20,13 @@ # Smith-Waterman alignment programs (with threads) my $fasta = "ssearch36"; + +# Does the executable $fasta exist? +my $exists = which($fasta); +if (!$exists) { + print STDERR "Aligner $fasta was not found in \$PATH.\n\n"; + exit 1; +} if (DEBUG) { open (LOG, ">targetfinder.log") or die " Cannot open targetfinder.log: $!\n\n"; From a5f303fc0e66c48a4711a48433edbdeddb60dccc Mon Sep 17 00:00:00 2001 From: hassanamr Date: Mon, 19 Dec 2016 11:21:50 +0100 Subject: [PATCH 3/3] fixing whitespace to be the same as the current version --- targetfinder.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/targetfinder.pl b/targetfinder.pl index 220ab8d..b7eceb7 100755 --- a/targetfinder.pl +++ b/targetfinder.pl @@ -2,7 +2,7 @@ use strict; use warnings; use File::Temp qw(tempfile); -use File::Which; +use File::Which; use Getopt::Std; use constant DEBUG => 0; @@ -20,12 +20,12 @@ # Smith-Waterman alignment programs (with threads) my $fasta = "ssearch36"; - -# Does the executable $fasta exist? -my $exists = which($fasta); -if (!$exists) { - print STDERR "Aligner $fasta was not found in \$PATH.\n\n"; - exit 1; + +# Does the executable $fasta exist? +my $exists = which($fasta); +if (!$exists) { + print STDERR "Aligner $fasta was not found in \$PATH.\n\n"; + exit 1; } if (DEBUG) {