| 1 | package Bio::AutomatedAnnotation::Prokka; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Prokka class for bacterial annotation | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # Copyright (C) 2012 Torsten Seemann | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use Time::Seconds; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use XML::Simple; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use List::Util qw(min max sum); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use Scalar::Util qw(openhandle); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use Bio::SeqIO; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use Bio::SearchIO; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use Bio::Seq; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use Bio::SeqFeature::Generic; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | use FindBin; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | use POSIX; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | use Bio::AutomatedAnnotation::External::Cmscan; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | has 'assembly_file' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | has 'quiet' => ( is => 'rw', isa => 'Bool', default => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | has 'outdir' => ( is => 'ro', isa => 'Str', default => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | has 'dbdir' => ( is => 'ro', isa => 'Str', default => '/tmp/prokka' ); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | has 'force' => ( is => 'ro', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | has 'prefix' => ( is => 'ro', isa => 'Str', default => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | has 'addgenes' => ( is => 'ro', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | has 'locustag' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_locustag' ); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | has 'increment' => ( is => 'ro', isa => 'Int', default => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | has 'gffver' => ( is => 'ro', isa => 'Int', default => 3 ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | has 'centre' => ( is => 'ro', isa => 'Str', default => 'VBC' ); | |||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | has 'genus' => ( is => 'rw', isa => 'Str', default => 'Genus' ); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | has 'species' => ( is => 'ro', isa => 'Str', default => 'species' ); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | has 'strain' => ( is => 'ro', isa => 'Str', default => 'strain' ); | |||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | has 'contig_uniq_id' => ( is => 'ro', isa => 'Str', default => 'gnl' ); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | has 'kingdom' => ( is => 'rw', isa => 'Str', default => 'Bacteria' ); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | has 'gcode' => ( is => 'ro', isa => 'Int', default => 11 ); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | has 'gram' => ( is => 'ro', isa => 'Str', default => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | has 'usegenus' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | has 'proteins' => ( is => 'ro', isa => 'Str', default => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | has 'fast' => ( is => 'ro', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | has 'cpus' => ( is => 'ro', isa => 'Int', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | has 'mincontig' => ( is => 'ro', isa => 'Int', default => 200 ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | has 'evalue' => ( is => 'ro', isa => 'Num', default => 1E-6 ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | has 'rfam' => ( is => 'ro', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | has 'files_per_chunk' => ( is => 'ro', isa => 'Int', default => 100 ); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | has 'tempdir' => ( is => 'ro', isa => 'Str', default => '/tmp' ); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | has 'cleanup_prod' => ( is => 'ro', isa => 'Bool', default => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | has 'keep_original_order_and_names' => ( is => 'ro', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | has 'exe' => ( is => 'ro', isa => 'Str', default => 'PROKKA' ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | has 'version' => ( is => 'ro', isa => 'Str', default => '1.5' ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | has 'author' => ( is => 'ro', isa => 'Str', default => 'Torsten Seemann <torsten.seemann@monash.edu>' ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | has 'url' => ( is => 'ro', isa => 'Str', default => 'http://www.vicbioinformatics.com' ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | has 'hypo' => ( is => 'ro', isa => 'Str', default => 'hypothetical protein' ); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | has 'unann' => ( is => 'ro', isa => 'Str', default => 'unannotated protein' ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | has 'blastcmd' => ( | |||||||||||||||||||||||||||||||||||||||||
| 76 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 78 | default => | ||||||||||||||||||||||||||||||||||||||||||
| 79 | "blastp -query %i -db %d -evalue %e -num_threads 1 -out %o -num_descriptions 1 -num_alignments 1 2>/dev/null" | ||||||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | has 'hmmer3cmd' => | |||||||||||||||||||||||||||||||||||||||||
| 82 | ( is => 'ro', isa => 'Str', default => "hmmscan --noali --notextw --acc -E %e --cpu 1 -o %o %d %i 2>/dev/null" ); | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | has 'infernalcmd' => | |||||||||||||||||||||||||||||||||||||||||
| 84 | ( is => 'ro', isa => 'Str', default => "cmscan --noali --notextw --acc -E %e --cpu 1 -o %o %d %i 2>/dev/null" ); | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | has 'starttime' => ( | |||||||||||||||||||||||||||||||||||||||||
| 86 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 87 | isa => 'Time::Piece', | ||||||||||||||||||||||||||||||||||||||||||
| 88 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | builder => '_build_starttime' | ||||||||||||||||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | sub _build_starttime { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_starttime: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return localtime; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | sub _build_locustag { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_locustag: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return $self->exe; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | sub annotate { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
annotate: not called CC=156 SCAR=101.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $AUTHOR = $self->author; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $BLASTPCMD = $self->blastcmd; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $EXE = $self->exe; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $HMMER3CMD = $self->hmmer3cmd; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $HYPO = $self->hypo; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $INFERNALCMD = $self->infernalcmd; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $UNANN = $self->unann; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $URL = $self->url; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $VERSION = $self->version; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $addgenes = $self->addgenes; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $centre = $self->centre; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $contig_uniq_id = $self->contig_uniq_id; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $cpus = $self->cpus; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $dbdir = $self->dbdir; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $evalue = $self->evalue; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $fast = $self->fast; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $files_per_chunk = $self->files_per_chunk; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $force = $self->force; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $gcode = $self->gcode; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $genus = $self->genus; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $gffver = $self->gffver; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $gram = $self->gram; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $increment = $self->increment; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $kingdom = $self->kingdom; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $locustag = $self->locustag; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $mincontig = $self->mincontig; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $outdir = $self->outdir; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $prefix = $self->prefix; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $proteins = $self->proteins; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $quiet = $self->quiet; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $rfam = $self->rfam; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $species = $self->species; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $starttime = $self->starttime; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $strain = $self->strain; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $tempdir = $self->tempdir; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $usegenus = $self->usegenus; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my %seq; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 144 | # welcome message | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $self->msg("This is $EXE $VERSION"); | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $self->msg("$AUTHOR"); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $self->msg("Victorian Bioinformatics Consortium - $URL"); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $self->msg("Local time is $starttime"); | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # set up options based on --mode | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ( $kingdom =~ m/bac|prok/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $kingdom = 'Bacteria'; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | $gcode ||= 11; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$gcode ||= 11
MC/DC0%0/1
$gcode ||= 11
$gcode
Truth table0%0/2
A
A= $gcode
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | elsif ( $kingdom =~ m/arch/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $kingdom = 'Archaea'; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $gcode ||= 11; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$gcode ||= 11
MC/DC0%0/1
$gcode ||= 11
$gcode
Truth table0%0/2
A
A= $gcode
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $gram = ''; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | elsif ( $kingdom =~ m/vir/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $kingdom = 'Viruses'; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $gcode ||= 1; # std | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$gcode ||= 1
MC/DC0%0/1
$gcode ||= 1
$gcode
Truth table0%0/2
A
A= $gcode
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $gram = ''; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->err("Can't parse --mode '$kingdom'. Choose from: Bacteria Archaea Virus"); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $self->msg("Annotating as >>> $kingdom <<<"); | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # check options | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | ( $gcode < 1 or $gcode > 24 ) and $self->err("Invalid genetic code, must be 1..24"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$gcode < 1 or $gcode > 24
MC/DC0%0/2
$gcode < 1 or $gcode > 24
$gcode < 1
$gcode > 24
Truth table0%0/3
A or B
A= $gcode < 1B= $gcode > 24
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | $evalue >= 0 or $self->err("Invalid --evalue, must be >= 0"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | #($coverage >= 0 and $coverage <= 100) or $self->err("Invalid --coverage, must be 0..100"); | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | $increment >= 1 or $self->err("Invalid --increment, must be >= 1"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $locustag ||= uc($EXE); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$locustag ||= uc $EXE
MC/DC0%0/2
$locustag ||= uc $EXE
$locustag
uc $EXE
Truth table0%0/3
A ||= B
A= $locustagB= uc $EXE
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | # http://www.ncbi.nlm.nih.gov/genomes/static/Annotation_pipeline_README.txt | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | $prefix ||= $locustag . '_' . ( localtime->mdy('') ); # NCBI wants US format, ech. | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prefix ||= $locustag . '_' . Bio::AutomatedAnnotation::Prokka::localtime()->mdy("")
MC/DC0%0/1
$prefix ||= $locustag . '_' . Bio::AutomatedAnnotation::Prokka::localtime()->mdy("")
$prefix
Truth table0%0/2
A
A= $prefix
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $outdir ||= $prefix; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$outdir ||= $prefix
MC/DC0%0/2
$outdir ||= $prefix
$outdir
$prefix
Truth table0%0/3
A ||= B
A= $outdirB= $prefix
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ( -d $outdir ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if ($force) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->msg("Re-using existing --outdir $outdir"); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $self->err("Folder '$outdir' already exists! Please change --outdir or use --force"); | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->msg("Creating new output folder: $outdir"); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $self->runcmd("mkdir -p \Q$outdir\E"); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->msg("Using filename prefix: $prefix.XXX"); | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | # canonical names | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | $genus = ucfirst( lc($genus) ) if $genus; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | $species = lc($species) if $strain; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 205 | # set up log file | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $logfile = "$outdir/$prefix.log"; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->msg("Writing log to: $logfile"); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | open LOG, '>', $logfile or $self->err("Can't open logfile"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 212 | # check dependencies | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | for my $exe ( | |||||||||||||||||||||||||||||||||||||||||
| 215 | qw(less grep egrep sed find tbl2asn makeblastdb blastp | ||||||||||||||||||||||||||||||||||||||||||
| 216 | aragorn prodigal rnammer parallel hmmscan cmscan) | ||||||||||||||||||||||||||||||||||||||||||
| 217 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $fp = $self->require_exe($exe); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | $fp ? $self->msg("Need '$exe' - using $fp") : $self->err("Can't find $exe in your \$PATH"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | # Heikki discovered moreutils.deb contains a really old 'parallel' tool.... | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my ($pout) = qx(parallel -V 2> /dev/null); | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ( $pout !~ m/GNU/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->err("You don't have GNU 'parallel' installed, you have a different tool with that name."); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 230 | # get versions of tools | ||||||||||||||||||||||||||||||||||||||||||
| 231 | # FIXME - put these in a hash with regexps! | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my %tools = ( | |||||||||||||||||||||||||||||||||||||||||
| 234 | 'aragorn' => { | ||||||||||||||||||||||||||||||||||||||||||
| 235 | GETVER => "aragorn -h 2>&1 | grep -i '^ARAGORN v'", | ||||||||||||||||||||||||||||||||||||||||||
| 236 | REGEXP => qr/([\d\.]+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | VERSION => "1.2", | ||||||||||||||||||||||||||||||||||||||||||
| 238 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 'rnammer' => { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | GETVER => "rnammer -V 2>&1 | grep -i 'rnammer [0-9]'", | ||||||||||||||||||||||||||||||||||||||||||
| 241 | REGEXP => qr/([\d\.]+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | VERSION => "1.2", | ||||||||||||||||||||||||||||||||||||||||||
| 243 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 'prodigal' => { | ||||||||||||||||||||||||||||||||||||||||||
| 245 | GETVER => "prodigal -v 2>&1 | grep -i '^Prodigal V'", | ||||||||||||||||||||||||||||||||||||||||||
| 246 | REGEXP => qr/([\d\.]+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 247 | VERSION => "2.6", | ||||||||||||||||||||||||||||||||||||||||||
| 248 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 'signalp' => { | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | # this is so long-winded as -v changed meaning (3.0=version, 4.0=verbose !?) | ||||||||||||||||||||||||||||||||||||||||||
| 252 | GETVER => "signalp -v < /dev/null 2>&1 | egrep ',|# SignalP' | sed 's/^# SignalP-//'", | ||||||||||||||||||||||||||||||||||||||||||
| 253 | REGEXP => qr/^(.*?)[,\s]/, | ||||||||||||||||||||||||||||||||||||||||||
| 254 | VERSION => "4.0", | ||||||||||||||||||||||||||||||||||||||||||
| 255 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 'infernal' => { | ||||||||||||||||||||||||||||||||||||||||||
| 257 | GETVER => "cmscan -h | grep '^# INFERNAL'", | ||||||||||||||||||||||||||||||||||||||||||
| 258 | REGEXP => qr/INFERNAL ([\d\.]+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | VERSION => "1.0", | ||||||||||||||||||||||||||||||||||||||||||
| 260 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 261 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | for my $toolname ( keys %tools ) { | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my $t = $tools{$toolname}; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my ($s) = qx($t->{GETVER}); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ( defined $s ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $s =~ $t->{REGEXP}; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | $t->{VERSION} = $1 if defined $1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->msg("Could not determine version of $toolname ..."); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $self->msg("Determined $toolname version is $t->{VERSION}"); | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ( $rfam and $tools{infernal}{VERSION} < 1.1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rfam and $tools{"infernal"}{"VERSION"} < "1.1"
MC/DC0%0/2
$rfam and $tools{"infernal"}{"VERSION"} < "1.1"
$rfam
$tools{"infernal"}{"VERSION"} < "1.1"
Truth table0%0/3
A and B
A= $rfamB= $tools{"infernal"}{"VERSION"} < "1.1"
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $self->err("This script only supports --rfam with Infernal (ie. cmscan) version 1.1 or higher"); | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | $gcode ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$gcode ||= 1
MC/DC0%0/1
$gcode ||= 1
$gcode
Truth table0%0/2
A
A= $gcode
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $self->msg("Using genetic code table $gcode."); | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 284 | # read in sequences; remove small contigs; replace ambig with N | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $in = $self->assembly_file; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $self->msg("Loading and checking input file: $in"); | |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $fin = Bio::SeqIO->new( -file => $in, -format => 'fasta' ); | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $fout = Bio::SeqIO->new( -file => ">$outdir/$prefix.fna", -format => 'fasta' ); | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $ncontig = 0; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | while ( my $seq = $fin->next_seq ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if ( $seq->length < $mincontig ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $self->msg( "Skipping short (<$mincontig bp) contig:", $seq->display_id ); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $ncontig++; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $id; | |||||||||||||||||||||||||||||||||||||||||
| 298 | # http://www.ncbi.nlm.nih.gov/genomes/static/Annotation_pipeline_README.txt | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if($self->keep_original_order_and_names) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $id = $seq->display_id; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | else | ||||||||||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $id = sprintf "contig%06d", $ncontig; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | $id = "$contig_uniq_id|$centre|$id" if $centre; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $seq->display_id($id); | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $s = $seq->seq; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $s = uc($s); | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $s =~ s/[^ACTG]/N/g; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $seq->seq($s); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $seq->desc(undef); | |||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $fout->write_seq($seq); | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $seq{$id}{DNA} = $seq; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $seq{$id}{order} = $ncontig; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->msg("Wrote $ncontig contigs"); | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | #$self->msg(sort keys %seq); exit; | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 324 | # tRNA + tmRNA | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $self->msg("Predicting tRNAs and tmRNAs"); | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $cmd = "aragorn -gc$gcode -w $outdir/$prefix.fna"; # -t/-m | |||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $self->msg("Running: $cmd"); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $num_trna = 0; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | open TRNA, "$cmd |"; | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $sid; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | while (<TRNA>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if (m/^>end/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if (m/^>(\S+)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $sid = $1; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my @x = split m/\s+/; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | next unless @x == 5 and $x[0] =~ m/^\d+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@x == 5 and $x[0] =~ /^\d+$/
MC/DC0%0/2
@x == 5 and $x[0] =~ /^\d+$/
@x == 5
$x[0] =~ /^\d+$/
Truth table0%0/3
A and B
A= @x == 5B= $x[0] =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | # and $x[4] =~ m/^\([ATCG]{3}\)$/i; | ||||||||||||||||||||||||||||||||||||||||||
| 346 | #$self->msg($_); | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $self->msg("@x"); | |||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $x[2] =~ m/(c)?\[(\d+),(\d+)\]/; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my ( $revcom, $start, $end ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | # bug fix for aragorn when revcom trna ends at start of contig! | ||||||||||||||||||||||||||||||||||||||||||
| 352 | # if (defined $revcom and $start > $end) { | ||||||||||||||||||||||||||||||||||||||||||
| 353 | # $self->msg("Activating kludge for Aragorn bug for tRNA end at contig start"); | ||||||||||||||||||||||||||||||||||||||||||
| 354 | # $start = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 355 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ( $start > $end ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $self->msg("tRNA $x[2] has start($start) > end ($end) - skipping."); | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if ( abs( $end - $start ) > 500 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $self->msg("tRNA/tmRNA $x[2] is too big (>500bp) - skipping."); | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | # end kludge | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $num_trna++; | |||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $ftype = 'tRNA'; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $product = $x[1] . $x[4]; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my @gene = (); | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if ( $x[1] eq 'tmRNA' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $ftype = $x[1]; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $product = "transfer-messenger RNA, SsrA"; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | @gene = ( 'gene' => 'ssrA' ); | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $tool = "Aragorn:" . $tools{aragorn}->{VERSION}; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | push @{ $seq{$sid}{FEATURE} }, Bio::SeqFeature::Generic->new( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | -primary => $ftype, # tRNA or tmRNA | ||||||||||||||||||||||||||||||||||||||||||
| 380 | -seq_id => $sid, | ||||||||||||||||||||||||||||||||||||||||||
| 381 | -source => $tool, | ||||||||||||||||||||||||||||||||||||||||||
| 382 | -start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 383 | -end => $end, | ||||||||||||||||||||||||||||||||||||||||||
| 384 | -strand => ( defined $revcom ? -1 : +1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 385 | -score => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 386 | -frame => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 387 | -tag => { | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 'product' => $product, | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 'inference' => "COORDINATES:profile:$tool", | ||||||||||||||||||||||||||||||||||||||||||
| 390 | @gene, | ||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $self->msg("Found $num_trna tRNAs"); | |||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 397 | # rRNA | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ( $kingdom ne 'Viruses' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $self->msg("Predicting Ribosomal RNAs"); | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $rnammerfn = "$outdir/rnammer.xml"; | |||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $num_rrna = 0; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | my $rnammer_opt = $cpus != 1 ? "-multi" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $self->runcmd("rnammer -S bac $rnammer_opt -xml $rnammerfn $outdir/$prefix.fna"); | |||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $xml = XML::Simple->new( ForceArray => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my $data = $xml->XMLin($rnammerfn); | |||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | for my $entry ( @{ $data->{entries}[0]->{entry} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $sid = $entry->{sequenceEntry}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | next unless exists $seq{$sid}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $desc = $entry->{mol}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $desc =~ s/s_r/S ribosomal /i; # make it English '23S_rRNA => 23S ribosomal RNA' | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $num_rrna++; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $tool = "RNAmmer:" . $tools{rnammer}->{VERSION}; | |||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | push @{ $seq{$sid}{FEATURE} }, Bio::SeqFeature::Generic->new( | |||||||||||||||||||||||||||||||||||||||||
| 415 | -primary => 'rRNA', | ||||||||||||||||||||||||||||||||||||||||||
| 416 | -seq_id => $sid, | ||||||||||||||||||||||||||||||||||||||||||
| 417 | -source => $tool, # $data->{predictor}[0] | ||||||||||||||||||||||||||||||||||||||||||
| 418 | -start => $entry->{start}[0], | ||||||||||||||||||||||||||||||||||||||||||
| 419 | -end => $entry->{stop}[0], | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | -strand => $entry->{direction}[0], | |||||||||||||||||||||||||||||||||||||||||
| 421 | -score => undef, # $entry->{score}[0], | ||||||||||||||||||||||||||||||||||||||||||
| 422 | -frame => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 423 | -tag => { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 'product' => $desc, | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 'inference' => "COORDINATES:profile:$tool", # FIXME version | ||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 428 | $self->msg( | ||||||||||||||||||||||||||||||||||||||||||
| 429 | join "\t", $num_rrna, $desc, $sid, | ||||||||||||||||||||||||||||||||||||||||||
| 430 | $entry->{start}[0], | ||||||||||||||||||||||||||||||||||||||||||
| 431 | $entry->{stop}[0], | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $entry->{direction}[0] | |||||||||||||||||||||||||||||||||||||||||
| 433 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $self->delfile($rnammerfn); | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $self->msg("Found $num_rrna rRNAs"); | |||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $self->msg("Disabling rRNA search for $kingdom."); | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 443 | # ncRNA via Rfam + Infernal | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $cmdb = "$dbdir/cm/$kingdom"; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | if ( $rfam and -r "$cmdb.i1m" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rfam and -r "$cmdb.i1m"
MC/DC0%0/2
$rfam and -r "$cmdb.i1m"
$rfam
-r "$cmdb.i1m"
Truth table0%0/3
A and B
A= $rfamB= -r "$cmdb.i1m"
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $self->msg("Scanning for ncRNAs... please be patient."); | |||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | my $cmscan_obj = Bio::AutomatedAnnotation::External::Cmscan->new( | ||||||||||||||||||||||||||||||||||||||||||
| 450 | cmdb => $cmdb, | ||||||||||||||||||||||||||||||||||||||||||
| 451 | input_file => "$outdir/$prefix.fna", | ||||||||||||||||||||||||||||||||||||||||||
| 452 | exec => 'cmscan', | ||||||||||||||||||||||||||||||||||||||||||
| 453 | version => $tools{infernal}->{VERSION}, | ||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | cpus => $cpus, | |||||||||||||||||||||||||||||||||||||||||
| 455 | evalue => $evalue, | ||||||||||||||||||||||||||||||||||||||||||
| 456 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $cmscan_obj->add_features_to_prokka_structure(\%seq); | |||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $self->msg("Found ".$cmscan_obj->number_of_features." ncRNAs."); | |||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $self->msg("Disabling ncRNA search, can't find $cmdb file."); | |||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 466 | # Tally all the RNA features so we can exclude overlaps with CDS | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | my @allrna; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | push @allrna, ( grep { $_->primary_tag =~ m/RNA/ } @{ $seq{$sid}{FEATURE} } ); | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $self->msg( "Total of", scalar(@allrna), "RNA features" ); | |||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 475 | # CDS | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->msg("Predicting coding sequences"); | |||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $totalbp = sum( map { $seq{$_}{DNA}->length } keys %seq ); | |||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | my $prodigal_mode = $totalbp >= 100000 ? 'single' : 'meta'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $self->msg("Contigs total $totalbp bp, so using $prodigal_mode mode"); | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $num_cds = 0; | |||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $cmd = "prodigal -i $outdir/$prefix.fna -c -m -g $gcode -p $prodigal_mode -f sco -q"; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $self->msg("Running: $cmd"); | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | open CDS, "$cmd |"; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | while (<CDS>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | if (m/seqhdr="([^\s\"]+)"/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $sid = $1; | |||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | # $self->msg("CDS $sid"); | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | elsif (m/^>\d+_(\d+)_(\d+)_([+-])$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my $tool = "Prodigal:" . $tools{prodigal}->{VERSION}; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | my $cds = Bio::SeqFeature::Generic->new( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | -primary => 'CDS', | ||||||||||||||||||||||||||||||||||||||||||
| 497 | -seq_id => $sid, | ||||||||||||||||||||||||||||||||||||||||||
| 498 | -source => $tool, | ||||||||||||||||||||||||||||||||||||||||||
| 499 | -start => $1, | ||||||||||||||||||||||||||||||||||||||||||
| 500 | -end => $2, | ||||||||||||||||||||||||||||||||||||||||||
| 501 | -strand => ( $3 eq '+' ? +1 : -1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 502 | -score => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 503 | -frame => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 504 | -tag => { | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 'inference' => "ab initio prediction:$tool", | ||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||
| 507 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my $overlap; | |||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | for my $rna (@allrna) { | |||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | # same contig, overlapping (could check same strand too? not sure) | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | if ( $rna->seq_id eq $sid and $cds->overlaps($rna) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rna->seq_id eq $sid and $cds->overlaps($rna)
MC/DC0%0/2
$rna->seq_id eq $sid and $cds->overlaps($rna)
$rna->seq_id eq $sid
$cds->overlaps($rna)
Truth table0%0/3
A and B
A= $rna->seq_id eq $sidB= $cds->overlaps($rna)
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $overlap = $rna; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if ($overlap) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->msg("Not including CDS which overlaps existing RNA at $sid:$1..$2 on $3 strand"); | |||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $num_cds++; | |||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | push @{ $seq{$sid}{FEATURE} }, $cds; | |||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $self->msg("Found $num_cds CDS"); | |||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 529 | # Connect features to their parent sequences | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $self->msg("Connecting features back to sequences"); | |||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | for my $f ( @{ $seq{$sid}{FEATURE} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $f->attach_seq( $seq{$sid}{DNA} ); | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 539 | # Find signal peptide leader sequences | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | my $sigpver = substr $tools{signalp}{VERSION}, 0, 1; # first char, expect 3 or 4 | |||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if ( $kingdom eq 'Bacteria' and $sigpver == 3 || $sigpver == 4 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$kingdom eq "Bacteria" and $sigpver == 3 || $sigpver == 4
$sigpver == 3 or $sigpver == 4
MC/DC0%0/3
$kingdom eq "Bacteria" and $sigpver == 3 || $sigpver == 4
$kingdom eq "Bacteria"
$sigpver == 3
$sigpver == 4
Truth table0%0/4
A and B or C
A= $kingdom eq "Bacteria"B= $sigpver == 3C= $sigpver == 4
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | if ($gram) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | $gram = $gram =~ m/\+|[posl]/i ? 'gram+' : 'gram-'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $self->msg("Looking for signal peptides at start of predicted proteins"); | |||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | $self->msg("Treating $kingdom as $gram"); | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $spoutfn = "$outdir/signalp.faa"; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $spout = Bio::SeqIO->new( -file => ">$spoutfn", -format => 'fasta' ); | |||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my %cds; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | for my $f ( @{ $seq{$sid}{FEATURE} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | next unless $f->primary_tag eq 'CDS'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $cds{ ++$count } = $f; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | my $seq = $f->seq->translate; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $seq->display_id($count); | |||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $spout->write_seq($seq); | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | my $opts = $sigpver == 3 ? '-m hmm' : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $cmd = "signalp -t $gram -f short $opts $spoutfn 2> /dev/null"; | |||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | $self->msg("Running: $cmd"); | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | my $tool = "SignalP:" . $tools{signalp}->{VERSION}; | |||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $num_sigpep = 0; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | open SIGNALP, "$cmd |"; | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | while (<SIGNALP>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my @x = split m/\s+/; | |||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | if ( $sigpver == 3 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | next unless @x == 7 and $x[6] eq 'Y'; # has sig_pep | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@x == 7 and $x[6] eq "Y"
MC/DC0%0/2
@x == 7 and $x[6] eq "Y"
@x == 7
$x[6] eq "Y"
Truth table0%0/3
A and B
A= @x == 7B= $x[6] eq "Y"
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my $parent = $cds{ $x[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $prob = $x[5]; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | my $cleave = $x[3]; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | my $start = $parent->strand > 0 ? $parent->start : $parent->end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my $end = $start + $parent->strand * ( $cleave - 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my $sigpep = Bio::SeqFeature::Generic->new( | |||||||||||||||||||||||||||||||||||||||||
| 579 | -seq_id => $parent->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 580 | -source_tag => $tool, | ||||||||||||||||||||||||||||||||||||||||||
| 581 | -primary => 'sig_peptide', | ||||||||||||||||||||||||||||||||||||||||||
| 582 | -start => min( $start, $end ), | ||||||||||||||||||||||||||||||||||||||||||
| 583 | -end => max( $start, $end ), | ||||||||||||||||||||||||||||||||||||||||||
| 584 | -strand => $parent->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 585 | -frame => 0, # PHASE: compulsory for peptides, can't be '.' | ||||||||||||||||||||||||||||||||||||||||||
| 586 | -tag => { | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | # 'ID' => $ID, | ||||||||||||||||||||||||||||||||||||||||||
| 589 | # 'Parent' => $x[0], # don't have proper IDs yet.... | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 'product' => "putative signal peptide", | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 'inference' => "ab initio prediction:$tool", | ||||||||||||||||||||||||||||||||||||||||||
| 592 | 'note' => "predicted cleavage at residue $x[3] with probability $prob", | ||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 594 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | push @{ $seq{ $parent->seq_id }{FEATURE} }, $sigpep; | |||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $num_sigpep++; | |||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 598 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 599 | # $self->msg("sigp$sigpver: @x"); | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | next unless @x == 12 and $x[9] eq 'Y'; # has sig_pep | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@x == 12 and $x[9] eq "Y"
MC/DC0%0/2
@x == 12 and $x[9] eq "Y"
@x == 12
$x[9] eq "Y"
Truth table0%0/3
A and B
A= @x == 12B= $x[9] eq "Y"
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $parent = $cds{ $x[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $cleave = $x[2]; | |||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | my $start = $parent->strand > 0 ? $parent->start : $parent->end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my $end = $start + $parent->strand * ( $cleave - 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $sigpep = Bio::SeqFeature::Generic->new( | |||||||||||||||||||||||||||||||||||||||||
| 606 | -seq_id => $parent->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 607 | -source_tag => $tool, | ||||||||||||||||||||||||||||||||||||||||||
| 608 | -primary => 'sig_peptide', | ||||||||||||||||||||||||||||||||||||||||||
| 609 | -start => min( $start, $end ), | ||||||||||||||||||||||||||||||||||||||||||
| 610 | -end => max( $start, $end ), | ||||||||||||||||||||||||||||||||||||||||||
| 611 | -strand => $parent->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 612 | -frame => 0, # PHASE: compulsory for peptides, can't be '.' | ||||||||||||||||||||||||||||||||||||||||||
| 613 | -tag => { | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | # 'ID' => $ID, | ||||||||||||||||||||||||||||||||||||||||||
| 616 | # 'Parent' => $x[0], # don't have proper IDs yet.... | ||||||||||||||||||||||||||||||||||||||||||
| 617 | 'product' => "putative signal peptide", | ||||||||||||||||||||||||||||||||||||||||||
| 618 | 'inference' => "ab initio prediction:$tool", | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 'note' => "predicted cleavage at residue $x[2]", | ||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 621 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | push @{ $seq{ $parent->seq_id }{FEATURE} }, $sigpep; | |||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $num_sigpep++; | |||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | $self->msg("Found $num_sigpep signal peptides"); | |||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $self->delfile($spoutfn); | |||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||
| 629 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $self->msg("Option --gram not specified, will NOT check for signal peptides."); | |||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 635 | # Annotate CDS | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | #my %dbof = ( 'PF'=>'Pfam', 'TIGR'=>'TIGRFAMs', 'PRK'=>'Cdd', 'COG'=>'COG' ); | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | # primary data source is a curated subset of uniprot (evidence <= 1 per Phylum) | ||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | my @database = ( | |||||||||||||||||||||||||||||||||||||||||
| 641 | { | ||||||||||||||||||||||||||||||||||||||||||
| 642 | DB => "$dbdir/kingdom/$kingdom/sprot", | ||||||||||||||||||||||||||||||||||||||||||
| 643 | SRC => 'similar to AA sequence:UniProtKB:', | ||||||||||||||||||||||||||||||||||||||||||
| 644 | FMT => 'blast', | ||||||||||||||||||||||||||||||||||||||||||
| 645 | CMD => $BLASTPCMD, | ||||||||||||||||||||||||||||||||||||||||||
| 646 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 647 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | # secondary sources are a series of HMMs | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | unless ( $kingdom eq 'Viruses' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | for my $name (qw(CLUSTERS Cdd TIGRFAMs Pfam)) { | |||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | push @database, | |||||||||||||||||||||||||||||||||||||||||
| 653 | { | ||||||||||||||||||||||||||||||||||||||||||
| 654 | DB => "$dbdir/hmm/$name.hmm", | ||||||||||||||||||||||||||||||||||||||||||
| 655 | SRC => "protein motif:$name:", | ||||||||||||||||||||||||||||||||||||||||||
| 656 | FMT => 'hmmer', | ||||||||||||||||||||||||||||||||||||||||||
| 657 | VERSION => 3, | ||||||||||||||||||||||||||||||||||||||||||
| 658 | CMD => $HMMER3CMD, | ||||||||||||||||||||||||||||||||||||||||||
| 659 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | # if --usegenus is enabled | ||||||||||||||||||||||||||||||||||||||||||
| 664 | # AND user supplies a genus, and we have a custom file (from GenBank) do it first! | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | if ($usegenus) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if ( $genus and -r "$dbdir/genus/$genus.pin" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$genus and -r "$dbdir/genus/$genus.pin"
MC/DC0%0/2
$genus and -r "$dbdir/genus/$genus.pin"
$genus
-r "$dbdir/genus/$genus.pin"
Truth table0%0/3
A and B
A= $genusB= -r "$dbdir/genus/$genus.pin"
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | my $blastdb = "$dbdir/genus/$genus"; | |||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $self->msg("Using custom $genus database for annotation"); | |||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | unshift @database, | |||||||||||||||||||||||||||||||||||||||||
| 670 | { | ||||||||||||||||||||||||||||||||||||||||||
| 671 | DB => $blastdb, | ||||||||||||||||||||||||||||||||||||||||||
| 672 | SRC => 'similar to AA sequence:RefSeq:', | ||||||||||||||||||||||||||||||||||||||||||
| 673 | FMT => 'blast', | ||||||||||||||||||||||||||||||||||||||||||
| 674 | CMD => $BLASTPCMD, | ||||||||||||||||||||||||||||||||||||||||||
| 675 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||
| 677 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $self->msg("Skipping genus-specific proteins as can't see $dbdir/$genus"); | |||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | $self->msg("Not using genus-specific database. Try --usegenus to enable it."); | |||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | # if user supplies a trusted set of proteins, we try these first! | ||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | if ( -r $proteins ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | $self->msg("Preparing user-supplied primary annotation source: $proteins"); | |||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | $self->runcmd("makeblastdb -dbtype prot -in '$proteins' -out $outdir/proteins -logfile /dev/null"); | |||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | unshift @database, | |||||||||||||||||||||||||||||||||||||||||
| 690 | { | ||||||||||||||||||||||||||||||||||||||||||
| 691 | DB => "$outdir/proteins", | ||||||||||||||||||||||||||||||||||||||||||
| 692 | SRC => 'similar to AA sequence:RefSeq:', | ||||||||||||||||||||||||||||||||||||||||||
| 693 | FMT => 'blast', | ||||||||||||||||||||||||||||||||||||||||||
| 694 | CMD => $BLASTPCMD, | ||||||||||||||||||||||||||||||||||||||||||
| 695 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | if ($fast) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | $self->msg("Option --fast enabled, so skipping CDS similarity searches"); | |||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 701 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $self->msg("Annotating CDS, please be patient."); | |||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | my $paropts = $cpus > 0 ? " -j $cpus" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | $self->msg( "Will use", ( $cpus > 0 ? $cpus : 'all available' ), "CPUs for similarity searching." ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | my $num_cleaned = 0; | |||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | my %cds; | |||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | for my $f ( @{ $seq{$sid}{FEATURE} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | next unless $f->primary_tag eq 'CDS'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | next if $f->has_tag('product'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | $cds{ ++$count } = $f; | |||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | if ( $count > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | # Minimise the number of files created at a time. Tradeoff with efficiency of parallelisation. | ||||||||||||||||||||||||||||||||||||||||||
| 722 | # This creates X files per CPU. | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | my $slice_size = ( ( $cpus > 0 ) ? $cpus : 1 ) * ( ( $files_per_chunk <= 0 ) ? 10 : $files_per_chunk ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | my @cds_counter = sort( keys %cds ); | |||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | for ( my $i = 0 ; $i < ceil( (@cds_counter) / $slice_size ) ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | for ( my $j = $slice_size * $i ; $j < @cds_counter && $j < $slice_size * ( $i + 1 ) ; $j++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$j < @cds_counter and $j < $slice_size * ($i + 1)
MC/DC0%0/2
$j < @cds_counter and $j < $slice_size * ($i + 1)
$j < @cds_counter
$j < $slice_size * ($i + 1)
Truth table0%0/3
A and B
A= $j < @cds_counterB= $j < $slice_size * ($i + 1)
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $self->create_cds_sequences_in_file( $tempdir, $cds_counter[$j], $cds{ $cds_counter[$j] } ); | |||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | for my $db (@database) { | |||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my $cmd = $db->{CMD}; | |||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | $cmd =~ s/%i/{}/g; | |||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $cmd =~ s/%o/{}.out/g; | |||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | $cmd =~ s/%e/$evalue/g; | |||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | $cmd =~ s,%d,$db->{DB},g; | |||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $self->msg( $db->{FMT}, "$count (of $num_cds) proteins against", $db->{DB} ); | |||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $self->runcmd("nice parallel$paropts $cmd ::: $tempdir/*.seq"); | |||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | for ( my $j = $slice_size * $i ; $j < @cds_counter && $j < $slice_size * ( $i + 1 ) ; $j++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$j < @cds_counter and $j < $slice_size * ($i + 1)
MC/DC0%0/2
$j < @cds_counter and $j < $slice_size * ($i + 1)
$j < @cds_counter
$j < $slice_size * ($i + 1)
Truth table0%0/3
A and B
A= $j < @cds_counterB= $j < $slice_size * ($i + 1)
| |||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | my $pid = $cds_counter[$j]; | |||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | my $bls = Bio::SearchIO->new( -file => "$tempdir/$pid.seq.out", -format => $db->{FMT}, -version => $db->{VERSION} ); | |||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | my $res = $bls->next_result or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | my $hit = $res->next_hit or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | my ( $prod, $gene, $EC ) = ( $hit->description, '', '' ); | |||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | if ( $prod =~ m/~~~/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ( $EC, $gene, $prod ) = split m/~~~/, $prod; | |||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | $EC =~ s/n\d+/-/g; # collapse transitionary EC numbers | |||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | my $cleanprod = $prod; | |||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | if ( $self->cleanup_prod ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $cleanprod = $self->cleanup_product($prod); | |||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | if ( $cleanprod ne $prod ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | $self->msg("Modify product: $prod => $cleanprod"); | |||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | if ( $cleanprod eq $HYPO ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | $cds{$pid}->add_tag_value( 'note', $prod ); | |||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | $cds{$pid}->remove_tag('gene') if $cds{$pid}->has_tag('gene'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | $cds{$pid}->remove_tag('EC_number') if $cds{$pid}->has_tag('EC_number'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $num_cleaned++; | |||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | $cds{$pid}->add_tag_value( 'product', $cleanprod ); | |||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | $cds{$pid}->add_tag_value( 'EC_number', $EC ) if $EC; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | if ( defined($gene) && $gene ne "" && !$cds{$pid}->has_tag('gene') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $gene and $gene ne "" and not $cds{$pid}->has_tag("gene")
defined $gene and $gene ne ""
MC/DC0%0/3
defined $gene and $gene ne "" and not $cds{$pid}->has_tag("gene")
defined $gene
$gene ne ""
not $cds{$pid}->has_tag("gene")
Truth table0%0/4
A and B and not(C)
A= defined $geneB= $gene ne ""C= not $cds{$pid}->has_tag("gene")
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | $cds{$pid}->add_tag_value( 'gene', $gene ); | |||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | $cds{$pid}->add_tag_value( 'inference', $db->{SRC} . $hit->name ); | |||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | unlink "$tempdir/$pid.seq.out"; | |||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | unlink map { "$tempdir/$_.seq" } keys %cds; | |||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | unlink map { "$tempdir/$_.seq.out" } keys %cds; | |||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | unlink map { "$tempdir/$_.seq" } keys %cds; | |||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | unlink map { "$tempdir/$_.seq.out" } keys %cds; | |||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | $self->msg("Cleaned $num_cleaned /product names") if $num_cleaned > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | if ($proteins) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | $self->delfile( map { "$outdir/proteins.$_" } qw(psq phr pin) ); | |||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 791 | # Label unannotated proteins as 'hypothetical protein' | ||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | my $empty_label = $fast ? 'unannotated protein' : $HYPO; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | my $num_hypo = 0; | |||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | for my $f ( @{ $seq{$sid}{FEATURE} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | if ( $f->primary_tag eq 'CDS' and not $f->has_tag('product') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$f->primary_tag eq "CDS" and not $f->has_tag("product")
MC/DC0%0/2
$f->primary_tag eq "CDS" and not $f->has_tag("product")
$f->primary_tag eq "CDS"
not $f->has_tag("product")
Truth table0%0/3
A and not(B)
A= $f->primary_tag eq "CDS"B= not $f->has_tag("product")
| |||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | $f->add_tag_value( 'product', $empty_label ); | |||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | $num_hypo++; | |||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | $self->msg("Labelling remaining $num_hypo proteins as '$empty_label'") if $num_hypo > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 806 | # Look for possible /pseudo genes - adjacent with same annotation | ||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | my $prev = ''; | |||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | for my $f ( grep { $_->primary_tag eq 'CDS' } @{ $seq{$sid}{FEATURE} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | my $this = $self->tag( $f, 'product' ); | |||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | if ( $this eq $prev and $this ne $HYPO and $this ne $UNANN ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$this eq $prev and $this ne $HYPO and $this ne $UNANN
$this eq $prev and $this ne $HYPO
MC/DC0%0/3
$this eq $prev and $this ne $HYPO and $this ne $UNANN
$this eq $prev
$this ne $HYPO
$this ne $UNANN
Truth table0%0/4
A and B and C
A= $this eq $prevB= $this ne $HYPOC= $this ne $UNANN
| |||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $self->msg( "Possible /pseudo '$prev' at", $f->seq_id, 'position', $f->start ); | |||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | $prev = $this; | |||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | $this = ''; | |||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 821 | # Fix colliding /gene names in CDS (before we add 'gene' features) | ||||||||||||||||||||||||||||||||||||||||||
| 822 | # (this could be written as such a nice map/map/grep one day...) | ||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my %collide; | |||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | for my $f ( sort { $a->start <=> $b->start } @{ $seq{$sid}{FEATURE} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | next unless $f->primary_tag eq 'CDS'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | my $gene = $self->tag( $f, 'gene' ) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | push @{ $collide{$gene} }, $f; | |||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | $self->msg( "Found", scalar( keys(%collide) ), "unique /gene codes." ); | |||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my $num_collide = 0; | |||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | for my $gene ( keys %collide ) { | |||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | my @cds = @{ $collide{$gene} }; | |||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | next unless @cds > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | for my $f (@cds) { | |||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | $f->remove_tag('gene'); | |||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | $n++; | |||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | $f->add_tag_value( 'gene', "${gene}_${n}" ); | |||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | $num_collide++; | |||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | $self->msg("Fixed $num_collide colliding /gene names."); | |||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 850 | # Add locus_tags and protein_id[CDS only] (and Parent genes if asked) | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my $num_lt = 0; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | for my $f ( sort { $a->start <=> $b->start } @{ $seq{$sid}{FEATURE} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | next unless $f->primary_tag =~ m/CDS|RNA/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | $num_lt++; | |||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my $ID = sprintf( "${locustag}_%05d", $num_lt * $increment ); | |||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | $f->add_tag_value( 'ID', $ID ); | |||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | $f->add_tag_value( 'locus_tag', $ID ); | |||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | ▶ | $f->add_tag_value( 'protein_id', "gnl|$centre|$ID" ) if $f->primary_tag eq 'CDS'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | if ($addgenes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | my $g = $f->clone; | |||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | $g->primary_tag('gene'); | |||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | $g->source_tag($EXE); | |||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | $g->remove_tag($_) for $g->get_all_tags; | |||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | $g->add_tag_value( 'locus_tag', $ID ); | |||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | if ( my $gENE = $self->tag( $f, 'gene' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | $g->add_tag_value( 'gene', $gENE ); | |||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | push @{ $seq{$sid}{FEATURE} }, $g; | |||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | $self->msg("Assigned $num_lt locus_tags to CDS and RNA features."); | |||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||
| 876 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 877 | # Write it all out! | ||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | $self->msg("Writing outputs to $outdir/"); | |||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | open my $gff_fh, '>', "$outdir/$prefix.gff"; | |||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | my $faa_fh = Bio::SeqIO->new( -file => ">$outdir/$prefix.faa", -format => 'fasta' ); | |||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my $ffn_fh = Bio::SeqIO->new( -file => ">$outdir/$prefix.ffn", -format => 'fasta' ); | |||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | open my $tbl_fh, '>', "$outdir/$prefix.tbl"; | |||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my $fsa_fh = Bio::SeqIO->new( -file => ">$outdir/$prefix.fsa", -format => 'fasta' ); | |||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | my $gff_factory = Bio::Tools::GFF->new( -gff_version => $gffver ); | |||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | print $gff_fh "##gff-version $gffver\n"; | |||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | for my $id ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | print $gff_fh "##sequence-region $id 1 ", $seq{$id}{DNA}->length, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | my $fsa_desc = "[gcode=$gcode] [organism=$genus $species] [strain=$strain]"; | |||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | my $ctg = $seq{$sid}{DNA}; | |||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | $ctg->desc($fsa_desc); | |||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | $fsa_fh->write_seq($ctg); | |||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | $ctg->desc(undef); | |||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | print $tbl_fh ">Feature $sid\n"; | |||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | for my $f ( sort { $a->start <=> $b->start } @{ $seq{$sid}{FEATURE} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | if ( $f->primary_tag eq 'CDS' and not $f->has_tag('product') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$f->primary_tag eq "CDS" and not $f->has_tag("product")
MC/DC0%0/2
$f->primary_tag eq "CDS" and not $f->has_tag("product")
$f->primary_tag eq "CDS"
not $f->has_tag("product")
Truth table0%0/3
A and not(B)
A= $f->primary_tag eq "CDS"B= not $f->has_tag("product")
| |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $f->add_tag_value( 'product', $HYPO ); | |||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | print $gff_fh $f->gff_string($gff_factory), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | my ( $L, $R ) = ( $f->strand >= 0 ) ? ( $f->start, $f->end ) : ( $f->end, $f->start ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | print {$tbl_fh} "$L\t$R\t", $f->primary_tag, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | for my $tag ( $f->get_all_tags ) { | |||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | next if $tag =~ m/^(ID|Alias)$/; # remove GFF specific tags | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | for my $value ( $f->get_tag_values($tag) ) { | |||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | print {$tbl_fh} "\t\t\t$tag\t$value\n"; | |||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my $p = $seq{$sid}{DNA}->trunc( $f->location ); | |||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | $p->display_id( $self->tag( $f, 'locus_tag' ) ); | |||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | ▶ | $p->desc( $self->tag( $f, 'product' ) ) if $f->has_tag('product'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | unless ( $addgenes and $f->primary_tag eq 'gene' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$addgenes and $f->primary_tag eq "gene"
MC/DC0%0/2
$addgenes and $f->primary_tag eq "gene"
$addgenes
$f->primary_tag eq "gene"
Truth table0%0/3
A and B
A= $addgenesB= $f->primary_tag eq "gene"
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | $ffn_fh->write_seq($p); | |||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | if ( $f->primary_tag eq 'CDS' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | $faa_fh->write_seq( $p->translate( -codontable_id => $gcode ) ); | |||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | if ( scalar keys %seq ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | print $gff_fh "##FASTA\n"; | |||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my $seqio = Bio::SeqIO->new( -fh => $gff_fh, -format => 'fasta' ); | |||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | ▶ | if($self->keep_original_order_and_names) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 933 | { | ||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | for my $sid ( sort {$seq{$a}{order} <=> $seq{$b}{order} } keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | $seqio->write_seq( $seq{$sid}{DNA} ); | |||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||
| 938 | else | ||||||||||||||||||||||||||||||||||||||||||
| 939 | { | ||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | for my $sid ( sort keys %seq ) { | |||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | $seqio->write_seq( $seq{$sid}{DNA} ); | |||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 947 | # Use tbl2asn tool to make .gbk and .sqn for us | ||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | $self->msg("Generating Genbank and Sequin files"); | |||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | $self->runcmd( | |||||||||||||||||||||||||||||||||||||||||
| 951 | "tbl2asn -N 1 -y 'Annotated using $EXE $VERSION from $URL' -Z $outdir/$prefix.err -M n -V b -i $outdir/$prefix.fsa -f $outdir/$prefix.tbl 2> /dev/null" | ||||||||||||||||||||||||||||||||||||||||||
| 952 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | $self->delfile("$outdir/errorsummary.val"); | |||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | $self->delfile( map { "$outdir/$prefix.$_" } qw(dr fixedproducts ecn val) ); | |||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | move( "$outdir/$prefix.gbf", "$outdir/$prefix.gbk" ); # rename XXX.gbf to XXX.gbk | |||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||
| 957 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||||||||||||||||
| 958 | # Some final log output | ||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | $self->msg("Output files:"); | |||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | foreach (qx(find $outdir -type f -name "$prefix.*")) { | |||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $self->msg($_); | |||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | my $endtime = localtime; | |||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | my $walltime = $endtime - $starttime; | |||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||
| 968 | #$self->msg("Walltime used:", $walltime->pretty); # Heikki says this method only came with 1.20 | ||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my $pretty = sprintf "%.2f minutes", $walltime->minutes; | |||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | $self->msg("Walltime used: $pretty"); | |||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | ▶ | $self->msg( $walltime % 2 ? "Share and enjoy!" : "Thank you, come again." ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | #EXIT | ||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||
| 977 | sub cleanup_product { | ||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | my ( $self, $p ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cleanup_product: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | return $self->hypo if $p =~ m/DUF\d|UPF\d|conserved|domain of unknown|[CN].term|homolog|paralog/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | ▶ | return $self->hypo if $p !~ m/[a-z]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | $p =~ s/\((EC|COG).*?\)//; | |||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | $p =~ s/\s*\w+\d{4,}//; # remove possible locus tags | |||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | $p =~ s/ and (inactivated|related) \w+//; | |||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | $p =~ s/^(possible|probable|predicted|uncharacteri.ed)/putative/i; | |||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | if ( $p =~ m/(domain|family|binding|fold|like)\s*$/i and $p !~ m/,/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$p =~ /(domain|family|binding|fold|like)\s*$/i and not $p =~ /,/
MC/DC0%0/2
$p =~ /(domain|family|binding|fold|like)\s*$/i and not $p =~ /,/
$p =~ /(domain|family|binding|fold|like)\s*$/i
not $p =~ /,/
Truth table0%0/3
A and not(B)
A= $p =~ /(domain|family|binding|fold|like)\s*$/iB= not $p =~ /,/
| |||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | $p .= " protein"; | |||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 991 | } | ||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||
| 993 | sub tag { | ||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | ▶ | my ( $self, $f, $tag ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tag: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | return unless $f->has_tag($tag); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | return ( $f->get_tag_values($tag) )[0]; | |||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||
| 999 | sub require_exe { | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | my ( $self, $bin ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_exe: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | for my $dir ( File::Spec->path ) { | |||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $exe = File::Spec->catfile( $dir, $bin ); | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | return $exe if -x $exe; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | sub msg { | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | ▶ | my ( $self, @message ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | my $t = localtime; | |||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | my $line = "[" . $t->hms . "] @message\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ▶ | print LOG $line if openhandle( \*LOG ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | ▶ | print STDERR $line unless $self->quiet; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||
| 1016 | sub err { | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | ▶ | my ( $self, @message ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
err: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | $self->quiet(0); | |||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | $self->msg(@message); | |||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | exit(2); | |||||||||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | sub runcmd { | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | ▶ | my ( $self, @command_to_run ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
runcmd: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | $self->msg( "Running:", @command_to_run ); | |||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | ▶ | system(@command_to_run) == 0 or $self->err( "Could not run command:", @command_to_run ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||
| 1029 | sub delfile { | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | ▶ | my ( $self, @files_to_delete ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delfile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | for my $file (@files_to_delete) { | |||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | $self->msg( "Deleting temporary file:", $file ); | |||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | unlink $file; | |||||||||||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||
| 1037 | sub create_cds_sequences_in_file { | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | ▶ | my ( $self, $outdir, $count, $feature ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_cds_sequences_in_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | open my $fout, '>', "$outdir/$count.seq"; | |||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | print $fout ">$count\n", $feature->seq->translate->seq, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | close $fout; | |||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | 2 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||
| 1047 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||
| 1049 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||
| 1051 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||
| 1055 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | Bio::AutomatedAnnotation::Prokka - Prokka class for bacterial annotation | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||
| 1061 | version 1.182680 | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||
| 1063 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | Modified prokka from a command line script to a Moose class - Bacterial annotation done fast and NCBI compliant (mostly). | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | http://www.vicbioinformatics.com/software.prokka.shtml | ||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||
| 1068 | If you use Prokka in your work, please cite: | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | Seemann T (2012) | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | Prokka: Prokaryotic Genome Annotation System | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | http://vicbioinformatics.com/ | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||
| 1076 | Andrew J. Page <ap13@sanger.ac.uk> | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||
| 1078 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||
| 1080 | This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||
| 1082 | This is free software, licensed under: | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||
| 1084 | The GNU General Public License, Version 3, June 2007 | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||
| 1086 | =cut | ||||||||||||||||||||||||||||||||||||||||||