| 1 | package Bio::Tradis::Map; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # ABSTRACT: Perform mapping | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | ▶ | use Bio::Tradis::Parser::Fastq; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | has 'fastqfile' => ( is => 'rw', isa => 'Str', required => 1 ); | |||||||||||||||||||
| 10 | 2 | has 'reference' => ( is => 'rw', isa => 'Str', required => 1 ); | |||||||||||||||||||
| 11 | 2 | has 'refname' => | |||||||||||||||||||
| 12 | ( is => 'rw', isa => 'Str', required => 0, default => 'ref.index' ); | ||||||||||||||||||||
| 13 | 2 | has 'outfile' => | |||||||||||||||||||
| 14 | ( is => 'rw', isa => 'Str', required => 0, default => 'mapped.sam' ); | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | sub index_ref { | ||||||||||||||||||||
| 17 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
index_ref: called CC=4 SCAR=15.6
Pod
undocumented
| |||||||||||||||||||||
| 18 | 1 | my $ref = $self->reference; | |||||||||||||||||||
| 19 | 1 | my $refname = $self->refname; | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | # Calculate index parameters | ||||||||||||||||||||
| 22 | 1 | my $pars = Bio::Tradis::Parser::Fastq->new( file => $self->fastqfile ); | |||||||||||||||||||
| 23 | 1 | $pars->next_read; | |||||||||||||||||||
| 24 | 1 | my @read = $pars->read_info; | |||||||||||||||||||
| 25 | 1 | my ( $k, $s ); | |||||||||||||||||||
| 26 | 1 | ( $k, $s ) = ( 13, 4 ); | |||||||||||||||||||
| 27 | 1 | my $seq = $read[1]; | |||||||||||||||||||
| 28 | 1 | ▶ | if ( length($seq) < 70 ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 29 | 1 | ( $k, $s ) = ( 13, 4 ); | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | ▶ | elsif ( length($seq) > 70 && length($seq) < 100 ) { | |||||||||||||||||||
|
Condition0%0/3
length $seq > 70 and length $seq < 100
MC/DC0%0/2
length $seq > 70 and length $seq < 100
length $seq > 70
length $seq < 100
Truth table0%0/3
A and B
A= length $seq > 70B= length $seq < 100
| |||||||||||||||||||||
| 32 | 0 | ( $k, $s ) = ( 13, 6 ); | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | else { | ||||||||||||||||||||
| 35 | 0 | ( $k, $s ) = ( 20, 13 ); | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 1 | system("smalt index -k $k -s $s $refname $ref"); | |||||||||||||||||||
| 39 | 1 | return 1; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | sub do_mapping { | ||||||||||||||||||||
| 43 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
do_mapping: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 44 | 1 | my $fqfile = $self->fastqfile; | |||||||||||||||||||
| 45 | 1 | my $refname = $self->refname; | |||||||||||||||||||
| 46 | 1 | my $outfile = $self->outfile; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 1 | system("smalt map -x -r -1 -y 0.96 $refname $fqfile 1> $outfile 2> smalt.stderr"); | |||||||||||||||||||
| 49 | 1 | unlink('smalt.stderr'); | |||||||||||||||||||
| 50 | 1 | return 1; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 54 | 2 | ▶ | no Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 55 | 2 | 1; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | =pod | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =head1 NAME | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | Bio::Tradis::Map - Perform mapping | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =head1 VERSION | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | version 1.132190 | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =head1 SYNOPSIS | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | Takes a reference genome and indexes it. | ||||||||||||||||||||
| 72 | Maps given fastq files to ref. | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | use Bio::Tradis::Map; | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | my $pipeline = Bio::Tradis::Map->new(fastqfile => 'abc', reference => 'abc'); | ||||||||||||||||||||
| 77 | $pipeline->index_ref(); | ||||||||||||||||||||
| 78 | $pipeline->do_mapping(); | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =head1 PARAMETERS | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head2 Required | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | =over | ||||||||||||||||||||
| 85 | =item * C<fastqfile> - path to/name of file containing reads to map to the reference | ||||||||||||||||||||
| 86 | =item * C<reference> - path to/name of reference genome in fasta format (.fa) | ||||||||||||||||||||
| 87 | =back | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =head2 Optional | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =over | ||||||||||||||||||||
| 92 | =item * C<refname> - name to assign to the reference index files. Default = ref.index | ||||||||||||||||||||
| 93 | =item * C<outfile> - name to assign to the mapped SAM file. Default = mapped.sam | ||||||||||||||||||||
| 94 | =back | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | =head1 METHODS | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =over | ||||||||||||||||||||
| 99 | =item * C<index_ref> - create index files of the reference genome. These are required | ||||||||||||||||||||
| 100 | for the mapping step. Only skip this step if index files already | ||||||||||||||||||||
| 101 | exist. -k and -s options for referencing are calculated based | ||||||||||||||||||||
| 102 | on the length of the reads being mapped as per table: | ||||||||||||||||||||
| 103 | =begin html | ||||||||||||||||||||
| 104 | <table> | ||||||||||||||||||||
| 105 | <tr><th>Read length</th><th>k</th><th>s</th></tr> | ||||||||||||||||||||
| 106 | <tr><td><70</td><td>13</td><td>4<td></tr> | ||||||||||||||||||||
| 107 | <tr><td>>70 and <100</td><td>13</td><td>6<td></tr> | ||||||||||||||||||||
| 108 | <tr><td>>100</td><td>20</td><td>6<td></tr> | ||||||||||||||||||||
| 109 | </table> | ||||||||||||||||||||
| 110 | =end html | ||||||||||||||||||||
| 111 | =item * C<do_mapping> - map C<fastqfile> to C<reference>. Options used for mapping are: C<-r -1 -x -y 0.96> | ||||||||||||||||||||
| 112 | =back | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 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> | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | =head1 AUTHOR | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | Carla Cummins <cc21@sanger.ac.uk> | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | This is free software, licensed under: | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | The GNU General Public License, Version 3, June 2007 | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||