| 1 | package Bio::Tradis::Map; | ||||||||||||||
| 2 | 3 | $Bio::Tradis::Map::VERSION = '1.4.1'; | |||||||||||||
| 3 | # ABSTRACT: Perform mapping | ||||||||||||||
| 4 | |||||||||||||||
| 5 | |||||||||||||||
| 6 | 3 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 3 | ▶ | use Bio::Tradis::Parser::Fastq; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | 3 | has 'fastqfile' => ( is => 'rw', isa => 'Str', required => 1 ); | |||||||||||||
| 10 | 3 | has 'reference' => ( is => 'rw', isa => 'Str', required => 1 ); | |||||||||||||
| 11 | 3 | has 'refname' => | |||||||||||||
| 12 | ( is => 'rw', isa => 'Str', required => 0, default => 'ref.index' ); | ||||||||||||||
| 13 | 3 | has 'outfile' => | |||||||||||||
| 14 | ( is => 'rw', isa => 'Str', required => 0, default => 'mapped.sam' ); | ||||||||||||||
| 15 | 3 | has 'smalt_k' => ( is => 'rw', isa => 'Maybe[Int]', required => 0 ); | |||||||||||||
| 16 | 3 | has 'smalt_s' => ( is => 'rw', isa => 'Maybe[Int]', required => 0 ); | |||||||||||||
| 17 | 3 | has 'smalt_y' => ( is => 'rw', isa => 'Maybe[Num]', required => 0, default => 0.96 ); | |||||||||||||
| 18 | 3 | has 'smalt_r' => ( is => 'rw', isa => 'Maybe[Int]', required => 0, default => -1 ); | |||||||||||||
| 19 | 3 | has 'smalt_n' => ( is => 'rw', isa => 'Maybe[Int]', required => 0, default => 1 ); | |||||||||||||
| 20 | |||||||||||||||
| 21 | sub index_ref { | ||||||||||||||
| 22 | 4 | ▶ | my ($self) = @_; | ||||||||||||
|
Subroutine
index_ref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 23 | 4 | my $ref = $self->reference; | |||||||||||||
| 24 | 4 | my $refname = $self->refname; | |||||||||||||
| 25 | |||||||||||||||
| 26 | # Calculate index parameters | ||||||||||||||
| 27 | 4 | my $pars = Bio::Tradis::Parser::Fastq->new( file => $self->fastqfile ); | |||||||||||||
| 28 | 4 | $pars->next_read; | |||||||||||||
| 29 | 4 | my @read = $pars->read_info; | |||||||||||||
| 30 | 4 | my $read_len = length($read[1]); | |||||||||||||
| 31 | 4 | my ( $k, $s ) = $self->_calculate_index_parameters($read_len); | |||||||||||||
| 32 | |||||||||||||||
| 33 | 4 | my $cmd = "smalt index -k $k -s $s $refname $ref > /dev/null 2>&1"; | |||||||||||||
| 34 | 4 | system($cmd); | |||||||||||||
| 35 | 4 | return $cmd; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | sub _calculate_index_parameters { | ||||||||||||||
| 39 | 4 | ▶ | my ($self, $read_len) = @_; | ||||||||||||
|
Subroutine
_calculate_index_parameters: called CC=3 SCAR=11.0
| |||||||||||||||
| 40 | 4 | my ( $k, $s ); | |||||||||||||
| 41 | |||||||||||||||
| 42 | 4 | ▶ | if( defined $self->smalt_k ){ $k = $self->smalt_k; } | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 3 | else{ $k = $self->_smalt_k_default($read_len); } | |||||||||||||
| 44 | |||||||||||||||
| 45 | 4 | ▶ | if( defined $self->smalt_s ){ $s = $self->smalt_s; } | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | 3 | else{ $s = $self->_smalt_s_default($read_len); } | |||||||||||||
| 47 | |||||||||||||||
| 48 | 4 | return ( $k, $s ); | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | sub _smalt_k_default { | ||||||||||||||
| 52 | 3 | ▶ | my ($self, $read_len) = @_; | ||||||||||||
|
Subroutine
_smalt_k_default: called CC=2 SCAR=7.6
| |||||||||||||||
| 53 | 3 | ▶ | if($read_len < 100){ return 13; } | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 54 | 0 | else{ return 20; } | |||||||||||||
| 55 | } | ||||||||||||||
| 56 | |||||||||||||||
| 57 | sub _smalt_s_default { | ||||||||||||||
| 58 | 3 | ▶ | my ( $self, $read_len ) = @_; | ||||||||||||
|
Subroutine
_smalt_s_default: called CC=3 SCAR=15.1
| |||||||||||||||
| 59 | 3 | ▶ | if( $read_len < 70 ){ return 4; } | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 60 | 0 | elsif( $read_len > 100 ){ return 13; } | |||||||||||||
| 61 | 0 | else{ return 6; } | |||||||||||||
| 62 | } | ||||||||||||||
| 63 | |||||||||||||||
| 64 | sub do_mapping { | ||||||||||||||
| 65 | 4 | ▶ | my ($self) = @_; | ||||||||||||
|
Subroutine
do_mapping: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 66 | 4 | my $fqfile = $self->fastqfile; | |||||||||||||
| 67 | 4 | my $refname = $self->refname; | |||||||||||||
| 68 | 4 | my $outfile = $self->outfile; | |||||||||||||
| 69 | 4 | my $y = $self->smalt_y; | |||||||||||||
| 70 | 4 | my $r = $self->smalt_r; | |||||||||||||
| 71 | 4 | my $n = $self->smalt_n; | |||||||||||||
| 72 | |||||||||||||||
| 73 | 4 | my $smalt = "smalt map -n $n -x -r $r -y $y $refname $fqfile 1> $outfile 2> smalt.stderr"; | |||||||||||||
| 74 | |||||||||||||||
| 75 | 4 | system($smalt); | |||||||||||||
| 76 | 4 | unlink('smalt.stderr'); | |||||||||||||
| 77 | |||||||||||||||
| 78 | 4 | return $smalt; | |||||||||||||
| 79 | } | ||||||||||||||
| 80 | |||||||||||||||
| 81 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||||
| 82 | 3 | ▶ | no Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 83 | 3 | 1; | |||||||||||||
| 84 | |||||||||||||||
| 85 | __END__ | ||||||||||||||
| 86 | |||||||||||||||
| 87 | =pod | ||||||||||||||
| 88 | |||||||||||||||
| 89 | =encoding UTF-8 | ||||||||||||||
| 90 | |||||||||||||||
| 91 | =head1 NAME | ||||||||||||||
| 92 | |||||||||||||||
| 93 | Bio::Tradis::Map - Perform mapping | ||||||||||||||
| 94 | |||||||||||||||
| 95 | =head1 VERSION | ||||||||||||||
| 96 | |||||||||||||||
| 97 | version 1.4.1 | ||||||||||||||
| 98 | |||||||||||||||
| 99 | =head1 SYNOPSIS | ||||||||||||||
| 100 | |||||||||||||||
| 101 | Takes a reference genome and indexes it. | ||||||||||||||
| 102 | Maps given fastq files to ref. | ||||||||||||||
| 103 | |||||||||||||||
| 104 | use Bio::Tradis::Map; | ||||||||||||||
| 105 | |||||||||||||||
| 106 | my $pipeline = Bio::Tradis::Map->new(fastqfile => 'abc', reference => 'abc'); | ||||||||||||||
| 107 | $pipeline->index_ref(); | ||||||||||||||
| 108 | $pipeline->do_mapping(); | ||||||||||||||
| 109 | |||||||||||||||
| 110 | =head1 PARAMETERS | ||||||||||||||
| 111 | |||||||||||||||
| 112 | =head2 Required | ||||||||||||||
| 113 | |||||||||||||||
| 114 | =over | ||||||||||||||
| 115 | |||||||||||||||
| 116 | =item * C<fastqfile> - path to/name of file containing reads to map to the reference | ||||||||||||||
| 117 | |||||||||||||||
| 118 | =item * C<reference> - path to/name of reference genome in fasta format (.fa) | ||||||||||||||
| 119 | |||||||||||||||
| 120 | =back | ||||||||||||||
| 121 | |||||||||||||||
| 122 | =head2 Optional | ||||||||||||||
| 123 | |||||||||||||||
| 124 | =over | ||||||||||||||
| 125 | |||||||||||||||
| 126 | =item * C<refname> - name to assign to the reference index files. Default = ref.index | ||||||||||||||
| 127 | |||||||||||||||
| 128 | =item * C<outfile> - name to assign to the mapped SAM file. Default = mapped.sam | ||||||||||||||
| 129 | |||||||||||||||
| 130 | =back | ||||||||||||||
| 131 | |||||||||||||||
| 132 | =head1 METHODS | ||||||||||||||
| 133 | |||||||||||||||
| 134 | =over | ||||||||||||||
| 135 | |||||||||||||||
| 136 | =item * C<index_ref> - create index files of the reference genome. These are required | ||||||||||||||
| 137 | for the mapping step. Only skip this step if index files already | ||||||||||||||
| 138 | exist. -k and -s options for referencing are calculated based | ||||||||||||||
| 139 | on the length of the reads being mapped as per table: | ||||||||||||||
| 140 | |||||||||||||||
| 141 | =for html <table> | ||||||||||||||
| 142 | <tr><th>Read length</th><th>k</th><th>s</th></tr> | ||||||||||||||
| 143 | <tr><td><70</td><td>13</td><td>4<td></tr> | ||||||||||||||
| 144 | <tr><td>>70 and <100</td><td>13</td><td>6<td></tr> | ||||||||||||||
| 145 | <tr><td>>100</td><td>20</td><td>6<td></tr> | ||||||||||||||
| 146 | </table> | ||||||||||||||
| 147 | |||||||||||||||
| 148 | =item * C<do_mapping> - map C<fastqfile> to C<reference>. Options used for mapping are: C<-r -1 -x -y 0.96> | ||||||||||||||
| 149 | |||||||||||||||
| 150 | =back | ||||||||||||||
| 151 | |||||||||||||||
| 152 | For more information on the mapping and indexing options discussed here, see the L<SMALT manual|ftp://ftp.sanger.ac.uk/pub4/resources/software/smalt/smalt-manual-0.7.4.pdf> | ||||||||||||||
| 153 | |||||||||||||||
| 154 | =head1 AUTHOR | ||||||||||||||
| 155 | |||||||||||||||
| 156 | Carla Cummins <path-help@sanger.ac.uk> | ||||||||||||||
| 157 | |||||||||||||||
| 158 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||
| 159 | |||||||||||||||
| 160 | This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. | ||||||||||||||
| 161 | |||||||||||||||
| 162 | This is free software, licensed under: | ||||||||||||||
| 163 | |||||||||||||||
| 164 | The GNU General Public License, Version 3, June 2007 | ||||||||||||||
| 165 | |||||||||||||||
| 166 | =cut | ||||||||||||||