| 1 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | Bio::SeqIO::mbsout - input stream for output by Teshima et al.'s mbs. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Do not use this module directly. Use it via the Bio::SeqIO class. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | mbs (Teshima KM, Innan H (2009) mbs: modifying Hudson's ms software to generate | ||||||||||||||||||||||||||||
| 14 | samples of DNA sequences with a biallelic site under selection. BMC | ||||||||||||||||||||||||||||
| 15 | Bioinformatics 10: 166 ) can be found at | ||||||||||||||||||||||||||||
| 16 | http://www.biomedcentral.com/1471-2105/10/166/additional/. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | Currently this object can be used to read output from mbs into seq objects. | ||||||||||||||||||||||||||||
| 19 | However, because bioperl has no support for haplotypes created using an infinite | ||||||||||||||||||||||||||||
| 20 | sites model (where '1' identifies a derived allele and '0' identifies an | ||||||||||||||||||||||||||||
| 21 | ancestral allele), the sequences returned by mbsout are coded using A, T, C and | ||||||||||||||||||||||||||||
| 22 | G. To decode the bases, use the sequence conversion table (a hash) returned by | ||||||||||||||||||||||||||||
| 23 | get_base_conversion_table(). In the table, 4 and 5 are used when the ancestry is | ||||||||||||||||||||||||||||
| 24 | unclear. This should not ever happen when creating files with mbs, but it will | ||||||||||||||||||||||||||||
| 25 | be used when creating mbsOUT files from a collection of seq objects ( To be | ||||||||||||||||||||||||||||
| 26 | added later ). Alternatively, use get_next_hap() to get a string with 1's and | ||||||||||||||||||||||||||||
| 27 | 0's instead of a seq object. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||
| 34 | Bioperl modules. Send your comments and suggestions preferably to the | ||||||||||||||||||||||||||||
| 35 | Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 38 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 43 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||
| 44 | web: | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 AUTHOR - Warren Kretzschmar | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | This module was written by Warren Kretzschmar | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | email: wkretzsch@gmail.com | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | This module grew out of a parser written by Aida Andres. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =head2 Public Domain Notice | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | This software/database is ``United States Government Work'' under the | ||||||||||||||||||||||||||||
| 61 | terms of the United States Copyright Act. It was written as part of | ||||||||||||||||||||||||||||
| 62 | the authors' official duties for the United States Government and thus | ||||||||||||||||||||||||||||
| 63 | cannot be copyrighted. This software/database is freely available to | ||||||||||||||||||||||||||||
| 64 | the public for use without a copyright notice. Restrictions cannot | ||||||||||||||||||||||||||||
| 65 | be placed on its present or future use. | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | Although all reasonable efforts have been taken to ensure the accuracy | ||||||||||||||||||||||||||||
| 68 | and reliability of the software and data, the National Human Genome | ||||||||||||||||||||||||||||
| 69 | Research Institute (NHGRI) and the U.S. Government does not and cannot | ||||||||||||||||||||||||||||
| 70 | warrant the performance or results that may be obtained by using this | ||||||||||||||||||||||||||||
| 71 | software or data. NHGRI and the U.S. Government disclaims all | ||||||||||||||||||||||||||||
| 72 | warranties as to performance, merchantability or fitness for any | ||||||||||||||||||||||||||||
| 73 | particular purpose. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head1 METHODS | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | package Bio::SeqIO::mbsout; | ||||||||||||||||||||||||||||
| 80 | 2 | $Bio::SeqIO::mbsout::VERSION = '1.7.8'; | |||||||||||||||||||||||||||
| 81 | 2 | ▶ | use version; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 82 | 2 | our $API_VERSION = qv('1.1.3'); | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | 2 | ▶ | use base qw(Bio::SeqIO); # This ISA Bio::SeqIO object | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 86 | 2 | ▶ | use Bio::Seq::SeqFactory; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head2 INTERNAL METHODS | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head3 _initialize | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Title : _initialize | ||||||||||||||||||||||||||||
| 93 | Usage : $stream = Bio::SeqIO::mbsout->new($infile) | ||||||||||||||||||||||||||||
| 94 | Function: extracts basic information about the file. | ||||||||||||||||||||||||||||
| 95 | Returns : Bio::SeqIO object | ||||||||||||||||||||||||||||
| 96 | Args : no_og | ||||||||||||||||||||||||||||
| 97 | Details : include 'no_og' flag = 0 if the last population of an mbsout file | ||||||||||||||||||||||||||||
| 98 | contains only one haplotype and you want the last haplotype to be | ||||||||||||||||||||||||||||
| 99 | treated as the outgroup. | ||||||||||||||||||||||||||||
| 100 | =cut | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 3 | ▶ | sub _initialize { | ||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=5 SCAR=16.6
| |||||||||||||||||||||||||||||
| 103 | 3 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 104 | 3 | $self->SUPER::_initialize(@args); | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 3 | ▶ | unless ( defined $self->sequence_factory ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 3 | $self->sequence_factory( Bio::Seq::SeqFactory->new() ); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | # Don't expect mbs to create an outgroup | ||||||||||||||||||||||||||||
| 111 | 3 | ▶ | my ($no_og) = $self->_rearrange( [qw(NO_OG)], @args ) || 1; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->_rearrange(['NO_OG'], @args) || 1
MC/DC0%0/1
$self->_rearrange(['NO_OG'], @args) || 1
$self->_rearrange(['NO_OG'], @args)
Truth table50%1/2
A
A= $self->_rearrange(['NO_OG'], @args)
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 3 | my %initial_values = ( | |||||||||||||||||||||||||||
| 114 | RUNS => undef, | ||||||||||||||||||||||||||||
| 115 | SEGSITES => undef, | ||||||||||||||||||||||||||||
| 116 | MBS_INFO_LINE => undef, | ||||||||||||||||||||||||||||
| 117 | TOT_RUN_HAPS => undef, | ||||||||||||||||||||||||||||
| 118 | NEXT_RUN_NUM => undef, # What run is the next hap from? undef = EOF | ||||||||||||||||||||||||||||
| 119 | LAST_READ_HAP_NUM => undef, # What did we just read from | ||||||||||||||||||||||||||||
| 120 | LAST_READ_POSITIONS => [], | ||||||||||||||||||||||||||||
| 121 | LAST_READ_SEGSITES => undef, | ||||||||||||||||||||||||||||
| 122 | BUFFER_HAP => undef, | ||||||||||||||||||||||||||||
| 123 | NO_OUTGROUP => $no_og, | ||||||||||||||||||||||||||||
| 124 | OPTIONS => {}, | ||||||||||||||||||||||||||||
| 125 | LAST_READ_ALLELES => [], | ||||||||||||||||||||||||||||
| 126 | LAST_READ_TRAJECTORY_FILE => undef, | ||||||||||||||||||||||||||||
| 127 | LAST_READ_REPLICATION_OF_TRAJECTORY_FILE => undef, | ||||||||||||||||||||||||||||
| 128 | BASE_CONVERSION_TABLE_HASH_REF => { | ||||||||||||||||||||||||||||
| 129 | 'A' => 0, | ||||||||||||||||||||||||||||
| 130 | 'T' => 1, | ||||||||||||||||||||||||||||
| 131 | 'C' => 4, | ||||||||||||||||||||||||||||
| 132 | 'G' => 5, | ||||||||||||||||||||||||||||
| 133 | }, | ||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 3 | foreach my $key ( keys %initial_values ) { | |||||||||||||||||||||||||||
| 137 | 45 | $self->{$key} = $initial_values{$key}; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | # If the filehandle is defined open it and read a few lines | ||||||||||||||||||||||||||||
| 141 | 3 | ▶ | if ( ref( $self->{_filehandle} ) eq 'GLOB' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 3 | $self->_read_start(); | |||||||||||||||||||||||||||
| 143 | 3 | return $self; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | # Otherwise throw a warning | ||||||||||||||||||||||||||||
| 147 | else { | ||||||||||||||||||||||||||||
| 148 | 0 | $self->throw( | |||||||||||||||||||||||||||
| 149 | "No filehandle defined. Please define a file handle through -file when calling mbsout with Bio::SeqIO" | ||||||||||||||||||||||||||||
| 150 | ); | ||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =head3 _read_start | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | Title : _read_start | ||||||||||||||||||||||||||||
| 157 | Usage : $stream->_read_start() | ||||||||||||||||||||||||||||
| 158 | Function: reads from the filehandle $stream->{_filehandle} all information up to the first haplotype (sequence). | ||||||||||||||||||||||||||||
| 159 | Returns : void | ||||||||||||||||||||||||||||
| 160 | Args : none | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =cut | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 3 | ▶ | sub _read_start { | ||||||||||||||||||||||||||
|
Subroutine
_read_start: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 165 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 3 | my $fh_IN = $self->{_filehandle}; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # get the first five lines and parse for important info | ||||||||||||||||||||||||||||
| 170 | 3 | my ($mbs_info_line) = $self->_get_next_clean_hap( $fh_IN, 1, 1 ); | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 3 | my @mbs_info_line = split( /\s+/, $mbs_info_line ); | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | # Parsing the mbs header line | ||||||||||||||||||||||||||||
| 175 | 3 | shift @mbs_info_line; | |||||||||||||||||||||||||||
| 176 | 3 | shift @mbs_info_line; | |||||||||||||||||||||||||||
| 177 | 3 | my $tot_run_haps = shift @mbs_info_line; | |||||||||||||||||||||||||||
| 178 | 3 | my $runs; | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | # $pop_mut_param_per_site is the population mutation parameter per site. | ||||||||||||||||||||||||||||
| 181 | my $pop_mut_param_per_site; | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | # $pop_recomb_param_per_site is the population recombination parameter per | ||||||||||||||||||||||||||||
| 184 | # site. | ||||||||||||||||||||||||||||
| 185 | 3 | my $pop_recomb_param_per_site; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | # $nsites is length of the simulated region. | ||||||||||||||||||||||||||||
| 188 | # $selpos is position of the target site of selection relative to the first | ||||||||||||||||||||||||||||
| 189 | # site of the simulated region. | ||||||||||||||||||||||||||||
| 190 | 3 | my $nsites; | |||||||||||||||||||||||||||
| 191 | 3 | my $selpos; | |||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | # $nfile is number of trajectory files. | ||||||||||||||||||||||||||||
| 194 | # $nrep is number of replications for each trajectory. | ||||||||||||||||||||||||||||
| 195 | # $traj_filename is initial part of the name of the trajectory files. | ||||||||||||||||||||||||||||
| 196 | 3 | my $nfiles; | |||||||||||||||||||||||||||
| 197 | 3 | my $nreps; | |||||||||||||||||||||||||||
| 198 | 3 | my $traj_filename; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 3 | foreach my $word ( 0 .. $#mbs_info_line ) { | |||||||||||||||||||||||||||
| 201 | 33 | ▶ | if ( $mbs_info_line[$word] eq '-t' ) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 202 | 3 | $pop_mut_param_per_site = $mbs_info_line[ $word + 1 ]; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | elsif ( $mbs_info_line[$word] eq '-r' ) { | ||||||||||||||||||||||||||||
| 205 | 3 | $pop_recomb_param_per_site = $mbs_info_line[ $word + 1 ]; | |||||||||||||||||||||||||||
| 206 | 3 | $selpos = $mbs_info_line[ $word + 2 ]; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | elsif ( $mbs_info_line[$word] eq '-s' ) { | ||||||||||||||||||||||||||||
| 209 | 3 | $nsites = $mbs_info_line[ $word + 1 ]; | |||||||||||||||||||||||||||
| 210 | 3 | $selpos = $mbs_info_line[ $word + 2 ]; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | elsif ( $mbs_info_line[$word] eq '-f' ) { | ||||||||||||||||||||||||||||
| 213 | 3 | $nfiles = $mbs_info_line[ $word + 1 ]; | |||||||||||||||||||||||||||
| 214 | 3 | $nreps = $mbs_info_line[ $word + 2 ]; | |||||||||||||||||||||||||||
| 215 | 3 | $traj_filename = $mbs_info_line[ $word + 3 ]; | |||||||||||||||||||||||||||
| 216 | 3 | $runs = $nfiles * $nreps; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | 21 | else { next; } | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | # Save mbs info data | ||||||||||||||||||||||||||||
| 222 | 3 | $self->{RUNS} = $runs; | |||||||||||||||||||||||||||
| 223 | 3 | $self->{MBS_INFO_LINE} = $mbs_info_line; | |||||||||||||||||||||||||||
| 224 | 3 | $self->{TOT_RUN_HAPS} = $tot_run_haps; | |||||||||||||||||||||||||||
| 225 | 3 | $self->{POP_MUT_PARAM_PER_SITE} = $pop_mut_param_per_site; | |||||||||||||||||||||||||||
| 226 | 3 | $self->{POP_RECOMB_PARAM_PER_SITE} = $pop_recomb_param_per_site; | |||||||||||||||||||||||||||
| 227 | 3 | $self->{NSITES} = $nsites; | |||||||||||||||||||||||||||
| 228 | 3 | $self->{SELPOS} = $selpos; | |||||||||||||||||||||||||||
| 229 | 3 | $self->{NFILES} = $nfiles; | |||||||||||||||||||||||||||
| 230 | 3 | $self->{NREPS} = $nreps; | |||||||||||||||||||||||||||
| 231 | 3 | $self->{TRAJ_FILENAME} = $traj_filename; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | =head2 Methods to retrieve mbsout data | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | =head3 get_segsites | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | Title : get_segsites | ||||||||||||||||||||||||||||
| 239 | Usage : $segsites = $stream->get_segsites() | ||||||||||||||||||||||||||||
| 240 | Function: returns the number segsites in the mbsout file (according to the mbsout header line). | ||||||||||||||||||||||||||||
| 241 | Returns : scalar | ||||||||||||||||||||||||||||
| 242 | Args : NONE | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | =cut | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 3 | ▶ | sub get_segsites { | ||||||||||||||||||||||||||
|
Subroutine
get_segsites: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 247 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 248 | 3 | ▶ | if ( defined $self->{SEGSITES} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 0 | return $self->{SEGSITES}; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | else { | ||||||||||||||||||||||||||||
| 252 | 3 | return $self->get_current_run_segsites; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | =head3 get_current_run_segsites | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | Title : get_current_run_segsites | ||||||||||||||||||||||||||||
| 259 | Usage : $segsites = $stream->get_current_run_segsites() | ||||||||||||||||||||||||||||
| 260 | Function: returns the number of segsites in the run of the last read haplotype (sequence). | ||||||||||||||||||||||||||||
| 261 | Returns : scalar | ||||||||||||||||||||||||||||
| 262 | Args : NONE | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =cut | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 48 | ▶ | sub get_current_run_segsites { | ||||||||||||||||||||||||||
|
Subroutine
get_current_run_segsites: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 267 | 48 | my $self = shift; | |||||||||||||||||||||||||||
| 268 | 48 | return $self->{LAST_READ_SEGSITES}; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | =head3 get_pop_mut_param_per_site | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | Title : get_pop_mut_param_per_site | ||||||||||||||||||||||||||||
| 274 | Usage : $pop_mut_param_per_site = $stream->get_pop_mut_param_per_site() | ||||||||||||||||||||||||||||
| 275 | Function: returns 4*N0*mu or the "population mutation parameter per site" | ||||||||||||||||||||||||||||
| 276 | Returns : scalar | ||||||||||||||||||||||||||||
| 277 | Args : NONE | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =cut | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 3 | ▶ | sub get_pop_mut_param_per_site { | ||||||||||||||||||||||||||
|
Subroutine
get_pop_mut_param_per_site: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 282 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 283 | 3 | return $self->{POP_MUT_PARAM_PER_SITE}; | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | =head3 get_pop_recomb_param_per_site | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | Title : get_pop_recomb_param_per_site | ||||||||||||||||||||||||||||
| 289 | Usage : $pop_recomb_param_per_site = $stream->get_pop_recomb_param_per_site() | ||||||||||||||||||||||||||||
| 290 | Function: returns 4*N0*r or the "population recombination parameter per site" | ||||||||||||||||||||||||||||
| 291 | Returns : scalar | ||||||||||||||||||||||||||||
| 292 | Args : NONE | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | =cut | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 3 | ▶ | sub get_pop_recomb_param_per_site { | ||||||||||||||||||||||||||
|
Subroutine
get_pop_recomb_param_per_site: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 297 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 298 | 3 | return $self->{POP_RECOMB_PARAM_PER_SITE}; | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =head3 get_nsites | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | Title : get_nsites | ||||||||||||||||||||||||||||
| 304 | Usage : $nsites = $stream->get_nsites() | ||||||||||||||||||||||||||||
| 305 | Function: returns the number of sites simulated by mbs. | ||||||||||||||||||||||||||||
| 306 | Returns : scalar | ||||||||||||||||||||||||||||
| 307 | Args : NONE | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =cut | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 3 | ▶ | sub get_nsites { | ||||||||||||||||||||||||||
|
Subroutine
get_nsites: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 312 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 313 | 3 | return $self->{NSITES}; | |||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | =head3 get_selpos | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | Title : get_selpos | ||||||||||||||||||||||||||||
| 319 | Usage : $selpos = $stream->get_selpos() | ||||||||||||||||||||||||||||
| 320 | Function: returns the location on the chromosome where the allele is located that was selected for by mbs. | ||||||||||||||||||||||||||||
| 321 | Returns : scalar | ||||||||||||||||||||||||||||
| 322 | Args : NONE | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | =cut | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 3 | ▶ | sub get_selpos { | ||||||||||||||||||||||||||
|
Subroutine
get_selpos: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 327 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 328 | 3 | return $self->{SELPOS}; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | =head3 get_nreps | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | Title : get_nreps | ||||||||||||||||||||||||||||
| 334 | Usage : $nreps = $stream->get_nreps() | ||||||||||||||||||||||||||||
| 335 | Function: returns the number replications done by mbs on each trajectory file to create the mbsout file. | ||||||||||||||||||||||||||||
| 336 | Returns : scalar | ||||||||||||||||||||||||||||
| 337 | Args : NONE | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | =cut | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 3 | ▶ | sub get_nreps { | ||||||||||||||||||||||||||
|
Subroutine
get_nreps: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 342 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 343 | 3 | return $self->{NREPS}; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =head3 get_nfiles | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | Title : get_nfiles | ||||||||||||||||||||||||||||
| 349 | Usage : $nfiles = $stream->get_nfiles() | ||||||||||||||||||||||||||||
| 350 | Function: returns the number of trajectory files used by mbs to create the mbsout file | ||||||||||||||||||||||||||||
| 351 | Returns : scalar | ||||||||||||||||||||||||||||
| 352 | Args : NONE | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | =cut | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 3 | ▶ | sub get_nfiles { | ||||||||||||||||||||||||||
|
Subroutine
get_nfiles: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 357 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 358 | 3 | return $self->{NFILES}; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =head3 get_traj_filename | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | Title : get_traj_filename | ||||||||||||||||||||||||||||
| 364 | Usage : $traj_filename = $stream->get_traj_filename() | ||||||||||||||||||||||||||||
| 365 | Function: returns the prefix of the trajectory files used by mbs to create the mbsout file | ||||||||||||||||||||||||||||
| 366 | Returns : scalar | ||||||||||||||||||||||||||||
| 367 | Args : NONE | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | =cut | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 3 | ▶ | sub get_traj_filename { | ||||||||||||||||||||||||||
|
Subroutine
get_traj_filename: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 372 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 373 | 3 | return $self->{TRAJ_FILENAME}; | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =head3 get_runs | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | Title : get_runs | ||||||||||||||||||||||||||||
| 379 | Usage : $runs = $stream->get_runs() | ||||||||||||||||||||||||||||
| 380 | Function: returns the number of runs in the mbsout file | ||||||||||||||||||||||||||||
| 381 | Returns : scalar | ||||||||||||||||||||||||||||
| 382 | Args : NONE | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | =cut | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 3 | ▶ | sub get_runs { | ||||||||||||||||||||||||||
|
Subroutine
get_runs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 387 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 388 | 3 | return $self->{RUNS}; | |||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | =head3 get_Positions | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | Title : get_Positions | ||||||||||||||||||||||||||||
| 394 | Usage : @positions = $stream->get_Positions() | ||||||||||||||||||||||||||||
| 395 | Function: returns an array of the names of each segsite of the run of the last read hap. | ||||||||||||||||||||||||||||
| 396 | Returns : array | ||||||||||||||||||||||||||||
| 397 | Args : NONE | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | =cut | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 3 | ▶ | sub get_Positions { | ||||||||||||||||||||||||||
|
Subroutine
get_Positions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 402 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 403 | 3 | return @{ $self->{LAST_READ_POSITIONS} }; | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | =head3 get_tot_run_haps | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | Title : get_tot_run_haps | ||||||||||||||||||||||||||||
| 409 | Usage : $number_of_haps_per_run = $stream->get_tot_run_haps() | ||||||||||||||||||||||||||||
| 410 | Function: returns the number of haplotypes (sequences) in each run of the mbsout file. | ||||||||||||||||||||||||||||
| 411 | Returns : scalar >= 0 | ||||||||||||||||||||||||||||
| 412 | Args : NONE | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | =cut | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 3 | ▶ | sub get_tot_run_haps { | ||||||||||||||||||||||||||
|
Subroutine
get_tot_run_haps: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 417 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 418 | 3 | return $self->{TOT_RUN_HAPS}; | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | =head3 get_mbs_info_line | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | Title : get_mbs_info_line | ||||||||||||||||||||||||||||
| 424 | Usage : $mbs_info_line = $stream->get_mbs_info_line() | ||||||||||||||||||||||||||||
| 425 | Function: returns the header line of the mbsout file. | ||||||||||||||||||||||||||||
| 426 | Returns : scalar | ||||||||||||||||||||||||||||
| 427 | Args : NONE | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | =cut | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 3 | ▶ | sub get_mbs_info_line { | ||||||||||||||||||||||||||
|
Subroutine
get_mbs_info_line: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 432 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 433 | 3 | return $self->{MBS_INFO_LINE}; | |||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | =head3 tot_haps | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | Title : tot_haps | ||||||||||||||||||||||||||||
| 439 | Usage : $number_of_haplotypes_in_file = $stream->tot_haps() | ||||||||||||||||||||||||||||
| 440 | Function: returns the number of haplotypes (sequences) in the mbsout file. Information gathered from mbsout header line. | ||||||||||||||||||||||||||||
| 441 | Returns : scalar | ||||||||||||||||||||||||||||
| 442 | Args : NONE | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =cut | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | 0 | ▶ | sub get_tot_haps { | ||||||||||||||||||||||||||
|
Subroutine
get_tot_haps: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 447 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 448 | 0 | return ( $self->{TOT_RUN_HAPS} * $self->{RUNS} ); | |||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | =head3 next_run_num | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | Title : next_run_num | ||||||||||||||||||||||||||||
| 454 | Usage : $next_run_number = $stream->next_run_num() | ||||||||||||||||||||||||||||
| 455 | Function: returns the number of the mbs run that the next haplotype (sequence) | ||||||||||||||||||||||||||||
| 456 | will be taken from (starting at 1). Returns undef if the complete | ||||||||||||||||||||||||||||
| 457 | file has been read. | ||||||||||||||||||||||||||||
| 458 | Returns : scalar > 0 or undef | ||||||||||||||||||||||||||||
| 459 | Args : NONE | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =cut | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 53 | ▶ | sub get_next_run_num { | ||||||||||||||||||||||||||
|
Subroutine
get_next_run_num: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 464 | 53 | my $self = shift; | |||||||||||||||||||||||||||
| 465 | 53 | return $self->{NEXT_RUN_NUM}; | |||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | =head3 get_last_haps_run_num | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | Title : get_last_haps_run_num | ||||||||||||||||||||||||||||
| 471 | Usage : $last_haps_run_number = $stream->get_last_haps_run_num() | ||||||||||||||||||||||||||||
| 472 | Function: returns the number of the ms run that the last haplotype (sequence) | ||||||||||||||||||||||||||||
| 473 | was taken from (starting at 1). Returns undef if no hap has been | ||||||||||||||||||||||||||||
| 474 | read yet. | ||||||||||||||||||||||||||||
| 475 | Returns : scalar > 0 or undef | ||||||||||||||||||||||||||||
| 476 | Args : NONE | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | =cut | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 42 | ▶ | sub get_last_haps_run_num { | ||||||||||||||||||||||||||
|
Subroutine
get_last_haps_run_num: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 481 | 42 | my $self = shift; | |||||||||||||||||||||||||||
| 482 | 42 | return $self->{LAST_HAPS_RUN_NUM}; | |||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =head3 get_last_read_hap_num | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | Title : get_last_read_hap_num | ||||||||||||||||||||||||||||
| 488 | Usage : $last_read_hap_num = $stream->get_last_read_hap_num() | ||||||||||||||||||||||||||||
| 489 | Function: returns the number (starting with 1) of the last haplotype | ||||||||||||||||||||||||||||
| 490 | read from the mbs file | ||||||||||||||||||||||||||||
| 491 | Returns : scalar >= 0 | ||||||||||||||||||||||||||||
| 492 | Args : NONE | ||||||||||||||||||||||||||||
| 493 | Details : 0 means that no haplotype has been read yet. | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =cut | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | 45 | ▶ | sub get_last_read_hap_num { | ||||||||||||||||||||||||||
|
Subroutine
get_last_read_hap_num: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 498 | 45 | my $self = shift; | |||||||||||||||||||||||||||
| 499 | 45 | return $self->{LAST_READ_HAP_NUM}; | |||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | =head3 outgroup | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | Title : outgroup | ||||||||||||||||||||||||||||
| 505 | Usage : $outgroup = $stream->outgroup() | ||||||||||||||||||||||||||||
| 506 | Function: returns '1' if the mbsout object has an outgroup. Returns '0' | ||||||||||||||||||||||||||||
| 507 | otherwise. | ||||||||||||||||||||||||||||
| 508 | Returns : 1 or 0, currently always 0 | ||||||||||||||||||||||||||||
| 509 | Args : NONE | ||||||||||||||||||||||||||||
| 510 | Details : This method will return '1' only if the last population in the mbsout | ||||||||||||||||||||||||||||
| 511 | file contains only one haplotype. If the last population is not an | ||||||||||||||||||||||||||||
| 512 | outgroup then create the mbsout object using 'no_outgroup' as input | ||||||||||||||||||||||||||||
| 513 | parameter for new() (see mbsout->new()). | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | Currently there exists no way of introducing an outgroup into an mbs | ||||||||||||||||||||||||||||
| 516 | file, so this function will always return '0'. | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | =cut | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | 1 | ▶ | sub outgroup { | ||||||||||||||||||||||||||
|
Subroutine
outgroup: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 521 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 522 | 1 | ▶ | if ( $self->{NO_OUTGROUP} ) { return 0; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 523 | 0 | else { return 0; } | |||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | =head3 get_next_seq | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | Title : get_next_seq | ||||||||||||||||||||||||||||
| 529 | Usage : $seq = $stream->get_next_seq() | ||||||||||||||||||||||||||||
| 530 | Function: reads and returns the next sequence (haplotype) in the stream | ||||||||||||||||||||||||||||
| 531 | Returns : Bio::Seq object | ||||||||||||||||||||||||||||
| 532 | Args : NONE | ||||||||||||||||||||||||||||
| 533 | Note : This function is included only to conform to convention. It only | ||||||||||||||||||||||||||||
| 534 | calls next_hap() and passes on that method's return value. Use | ||||||||||||||||||||||||||||
| 535 | next_hap() instead for better performance. | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | =cut | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | 43 | ▶ | sub get_next_seq { | ||||||||||||||||||||||||||
|
Subroutine
get_next_seq: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 540 | 43 | my $self = shift; | |||||||||||||||||||||||||||
| 541 | 43 | my $seqstring = $self->get_next_hap; | |||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | 43 | ▶ | return unless defined $seqstring; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | # Used to create unique ID; | ||||||||||||||||||||||||||||
| 546 | 42 | my $run = $self->get_last_haps_run_num; | |||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | # Converting numbers to letters so that the haplotypes can be stored as a | ||||||||||||||||||||||||||||
| 549 | # seq object | ||||||||||||||||||||||||||||
| 550 | 42 | my $rh_base_conversion_table = $self->get_base_conversion_table; | |||||||||||||||||||||||||||
| 551 | 42 | foreach my $base ( keys %{$rh_base_conversion_table} ) { | |||||||||||||||||||||||||||
| 552 | 168 | $seqstring =~ s/($rh_base_conversion_table->{$base})/$base/g; | |||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | 42 | my $last_read_hap = $self->get_last_read_hap_num; | |||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | 42 | my $id = 'Hap_' . $last_read_hap . '_Run_' . $run; | |||||||||||||||||||||||||||
| 558 | 42 | my $description = | |||||||||||||||||||||||||||
| 559 | 'Segsites ' | ||||||||||||||||||||||||||||
| 560 | . $self->get_current_run_segsites | ||||||||||||||||||||||||||||
| 561 | . "; Positions $self->positions; Haplotype " | ||||||||||||||||||||||||||||
| 562 | . $last_read_hap | ||||||||||||||||||||||||||||
| 563 | . '; Run ' | ||||||||||||||||||||||||||||
| 564 | . $run . ';'; | ||||||||||||||||||||||||||||
| 565 | 42 | my $seq = $self->sequence_factory->create( | |||||||||||||||||||||||||||
| 566 | -seq => $seqstring, | ||||||||||||||||||||||||||||
| 567 | -id => $id, | ||||||||||||||||||||||||||||
| 568 | -desc => $description, | ||||||||||||||||||||||||||||
| 569 | -alphabet => q(dna), | ||||||||||||||||||||||||||||
| 570 | -direct => 1, | ||||||||||||||||||||||||||||
| 571 | ); | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | 42 | return $seq; | |||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | =head3 get_next_hap | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | Title : get_next_hap | ||||||||||||||||||||||||||||
| 580 | Usage : $seq = $stream->get_next_hap() | ||||||||||||||||||||||||||||
| 581 | Function: reads and returns the next sequence (haplotype) in the stream. Returns | ||||||||||||||||||||||||||||
| 582 | void if all sequences in stream have been read. | ||||||||||||||||||||||||||||
| 583 | Returns : Bio::Seq object | ||||||||||||||||||||||||||||
| 584 | Args : NONE | ||||||||||||||||||||||||||||
| 585 | Note : Use this instead of get_next_seq(). | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | =cut | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | 47 | ▶ | sub get_next_hap { | ||||||||||||||||||||||||||
|
Subroutine
get_next_hap: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 590 | 47 | my $self = shift; | |||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | # Let's figure out how many haps to read from the input file so that | ||||||||||||||||||||||||||||
| 593 | # we get back to the beginning of the next run. | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | 47 | my $end_run = 0; | |||||||||||||||||||||||||||
| 596 | 47 | ▶ | if ( $self->{TOT_RUN_HAPS} == $self->{LAST_READ_HAP_NUM} + 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 597 | 8 | $end_run = 1; | |||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | # Setting last_haps_run_num | ||||||||||||||||||||||||||||
| 601 | 47 | $self->{LAST_HAPS_RUN_NUM} = $self->get_next_run_num; | |||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | 47 | my $fh_IN = $self->{_filehandle}; | |||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | my ($seqstring) = | ||||||||||||||||||||||||||||
| 606 | 47 | $self->_get_next_clean_hap( $self->{_filehandle}, 1, $end_run ); | |||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | 47 | return $seqstring; | |||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | =head3 get_next_run | ||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||
| 613 | Title : get_next_run | ||||||||||||||||||||||||||||
| 614 | Usage : @seqs = $stream->get_next_run() | ||||||||||||||||||||||||||||
| 615 | Function: reads and returns all the remaining sequences (haplotypes) in the mbs | ||||||||||||||||||||||||||||
| 616 | run of the next sequence. | ||||||||||||||||||||||||||||
| 617 | Returns : array of Bio::Seq objects | ||||||||||||||||||||||||||||
| 618 | Args : NONE | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | =cut | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 9 | ▶ | sub get_next_run { | ||||||||||||||||||||||||||
|
Subroutine
get_next_run: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 623 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | # Let's figure out how many haps to read from the input file so that | ||||||||||||||||||||||||||||
| 626 | # we get back to the beginning of the next run. | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | 9 | my $haps_to_pull = $self->{TOT_RUN_HAPS} - $self->{LAST_READ_HAP_NUM}; | |||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | # Read those haps from the input file | ||||||||||||||||||||||||||||
| 631 | # Next hap read will be the first hap of the next run. | ||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||
| 633 | 9 | my @seqs; | |||||||||||||||||||||||||||
| 634 | 9 | for ( 1 .. $haps_to_pull ) { | |||||||||||||||||||||||||||
| 635 | 37 | my $seq = $self->get_next_seq; | |||||||||||||||||||||||||||
| 636 | 37 | ▶ | next unless defined $seq; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | 37 | push @seqs, $seq; | |||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | 9 | return @seqs; | |||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | =head2 METHODS TO RETRIEVE CONSTANTS | ||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | =head3 base_conversion_table | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | Title : get_base_conversion_table | ||||||||||||||||||||||||||||
| 649 | Usage : $table_hash_ref = $stream->get_base_conversion_table() | ||||||||||||||||||||||||||||
| 650 | Function: returns a reference to a hash. The keys of the hash are the letters | ||||||||||||||||||||||||||||
| 651 | 'A','T','G','C'. The values associated with each key are the value | ||||||||||||||||||||||||||||
| 652 | that each letter in the sequence of a seq object returned by a | ||||||||||||||||||||||||||||
| 653 | Bio::SeqIO::mbsout stream should be translated to. | ||||||||||||||||||||||||||||
| 654 | Returns : reference to a hash | ||||||||||||||||||||||||||||
| 655 | Args : NONE | ||||||||||||||||||||||||||||
| 656 | Synopsis: | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | # retrieve the Bio::Seq object's sequence | ||||||||||||||||||||||||||||
| 659 | my $haplotype = $seq->seq; | ||||||||||||||||||||||||||||
| 660 | my $rh_base_conversion_table = $stream->get_base_conversion_table(); | ||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | # need to convert all letters to their corresponding numbers. | ||||||||||||||||||||||||||||
| 663 | foreach my $base (keys %{$rh_base_conversion_table}){ | ||||||||||||||||||||||||||||
| 664 | $haplotype =~ s/($base)/$rh_base_conversion_table->{$base}/g; | ||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | # $haplotype is now an ms style haplotype. (e.g. '100101101455') | ||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | =cut | ||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||
| 671 | 45 | ▶ | sub get_base_conversion_table { | ||||||||||||||||||||||||||
|
Subroutine
get_base_conversion_table: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 672 | 45 | my $self = shift; | |||||||||||||||||||||||||||
| 673 | 45 | return $self->{BASE_CONVERSION_TABLE_HASH_REF}; | |||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | ############################################################################## | ||||||||||||||||||||||||||||
| 677 | ## subs for internal use only | ||||||||||||||||||||||||||||
| 678 | ############################################################################## | ||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||
| 680 | 50 | ▶ | sub _get_next_clean_hap { | ||||||||||||||||||||||||||
|
Subroutine
_get_next_clean_hap: called CC=10 SCAR=24.5
| |||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||
| 682 | #By Warren Kretzschmar | ||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | # return the next non-empty line from file handle (chomped line) | ||||||||||||||||||||||||||||
| 685 | # skipps to the next run if '//' is encountered | ||||||||||||||||||||||||||||
| 686 | 50 | my ( $self, $fh, $times, $end_run ) = @_; | |||||||||||||||||||||||||||
| 687 | 50 | my @data; | |||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | 0 | ▶ | unless ( defined $fh ) { return; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | 50 | ▶ | unless ( defined $times && $times > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $times and $times > 0
MC/DC0%0/2
defined $times and $times > 0
defined $times
$times > 0
Truth table33%1/3
A and B
A= defined $timesB= $times > 0
| |||||||||||||||||||||||||||||
| 692 | 0 | $times = 1; | |||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | 50 | ▶ | if ( defined $self->{BUFFER_HAP} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 696 | 8 | push @data, $self->{BUFFER_HAP}; | |||||||||||||||||||||||||||
| 697 | 8 | $self->{BUFFER_HAP} = undef; | |||||||||||||||||||||||||||
| 698 | 8 | $self->{LAST_READ_HAP_NUM}++; | |||||||||||||||||||||||||||
| 699 | 8 | $times--; | |||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | 50 | ▶ | while ( 1 <= $times-- ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | # Find next clean line | ||||||||||||||||||||||||||||
| 705 | 42 | my $data = <$fh>; | |||||||||||||||||||||||||||
| 706 | 42 | ▶ | last if !defined($data); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 707 | 40 | chomp $data; | |||||||||||||||||||||||||||
| 708 | 40 | ▶ | while ( $data !~ /./ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 709 | 0 | $data = <$fh>; | |||||||||||||||||||||||||||
| 710 | 0 | chomp $data; | |||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | # If the next run is encountered here, then we have a programming | ||||||||||||||||||||||||||||
| 714 | # or format error | ||||||||||||||||||||||||||||
| 715 | 0 | ▶ | if ( $data eq '//' ) { $self->throw("'//' found when not expected\n") } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||
| 717 | 40 | $self->{LAST_READ_HAP_NUM}++; | |||||||||||||||||||||||||||
| 718 | 40 | push @data, $data; | |||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | 50 | ▶ | if ($end_run) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 722 | 11 | $self->_load_run_info($fh); | |||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | 50 | return (@data); | |||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||
| 728 | 11 | ▶ | sub _load_run_info { | ||||||||||||||||||||||||||
|
Subroutine
_load_run_info: called CC=10 SCAR=23.3
| |||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||
| 730 | 11 | my ( $self, $fh ) = @_; | |||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||
| 732 | 11 | my $data = <$fh>; | |||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | # In this case we are at EOF | ||||||||||||||||||||||||||||
| 735 | 11 | ▶ | if ( !defined($data) ) { $self->{NEXT_RUN_NUM} = undef; return; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||
| 737 | 9 | chomp $data; | |||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||
| 739 | 9 | ▶ | while ( $data !~ /./ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 740 | 3 | $data = <$fh>; | |||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||
| 742 | # In this case we are at EOF | ||||||||||||||||||||||||||||
| 743 | 0 | ▶ | if ( !defined($data) ) { $self->{NEXT_RUN_NUM} = undef; return; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 744 | 3 | chomp $data; | |||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||
| 747 | # If the next run is encountered, then skip to the next hap and save it in | ||||||||||||||||||||||||||||
| 748 | # the buffer. | ||||||||||||||||||||||||||||
| 749 | 9 | ▶ | if ( $data =~ /^\/\// ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 750 | 9 | $self->{NEXT_RUN_NUM}++; | |||||||||||||||||||||||||||
| 751 | 9 | $self->{LAST_READ_HAP_NUM} = 0; | |||||||||||||||||||||||||||
| 752 | 9 | my @data = split( /\s+/, $data ); | |||||||||||||||||||||||||||
| 753 | 9 | my @temp = split( /\/\//, $data[0] ); | |||||||||||||||||||||||||||
| 754 | 9 | @temp = split( /-/, $temp[0] ); | |||||||||||||||||||||||||||
| 755 | 9 | $self->{LAST_READ_TRAJ_FILE} = $temp[0]; | |||||||||||||||||||||||||||
| 756 | 9 | $self->{LAST_LEAD_TRAJ_FILE_REPLICATION} = $temp[1]; | |||||||||||||||||||||||||||
| 757 | 9 | $self->{LAST_READ_ALLELES} = \@data[ 2 .. $#data ]; | |||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | 9 | for ( 1 .. 3 ) { | |||||||||||||||||||||||||||
| 760 | 27 | $data = <$fh>; | |||||||||||||||||||||||||||
| 761 | 27 | ▶ | while ( $data !~ /./ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 762 | 3 | $data = <$fh>; | |||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||
| 764 | 27 | chomp $data; | |||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||
| 766 | 27 | @data = split( /\s+/, $data ); | |||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||
| 768 | 27 | ▶ | if ( $_ eq '1' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 769 | 9 | $self->{LAST_READ_SEGSITES} = $data[1]; | |||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||
| 771 | elsif ( $_ eq '2' ) { | ||||||||||||||||||||||||||||
| 772 | 9 | $self->{LAST_READ_POSITIONS} = [ @data[ 1 .. $#data ] ]; | |||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||
| 774 | else { | ||||||||||||||||||||||||||||
| 775 | 9 | ▶ | if ( !defined($data) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 776 | 0 | $self->throw("run $self->{NEXT_RUN_NUM} has no haps./n"); | |||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||
| 778 | 9 | $self->{BUFFER_HAP} = $data; | |||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||
| 782 | 0 | else { $self->throw("'//' not encountered when expected\n") } | |||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||
| 785 | 2 | 1; | |||||||||||||||||||||||||||