| 1 | # | ||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::AlignIO::phylip | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # Copyright Heikki Lehvaslaiho | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Bio::AlignIO::phylip - PHYLIP format sequence input/output stream | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Do not use this module directly. Use it via the Bio::AlignIO class. | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | This example shows how to write to phylip format: | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | use Bio::AlignIO; | ||||||||||||||||||||||||||||
| 18 | use Bio::SimpleAlign; | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # Use -idlength to set the name length to something other than | ||||||||||||||||||||||||||||
| 21 | # the default 10 if you need longer ids. | ||||||||||||||||||||||||||||
| 22 | my $phylipstream = Bio::AlignIO->new(-format => 'phylip', | ||||||||||||||||||||||||||||
| 23 | -fh => \*STDOUT, | ||||||||||||||||||||||||||||
| 24 | -idlength => 30); | ||||||||||||||||||||||||||||
| 25 | # Convert data from one format to another | ||||||||||||||||||||||||||||
| 26 | my $gcgstream = Bio::AlignIO->new(-format => 'msf', | ||||||||||||||||||||||||||||
| 27 | -file => 't/data/cysprot1a.msf'); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | while( my $aln = $gcgstream->next_aln ) { | ||||||||||||||||||||||||||||
| 30 | $phylipstream->write_aln($aln); | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # With phylip sequential format format | ||||||||||||||||||||||||||||
| 34 | $phylipstream->interleaved(0); | ||||||||||||||||||||||||||||
| 35 | # Or initialize the object like this | ||||||||||||||||||||||||||||
| 36 | $phylipstream = Bio::AlignIO->new(-interleaved => 0, | ||||||||||||||||||||||||||||
| 37 | -format => 'phylip', | ||||||||||||||||||||||||||||
| 38 | -fh => \*STDOUT, | ||||||||||||||||||||||||||||
| 39 | -idlength => 20 ); | ||||||||||||||||||||||||||||
| 40 | $gcgstream = Bio::AlignIO->new(-format => 'msf', | ||||||||||||||||||||||||||||
| 41 | -file => 't/data/cysprot1a.msf'); | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | while( my $aln = $gcgstream->next_aln ) { | ||||||||||||||||||||||||||||
| 44 | $phylipstream->write_aln($aln); | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | This example shows how to read phylip format: | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | my $in = Bio::AlignIO->new( | ||||||||||||||||||||||||||||
| 50 | -file => $inFile, | ||||||||||||||||||||||||||||
| 51 | -format => 'phylip', | ||||||||||||||||||||||||||||
| 52 | -interleaved => 0, | ||||||||||||||||||||||||||||
| 53 | -longid => 1 | ||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | my $out = Bio::AlignIO->new( | ||||||||||||||||||||||||||||
| 57 | -file => ">$outFile", | ||||||||||||||||||||||||||||
| 58 | -format => 'fasta' | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | while ( my $aln = $in->next_aln() ) { | ||||||||||||||||||||||||||||
| 62 | $out->write_aln($aln); | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | The -longid argument is required if the input phylip format file | ||||||||||||||||||||||||||||
| 66 | has ids with lengths greater then 10 characters. | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | This object can transform Bio::SimpleAlign objects to and from PHYLIP | ||||||||||||||||||||||||||||
| 71 | format. By default it works with the interleaved format. By specifying | ||||||||||||||||||||||||||||
| 72 | the flag -interleaved =E<gt> 0 in the initialization the module can | ||||||||||||||||||||||||||||
| 73 | read or write data in sequential format. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Reading phylip format with long IDs up to 50 characters is supported by | ||||||||||||||||||||||||||||
| 76 | the flag -longid =E<gt>1. ID strings can be surrounded by single quotes. | ||||||||||||||||||||||||||||
| 77 | They are mandatory only if the IDs contain spaces. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head2 Support | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 88 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 89 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 90 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 95 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||
| 96 | web: | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 AUTHORS - Heikki Lehvaslaiho and Jason Stajich | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Email: heikki at ebi.ac.uk | ||||||||||||||||||||||||||||
| 103 | Email: jason at bioperl.org | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | The rest of the documentation details each of the object | ||||||||||||||||||||||||||||
| 108 | methods. Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =cut | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | # Let the code begin... | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | package Bio::AlignIO::phylip; | ||||||||||||||||||||||||||||
| 115 | 3 | $Bio::AlignIO::phylip::VERSION = '1.7.8'; | |||||||||||||||||||||||||||
| 116 | 3 | ▶ | use vars qw($DEFAULTIDLENGTH $DEFAULTLINELEN $DEFAULTTAGLEN); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 117 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 3 | ▶ | use Bio::SimpleAlign; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 120 | 3 | ▶ | use POSIX; # for the rounding call | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 3 | ▶ | use base qw(Bio::AlignIO); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 125 | 3 | $DEFAULTIDLENGTH = 10; | |||||||||||||||||||||||||||
| 126 | 3 | $DEFAULTLINELEN = 60; | |||||||||||||||||||||||||||
| 127 | 3 | $DEFAULTTAGLEN = 10; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head2 new | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | Title : new | ||||||||||||||||||||||||||||
| 133 | Usage : my $alignio = Bio::AlignIO->new(-format => 'phylip' | ||||||||||||||||||||||||||||
| 134 | -file => '>file', | ||||||||||||||||||||||||||||
| 135 | -idlength => 10, | ||||||||||||||||||||||||||||
| 136 | -idlinebreak => 1); | ||||||||||||||||||||||||||||
| 137 | Function: Initialize a new L<Bio::AlignIO::phylip> reader or writer | ||||||||||||||||||||||||||||
| 138 | Returns : L<Bio::AlignIO> object | ||||||||||||||||||||||||||||
| 139 | Args : [specific for writing of phylip format files] | ||||||||||||||||||||||||||||
| 140 | -idlength => integer - length of the id (will pad w/ | ||||||||||||||||||||||||||||
| 141 | spaces if needed) when writing phylip | ||||||||||||||||||||||||||||
| 142 | -interleaved => boolean - whether interleaved | ||||||||||||||||||||||||||||
| 143 | or sequential format required | ||||||||||||||||||||||||||||
| 144 | -line_length => integer of how long a sequence lines should be | ||||||||||||||||||||||||||||
| 145 | -idlinebreak => insert a line break after the sequence id | ||||||||||||||||||||||||||||
| 146 | so that sequence starts on the next line | ||||||||||||||||||||||||||||
| 147 | -flag_SI => whether or not write a "S" or "I" just after | ||||||||||||||||||||||||||||
| 148 | the num.seq. and line len., in the first line | ||||||||||||||||||||||||||||
| 149 | -tag_length => integer of how long the tags have to be in | ||||||||||||||||||||||||||||
| 150 | each line between the space separator. set it | ||||||||||||||||||||||||||||
| 151 | to 0 to have 1 tag only. | ||||||||||||||||||||||||||||
| 152 | -wrap_sequential => boolean for whether or not sequential | ||||||||||||||||||||||||||||
| 153 | format should be broken up or a single line | ||||||||||||||||||||||||||||
| 154 | default is false (single line) | ||||||||||||||||||||||||||||
| 155 | -longid => boolean to read arbitrary long IDs (default is false) | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 20 | ▶ | sub _initialize { | ||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=12 SCAR=28.3
| |||||||||||||||||||||||||||||
| 160 | 20 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 161 | 20 | $self->SUPER::_initialize(@args); | |||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 20 | my ( $interleave, $linelen, $idlinebreak, | |||||||||||||||||||||||||||
| 164 | $idlength, $flag_SI, $tag_length, $ws, $longid ) | ||||||||||||||||||||||||||||
| 165 | = $self->_rearrange( | ||||||||||||||||||||||||||||
| 166 | [ qw(INTERLEAVED | ||||||||||||||||||||||||||||
| 167 | LINE_LENGTH | ||||||||||||||||||||||||||||
| 168 | IDLINEBREAK | ||||||||||||||||||||||||||||
| 169 | IDLENGTH | ||||||||||||||||||||||||||||
| 170 | FLAG_SI | ||||||||||||||||||||||||||||
| 171 | TAG_LENGTH | ||||||||||||||||||||||||||||
| 172 | WRAP_SEQUENTIAL | ||||||||||||||||||||||||||||
| 173 | LONGID) | ||||||||||||||||||||||||||||
| 174 | ], | ||||||||||||||||||||||||||||
| 175 | @args | ||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||
| 177 | 20 | ▶ | $self->interleaved( $interleave ? 1 : 0 ) if defined $interleave; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 178 | 20 | ▶ | $self->idlength( $idlength || $DEFAULTIDLENGTH ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$idlength || $Bio::AlignIO::phylip::DEFAULTIDLENGTH
MC/DC0%0/2
$idlength || $Bio::AlignIO::phylip::DEFAULTIDLENGTH
$idlength
$Bio::AlignIO::phylip::DEFAULTIDLENGTH
Truth table33%1/3
A || B
A= $idlengthB= $Bio::AlignIO::phylip::DEFAULTIDLENGTH
| |||||||||||||||||||||||||||||
| 179 | 20 | ▶ | $self->id_linebreak(1) if ($idlinebreak); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 20 | ▶ | $self->line_length($linelen) if defined $linelen && $linelen > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $linelen and $linelen > 0
MC/DC0%0/2
defined $linelen and $linelen > 0
defined $linelen
$linelen > 0
Truth table33%1/3
A and B
A= defined $linelenB= $linelen > 0
| |||||||||||||||||||||||||||||
| 181 | 20 | ▶ | $self->flag_SI(1) if ($flag_SI); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 20 | ▶ | $self->tag_length($tag_length) if ( $tag_length || $DEFAULTTAGLEN ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tag_length or $Bio::AlignIO::phylip::DEFAULTTAGLEN
MC/DC0%0/2
$tag_length or $Bio::AlignIO::phylip::DEFAULTTAGLEN
$tag_length
$Bio::AlignIO::phylip::DEFAULTTAGLEN
Truth table33%1/3
A or B
A= $tag_lengthB= $Bio::AlignIO::phylip::DEFAULTTAGLEN
| |||||||||||||||||||||||||||||
| 183 | 20 | ▶ | $self->wrap_sequential( $ws ? 1 : 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 20 | ▶ | $self->longid( $longid ? 1 : 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 20 | 1; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | =head2 next_aln | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | Title : next_aln | ||||||||||||||||||||||||||||
| 191 | Usage : $aln = $stream->next_aln() | ||||||||||||||||||||||||||||
| 192 | Function: returns the next alignment in the stream. | ||||||||||||||||||||||||||||
| 193 | Throws an exception if trying to read in PHYLIP | ||||||||||||||||||||||||||||
| 194 | sequential format. | ||||||||||||||||||||||||||||
| 195 | Returns : L<Bio::SimpleAlign> object | ||||||||||||||||||||||||||||
| 196 | Args : | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 18 | ▶ | sub next_aln { | ||||||||||||||||||||||||||
|
Subroutine
next_aln: called CC=23 SCAR=33.0
Pod
documented
| |||||||||||||||||||||||||||||
| 201 | 18 | my $self = shift; | |||||||||||||||||||||||||||
| 202 | 18 | my $entry; | |||||||||||||||||||||||||||
| 203 | 18 | my ($seqcount, $residuecount, %hash, $name, | |||||||||||||||||||||||||||
| 204 | $str, @names, $seqname, $start, | ||||||||||||||||||||||||||||
| 205 | $end, $count, $seq | ||||||||||||||||||||||||||||
| 206 | ); | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 18 | my $aln = Bio::SimpleAlign->new( -source => 'phylip' ); | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | # First, parse up through the header. | ||||||||||||||||||||||||||||
| 211 | # If we see a non-blank line that isn't the seqcount and residuecount line | ||||||||||||||||||||||||||||
| 212 | # then bail out of next_aln (return) | ||||||||||||||||||||||||||||
| 213 | 18 | ▶ | while ( $entry = $self->_readline ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 18 | ▶ | if ( $entry =~ /^\s?$/ ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 215 | 0 | next; | |||||||||||||||||||||||||||
| 216 | } elsif ( $entry =~ /\s*(\d+)\s+(\d+)/ ) { | ||||||||||||||||||||||||||||
| 217 | 18 | ( $seqcount, $residuecount ) = ( $1, $2 ); | |||||||||||||||||||||||||||
| 218 | 18 | last; | |||||||||||||||||||||||||||
| 219 | } else { | ||||||||||||||||||||||||||||
| 220 | 0 | $self->warn( | |||||||||||||||||||||||||||
| 221 | "Failed to parse PHYLIP: Did not see a sequence count and residue count." | ||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||
| 223 | 0 | return; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | 18 | ▶ | return unless $seqcount and $residuecount; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$seqcount and $residuecount
MC/DC0%0/2
$seqcount and $residuecount
$seqcount
$residuecount
Truth table33%1/3
A and B
A= $seqcountB= $residuecount
| |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | # First alignment section. We expect to see a name and (part of) a sequence. | ||||||||||||||||||||||||||||
| 229 | 18 | my $idlen = $self->idlength; | |||||||||||||||||||||||||||
| 230 | 18 | $count = 0; | |||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 18 | ▶ | while ( $entry = $self->_readline ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 107 | ▶ | if ( $entry =~ /^\s?$/ ) { # eat the newlines | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 4 | next; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | # Names can be in a few different formats: | ||||||||||||||||||||||||||||
| 238 | # 1. they can be traditional phylip: 10 chars long, period. If this is the case, that name can have spaces. | ||||||||||||||||||||||||||||
| 239 | # 2. they can be hacked with a long ID, as passed in with the flag -longid. | ||||||||||||||||||||||||||||
| 240 | # 3. if there is a long ID, the name can have spaces as long as it is wrapped in single quotes. | ||||||||||||||||||||||||||||
| 241 | 103 | ▶ | if ( $self->longid() ) { # 2 or 3 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 12 | ▶ | if ( $entry =~ /^'(.+)'\s+(.+)$/ ) { # 3. name has single quotes. | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 1 | $name = $1; | |||||||||||||||||||||||||||
| 244 | 1 | $str = $2; | |||||||||||||||||||||||||||
| 245 | } else { # 2. name does not have single quotes, so should not have spaces. | ||||||||||||||||||||||||||||
| 246 | # therefore, the first part of the line is the name and the rest is the seq. | ||||||||||||||||||||||||||||
| 247 | # make sure that the line does not lead with extra spaces. | ||||||||||||||||||||||||||||
| 248 | 11 | $entry =~ s/^\s+//; | |||||||||||||||||||||||||||
| 249 | 11 | ( $name, $str ) = split( /\s+/, $entry, 2 ); | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | } else { # 1. traditional phylip. | ||||||||||||||||||||||||||||
| 252 | 91 | $entry =~ /^(.{1,10})\s(.+)$/; | |||||||||||||||||||||||||||
| 253 | 91 | $name = $1; | |||||||||||||||||||||||||||
| 254 | 91 | $str = $2; | |||||||||||||||||||||||||||
| 255 | 91 | $name =~ s/\s+$//; # eat any trailing spaces | |||||||||||||||||||||||||||
| 256 | 91 | $name =~ s/\s+/_/g; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | 103 | push @names, $name; | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | #clean sequence of spaces: | ||||||||||||||||||||||||||||
| 261 | 103 | $str =~ s/\s+//g; | |||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | # are we sequential? If so, we should keep adding to the sequence until we've got all the residues. | ||||||||||||||||||||||||||||
| 264 | 103 | ▶ | if ( ( $self->interleaved ) == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | 4 | ▶ | while ( length($str) < $residuecount ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 20 | $entry = $self->_readline; | |||||||||||||||||||||||||||
| 267 | 20 | $str .= $entry; | |||||||||||||||||||||||||||
| 268 | 20 | $str =~ s/\s+//g; | |||||||||||||||||||||||||||
| 269 | 20 | ▶ | if ( $entry =~ /^\s*$/ ) { # we ran into a newline before we got a complete sequence: bail! | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 0 | $self->warn( | |||||||||||||||||||||||||||
| 271 | "Failed to parse PHYLIP: Sequence $name was shorter than expected: " | ||||||||||||||||||||||||||||
| 272 | . length($str) | ||||||||||||||||||||||||||||
| 273 | . " instead of $residuecount." ); | ||||||||||||||||||||||||||||
| 274 | 0 | last; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | 103 | $hash{$count} = $str; | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 103 | $count++; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | # if we've read as many seqs as we're supposed to, move on. | ||||||||||||||||||||||||||||
| 283 | 103 | ▶ | if ( $count == $seqcount ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 284 | 18 | last; | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | # if we are interleaved, we're going to keep seeing chunks of sequence until we get all of it. | ||||||||||||||||||||||||||||
| 289 | 18 | ▶ | if ( $self->interleaved ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 17 | ▶ | while ( length( $hash{ $seqcount - 1 } ) < $residuecount ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | 115 | $count = 0; | |||||||||||||||||||||||||||
| 292 | 115 | ▶ | while ( $entry = $self->_readline ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | 472 | ▶ | if ( $entry =~ /^\s*$/ ) { # eat newlines | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | 115 | ▶ | if ( $count != 0 ) { # there was a newline at an unexpected place! | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | 0 | $self->warn( | |||||||||||||||||||||||||||
| 296 | "Failed to parse PHYLIP: Interleaved file is missing a segment: saw $count, expected $seqcount." | ||||||||||||||||||||||||||||
| 297 | ); | ||||||||||||||||||||||||||||
| 298 | 0 | return; | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | 115 | next; | |||||||||||||||||||||||||||
| 301 | } else { # start taking in chunks | ||||||||||||||||||||||||||||
| 302 | 357 | $entry =~ s/\s//g; | |||||||||||||||||||||||||||
| 303 | 357 | $hash{$count} .= $entry; | |||||||||||||||||||||||||||
| 304 | 357 | $count++; | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | 357 | ▶ | if ( $count >= $seqcount ) { # we've read all of the sequences for this chunk, so move on. | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 115 | last; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | 18 | ▶ | if ( ( scalar @names ) != $seqcount ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | 0 | $self->warn( | |||||||||||||||||||||||||||
| 314 | "Failed to parse PHYLIP: Did not see the correct number of seqs: saw " | ||||||||||||||||||||||||||||
| 315 | . scalar(@names) | ||||||||||||||||||||||||||||
| 316 | . ", expected $seqcount." ); | ||||||||||||||||||||||||||||
| 317 | 0 | return; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | 18 | ▶ | for ( $count = 0; $count < $seqcount; $count++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | 103 | $str = $hash{$count}; | |||||||||||||||||||||||||||
| 321 | 103 | my $seqname = $names[$count]; | |||||||||||||||||||||||||||
| 322 | 103 | ▶ | if ( length($str) != $residuecount ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | 0 | $self->warn( | |||||||||||||||||||||||||||
| 324 | "Failed to parse PHYLIP: Sequence $seqname was the wrong length: " | ||||||||||||||||||||||||||||
| 325 | . length($str) | ||||||||||||||||||||||||||||
| 326 | . " instead of $residuecount." ); | ||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | $seq = Bio::LocatableSeq->new( | ||||||||||||||||||||||||||||
| 329 | 103 | '-seq' => $hash{$count}, | |||||||||||||||||||||||||||
| 330 | '-display_id' => $seqname | ||||||||||||||||||||||||||||
| 331 | ); | ||||||||||||||||||||||||||||
| 332 | 103 | $aln->add_seq($seq); | |||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | 18 | return $aln; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | =head2 write_aln | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | Title : write_aln | ||||||||||||||||||||||||||||
| 340 | Usage : $stream->write_aln(@aln) | ||||||||||||||||||||||||||||
| 341 | Function: writes the $aln object into the stream in phylip format | ||||||||||||||||||||||||||||
| 342 | Returns : 1 for success and 0 for error | ||||||||||||||||||||||||||||
| 343 | Args : L<Bio::Align::AlignI> object | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | =cut | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 2 | ▶ | sub write_aln { | ||||||||||||||||||||||||||
|
Subroutine
write_aln: called CC=26 SCAR=38.2
Pod
documented
| |||||||||||||||||||||||||||||
| 348 | 2 | my ( $self, @aln ) = @_; | |||||||||||||||||||||||||||
| 349 | 2 | my $count = 0; | |||||||||||||||||||||||||||
| 350 | 2 | my $wrapped = 0; | |||||||||||||||||||||||||||
| 351 | 2 | my $maxname; | |||||||||||||||||||||||||||
| 352 | 2 | my $width = $self->line_length(); | |||||||||||||||||||||||||||
| 353 | 2 | my ($length, $date, $name, $seq, $miss, | |||||||||||||||||||||||||||
| 354 | $pad, %hash, @arr, $tempcount, $index, | ||||||||||||||||||||||||||||
| 355 | $idlength, $flag_SI, $line_length, $tag_length | ||||||||||||||||||||||||||||
| 356 | ); | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 2 | foreach my $aln (@aln) { | |||||||||||||||||||||||||||
| 359 | 2 | ▶ | if ( ! $aln || ! $aln->isa('Bio::Align::AlignI') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$aln and $aln->isa("Bio::Align::AlignI")
MC/DC0%0/2
$aln and $aln->isa("Bio::Align::AlignI")
$aln
$aln->isa("Bio::Align::AlignI")
Truth table33%1/3
A and B
A= $alnB= $aln->isa("Bio::Align::AlignI")
| |||||||||||||||||||||||||||||
| 360 | 0 | $self->warn( | |||||||||||||||||||||||||||
| 361 | "Must provide a Bio::Align::AlignI object when calling write_aln" | ||||||||||||||||||||||||||||
| 362 | ); | ||||||||||||||||||||||||||||
| 363 | 0 | next; | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | 2 | ▶ | $self->throw("All sequences in the alignment must be the same length") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | unless $aln->is_flush(1); | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 2 | $flag_SI = $self->flag_SI(); | |||||||||||||||||||||||||||
| 369 | 2 | $aln->set_displayname_flat(); # plain | |||||||||||||||||||||||||||
| 370 | 2 | $length = $aln->length(); | |||||||||||||||||||||||||||
| 371 | 2 | ▶ | if ($flag_SI) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ( $self->interleaved() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | 0 | $self->_print( | |||||||||||||||||||||||||||
| 374 | sprintf( | ||||||||||||||||||||||||||||
| 375 | " %s %s I\n", $aln->num_sequences, $aln->length | ||||||||||||||||||||||||||||
| 376 | ) | ||||||||||||||||||||||||||||
| 377 | ); | ||||||||||||||||||||||||||||
| 378 | } else { | ||||||||||||||||||||||||||||
| 379 | 0 | $self->_print( | |||||||||||||||||||||||||||
| 380 | sprintf( | ||||||||||||||||||||||||||||
| 381 | " %s %s S\n", $aln->num_sequences, $aln->length | ||||||||||||||||||||||||||||
| 382 | ) | ||||||||||||||||||||||||||||
| 383 | ); | ||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | } else { | ||||||||||||||||||||||||||||
| 386 | 2 | $self->_print( | |||||||||||||||||||||||||||
| 387 | sprintf( " %s %s\n", $aln->num_sequences, $aln->length ) ); | ||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 2 | $idlength = $self->idlength(); | |||||||||||||||||||||||||||
| 391 | 2 | $line_length = $self->line_length(); | |||||||||||||||||||||||||||
| 392 | 2 | $tag_length = $self->tag_length(); | |||||||||||||||||||||||||||
| 393 | 2 | foreach $seq ( $aln->each_seq() ) { | |||||||||||||||||||||||||||
| 394 | 10 | $name = $aln->displayname( $seq->get_nse ); | |||||||||||||||||||||||||||
| 395 | 10 | ▶ | if ( $self->longid ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 0 | ▶ | $self->warn( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | "The length of the name is over 50 chars long [$name]") | ||||||||||||||||||||||||||||
| 398 | if length($name) > 50; | ||||||||||||||||||||||||||||
| 399 | 0 | $name = "'$name' "; | |||||||||||||||||||||||||||
| 400 | } else { | ||||||||||||||||||||||||||||
| 401 | 10 | ▶ | $name = substr( $name, 0, $idlength ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 402 | if length($name) > $idlength; | ||||||||||||||||||||||||||||
| 403 | 10 | $name = sprintf( "%-" . $idlength . "s", $name ); | |||||||||||||||||||||||||||
| 404 | 10 | ▶ | if ( $self->interleaved() ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 405 | 10 | $name .= ' '; | |||||||||||||||||||||||||||
| 406 | } elsif ( $self->id_linebreak ) { | ||||||||||||||||||||||||||||
| 407 | 0 | $name .= "\n"; | |||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | #phylip needs dashes not dots | ||||||||||||||||||||||||||||
| 412 | 10 | my $seq = $seq->seq(); | |||||||||||||||||||||||||||
| 413 | 10 | $seq =~ s/\./-/g; | |||||||||||||||||||||||||||
| 414 | 10 | $hash{$name} = $seq; | |||||||||||||||||||||||||||
| 415 | 10 | push( @arr, $name ); | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | 2 | ▶ | if ( $self->interleaved() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 419 | 2 | my $numtags; | |||||||||||||||||||||||||||
| 420 | 2 | ▶ | if ( $tag_length <= $line_length ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 421 | 2 | $numtags = floor( $line_length / $tag_length ); | |||||||||||||||||||||||||||
| 422 | 2 | $line_length = $tag_length * $numtags; | |||||||||||||||||||||||||||
| 423 | } else { | ||||||||||||||||||||||||||||
| 424 | 0 | $numtags = 1; | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | 2 | ▶ | while ( $count < $length ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | # there is another block to go! | ||||||||||||||||||||||||||||
| 429 | 9 | foreach $name (@arr) { | |||||||||||||||||||||||||||
| 430 | 52 | my $dispname = $name; | |||||||||||||||||||||||||||
| 431 | 52 | ▶ | $dispname = '' if $wrapped; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 52 | $self->_print( | |||||||||||||||||||||||||||
| 433 | sprintf( "%" . ( $idlength + 3 ) . "s", $dispname ) ); | ||||||||||||||||||||||||||||
| 434 | 52 | $tempcount = $count; | |||||||||||||||||||||||||||
| 435 | 52 | $index = 0; | |||||||||||||||||||||||||||
| 436 | 52 | ▶ | $self->debug("residue count: $count\n") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 437 | if ( $count % 100000 == 0 ); | ||||||||||||||||||||||||||||
| 438 | 52 | ▶ | while (( $tempcount + $tag_length < $length ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$tempcount + $tag_length < $length and $index < $numtags
MC/DC100%2/2
$tempcount + $tag_length < $length and $index < $numtags
$tempcount + $tag_length < $length
$index < $numtags
Truth table100%3/3
A and B
A= $tempcount + $tag_length < $lengthB= $index < $numtags
| |||||||||||||||||||||||||||||
| 439 | && ( $index < $numtags ) ) { | ||||||||||||||||||||||||||||
| 440 | $self->_print( | ||||||||||||||||||||||||||||
| 441 | sprintf( | ||||||||||||||||||||||||||||
| 442 | "%s ", | ||||||||||||||||||||||||||||
| 443 | substr( | ||||||||||||||||||||||||||||
| 444 | 268 | $hash{$name}, $tempcount, $tag_length | |||||||||||||||||||||||||||
| 445 | ) | ||||||||||||||||||||||||||||
| 446 | ) | ||||||||||||||||||||||||||||
| 447 | ); | ||||||||||||||||||||||||||||
| 448 | 268 | $tempcount += $tag_length; | |||||||||||||||||||||||||||
| 449 | 268 | $index++; | |||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | # last | ||||||||||||||||||||||||||||
| 453 | 52 | ▶ | if ( $index < $numtags ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | # space to print! | ||||||||||||||||||||||||||||
| 456 | $self->_print( | ||||||||||||||||||||||||||||
| 457 | sprintf( "%s", | ||||||||||||||||||||||||||||
| 458 | 10 | substr( $hash{$name}, $tempcount ) ) | |||||||||||||||||||||||||||
| 459 | ); | ||||||||||||||||||||||||||||
| 460 | 10 | $tempcount += $tag_length; | |||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | 52 | $self->_print("\n"); | |||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | 9 | $self->_print("\n"); | |||||||||||||||||||||||||||
| 465 | 9 | $count = $tempcount; | |||||||||||||||||||||||||||
| 466 | 9 | $wrapped = 1; | |||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||
| 468 | } else { | ||||||||||||||||||||||||||||
| 469 | 0 | foreach $name (@arr) { | |||||||||||||||||||||||||||
| 470 | 0 | my $dispname = $name; | |||||||||||||||||||||||||||
| 471 | 0 | my $line = sprintf( "%s%s\n", $dispname, $hash{$name} ); | |||||||||||||||||||||||||||
| 472 | 0 | ▶ | if ( $self->wrap_sequential ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 473 | 0 | $line =~ s/(.{1,$width})/$1\n/g; | |||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||
| 475 | 0 | $self->_print($line); | |||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | 2 | ▶ | $self->flush if $self->_flush_on_write && defined $self->_fh; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_flush_on_write and defined $self->_fh
MC/DC0%0/2
$self->_flush_on_write and defined $self->_fh
$self->_flush_on_write
defined $self->_fh
Truth table33%1/3
A and B
A= $self->_flush_on_writeB= defined $self->_fh
| |||||||||||||||||||||||||||||
| 480 | 2 | return 1; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | =head2 interleaved | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | Title : interleaved | ||||||||||||||||||||||||||||
| 486 | Usage : my $interleaved = $obj->interleaved | ||||||||||||||||||||||||||||
| 487 | Function: Get/Set Interleaved status | ||||||||||||||||||||||||||||
| 488 | Returns : boolean | ||||||||||||||||||||||||||||
| 489 | Args : boolean | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | =cut | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 134 | ▶ | sub interleaved { | ||||||||||||||||||||||||||
|
Subroutine
interleaved: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 495 | 134 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 496 | 134 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 497 | 1 | ▶ | if ($value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 498 | 0 | $self->{'_interleaved'} = 1 | |||||||||||||||||||||||||||
| 499 | } else { | ||||||||||||||||||||||||||||
| 500 | 1 | $self->{'_interleaved'} = 0 | |||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||
| 503 | 134 | ▶ | return 1 unless defined $self->{'_interleaved'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 504 | 6 | return $self->{'_interleaved'}; | |||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | =head2 flag_SI | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | Title : flag_SI | ||||||||||||||||||||||||||||
| 510 | Usage : my $flag = $obj->flag_SI | ||||||||||||||||||||||||||||
| 511 | Function: Get/Set if the Sequential/Interleaved flag has to be shown | ||||||||||||||||||||||||||||
| 512 | after the number of sequences and sequence length | ||||||||||||||||||||||||||||
| 513 | Example : | ||||||||||||||||||||||||||||
| 514 | Returns : boolean | ||||||||||||||||||||||||||||
| 515 | Args : boolean | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | =cut | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | 2 | ▶ | sub flag_SI { | ||||||||||||||||||||||||||
|
Subroutine
flag_SI: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||
| 521 | 2 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 522 | 2 | my $previous = $self->{'_flag_SI'}; | |||||||||||||||||||||||||||
| 523 | 2 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 524 | 0 | $self->{'_flag_SI'} = $value; | |||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||
| 526 | 2 | return $previous; | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | =head2 idlength | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | Title : idlength | ||||||||||||||||||||||||||||
| 532 | Usage : my $idlength = $obj->idlength | ||||||||||||||||||||||||||||
| 533 | Function: Get/Set value of id length | ||||||||||||||||||||||||||||
| 534 | Returns : string | ||||||||||||||||||||||||||||
| 535 | Args : string | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | =cut | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 40 | ▶ | sub idlength { | ||||||||||||||||||||||||||
|
Subroutine
idlength: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 541 | 40 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 542 | 40 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 543 | 20 | $self->{'_idlength'} = $value; | |||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||
| 545 | 40 | return $self->{'_idlength'}; | |||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | =head2 line_length | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | Title : line_length | ||||||||||||||||||||||||||||
| 551 | Usage : $obj->line_length($newval) | ||||||||||||||||||||||||||||
| 552 | Function: | ||||||||||||||||||||||||||||
| 553 | Returns : value of line_length | ||||||||||||||||||||||||||||
| 554 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | =cut | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | 4 | ▶ | sub line_length { | ||||||||||||||||||||||||||
|
Subroutine
line_length: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||
| 560 | 4 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 561 | 4 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 562 | 0 | $self->{'_line_length'} = $value; | |||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||
| 564 | 4 | ▶ | return $self->{'_line_length'} || $DEFAULTLINELEN; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'_line_length'} || $Bio::AlignIO::phylip::DEFAULTLINELEN
MC/DC0%0/2
$self->{'_line_length'} || $Bio::AlignIO::phylip::DEFAULTLINELEN
$self->{'_line_length'}
$Bio::AlignIO::phylip::DEFAULTLINELEN
Truth table33%1/3
A || B
A= $self->{'_line_length'}B= $Bio::AlignIO::phylip::DEFAULTLINELEN
| |||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | =head2 tag_length | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | Title : tag_length | ||||||||||||||||||||||||||||
| 571 | Usage : $obj->tag_length($newval) | ||||||||||||||||||||||||||||
| 572 | Function: | ||||||||||||||||||||||||||||
| 573 | Example : my $tag_length = $obj->tag_length | ||||||||||||||||||||||||||||
| 574 | Returns : value of the length for each space-separated tag in a line | ||||||||||||||||||||||||||||
| 575 | Args : newvalue (optional) - set to zero to have one tag per line | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | =cut | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | 22 | ▶ | sub tag_length { | ||||||||||||||||||||||||||
|
Subroutine
tag_length: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||
| 581 | 22 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 582 | 22 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 583 | 0 | $self->{'_tag_length'} = $value; | |||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||
| 585 | 22 | ▶ | return $self->{'_tag_length'} || $DEFAULTTAGLEN; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'_tag_length'} || $Bio::AlignIO::phylip::DEFAULTTAGLEN
MC/DC0%0/2
$self->{'_tag_length'} || $Bio::AlignIO::phylip::DEFAULTTAGLEN
$self->{'_tag_length'}
$Bio::AlignIO::phylip::DEFAULTTAGLEN
Truth table33%1/3
A || B
A= $self->{'_tag_length'}B= $Bio::AlignIO::phylip::DEFAULTTAGLEN
| |||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | =head2 id_linebreak | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | Title : id_linebreak | ||||||||||||||||||||||||||||
| 591 | Usage : $obj->id_linebreak($newval) | ||||||||||||||||||||||||||||
| 592 | Function: | ||||||||||||||||||||||||||||
| 593 | Returns : value of id_linebreak | ||||||||||||||||||||||||||||
| 594 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | =cut | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | 0 | ▶ | sub id_linebreak { | ||||||||||||||||||||||||||
|
Subroutine
id_linebreak: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 600 | 0 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 601 | 0 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 602 | 0 | $self->{'_id_linebreak'} = $value; | |||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||
| 604 | 0 | ▶ | return $self->{'_id_linebreak'} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'_id_linebreak'} || 0
MC/DC0%0/1
$self->{'_id_linebreak'} || 0
$self->{'_id_linebreak'}
Truth table0%0/2
A
A= $self->{'_id_linebreak'}
| |||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | =head2 wrap_sequential | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | Title : wrap_sequential | ||||||||||||||||||||||||||||
| 610 | Usage : $obj->wrap_sequential($newval) | ||||||||||||||||||||||||||||
| 611 | Function: | ||||||||||||||||||||||||||||
| 612 | Returns : value of wrap_sequential | ||||||||||||||||||||||||||||
| 613 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | =cut | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | 20 | ▶ | sub wrap_sequential { | ||||||||||||||||||||||||||
|
Subroutine
wrap_sequential: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||
| 619 | 20 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 620 | 20 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 621 | 20 | $self->{'_wrap_sequential'} = $value; | |||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||
| 623 | 20 | ▶ | return $self->{'_wrap_sequential'} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'_wrap_sequential'} || 0
MC/DC0%0/1
$self->{'_wrap_sequential'} || 0
$self->{'_wrap_sequential'}
Truth table50%1/2
A
A= $self->{'_wrap_sequential'}
| |||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | =head2 longid | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | Title : longid | ||||||||||||||||||||||||||||
| 629 | Usage : $obj->longid($newval) | ||||||||||||||||||||||||||||
| 630 | Function: | ||||||||||||||||||||||||||||
| 631 | Returns : value of longid | ||||||||||||||||||||||||||||
| 632 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||
| 635 | =cut | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | 133 | ▶ | sub longid { | ||||||||||||||||||||||||||
|
Subroutine
longid: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 638 | 133 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 639 | 133 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 640 | 20 | $self->{'_longid'} = $value; | |||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||
| 642 | 133 | ▶ | return $self->{'_longid'} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'_longid'} || 0
MC/DC100%1/1
$self->{'_longid'} || 0
$self->{'_longid'}
Truth table100%2/2
A
A= $self->{'_longid'}
| |||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | 3 | 1; | |||||||||||||||||||||||||||