From f11181f5b6f5def7f8b3b9329767a5d1427044b0 Mon Sep 17 00:00:00 2001 From: Torsten Seemann Date: Wed, 27 Sep 2017 16:38:26 +1000 Subject: [PATCH] snippy-core | allow --ref to be passed instead of auto-found --- bin/snippy-core | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/snippy-core b/bin/snippy-core index 8fc61b7..f681142 100755 --- a/bin/snippy-core +++ b/bin/snippy-core @@ -11,7 +11,7 @@ use Bio::SeqIO; my $REF = 'Reference'; -my(@Options, $quiet, $verbose, $inprefix, $noref, $prefix, $aformat, $tformat); +my(@Options, $quiet, $verbose, $inprefix, $noref, $prefix, $ref, $aformat, $tformat); setOptions(); my $anno; @@ -31,7 +31,16 @@ for my $dir (@ARGV) { add_snippy($id, $dir, $noref); # load the reference genome for first time through loop if (not keys %refseq) { - my $in = Bio::SeqIO->new(-file=>"$dir/reference/ref.fa", -format=>'fasta'); + my $ref_use = ''; + if (-r $ref) { + $ref_use = $ref; + msg("Using provided reference: $ref_use"); + } + else { + $ref_use = "$dir/reference/ref.fa"; + msg("Using reference discovered in Snippy folder: $ref_use"); + } + my $in = Bio::SeqIO->new(-file=>$ref_use, -format=>'fasta'); while (my $s = $in->next_seq) { $refseq{ $s->id } = $s->seq; $gapseq{ $s->id } = '-'x($s->length); @@ -268,6 +277,7 @@ sub setOptions { {OPT=>"verbose!", VAR=>\$verbose, DEFAULT=>0 , DESC=>"Verbose output"}, {OPT=>"inprefix=s", VAR=>\$inprefix, DEFAULT=>'snps' , DESC=>"Preferred input prefix of Snippy files"}, {OPT=>"prefix=s", VAR=>\$prefix, DEFAULT=>'core' , DESC=>"Output file prefix"}, + {OPT=>"ref=s", VAR=>\$ref, DEFAULT=>'' , DESC=>"Reference genome (try to find in Snippy folder otherwise)"}, {OPT=>"noref!", VAR=>\$noref, DEFAULT=>0 , DESC=>"Exclude reference"}, {OPT=>"aformat=s", VAR=>\$aformat, DEFAULT=>'fasta' , DESC=>"Output alignment format: nexus fasta phylip maf clustalw ..."}, );