| 1 | # | ||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::Seq::SeqFastaSpeedFactory | ||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||
| 6 | # Cared for by Jason Stajich <jason@bioperl.org> | ||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||
| 8 | # Copyright Jason Stajich | ||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||
| 10 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | Bio::Seq::SeqFastaSpeedFactory - Rapid creation of Bio::Seq objects through a factory | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | use Bio::Seq::SeqFastaSpeedFactory; | ||||||||||||||||||||||||||||||||
| 21 | my $factory = Bio::Seq::SeqFastaSpeedFactory->new(); | ||||||||||||||||||||||||||||||||
| 22 | my $seq = $factory->create( -seq => 'WYRAVLC', | ||||||||||||||||||||||||||||||||
| 23 | -id => 'name' ); | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | This factory was designed to build Bio::Seq objects as quickly as possible, but | ||||||||||||||||||||||||||||||||
| 28 | is not as generic as L<Bio::Seq::SeqFactory>. It can be used to create sequences | ||||||||||||||||||||||||||||||||
| 29 | from non-rich file formats. The L<Bio::SeqIO::fasta> sequence parser uses this | ||||||||||||||||||||||||||||||||
| 30 | factory. | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||
| 37 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||||||
| 38 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||
| 41 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | =head2 Support | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||
| 50 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||
| 51 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||
| 52 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||
| 57 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||||||
| 58 | web: | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | =head1 AUTHOR - Jason Stajich | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | Email jason@bioperl.org | ||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||
| 69 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | # Let the code begin... | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | package Bio::Seq::SeqFastaSpeedFactory; | ||||||||||||||||||||||||||||||||
| 78 | 27 | $Bio::Seq::SeqFastaSpeedFactory::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||
| 79 | 27 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 27 | ▶ | use Bio::Seq; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 82 | 27 | ▶ | use Bio::PrimarySeq; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 27 | ▶ | use base qw(Bio::Root::Root Bio::Factory::SequenceFactoryI); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | =head2 new | ||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | Title : new | ||||||||||||||||||||||||||||||||
| 90 | Usage : my $obj = Bio::Seq::SeqFastaSpeedFactory->new(); | ||||||||||||||||||||||||||||||||
| 91 | Function: Builds a new Bio::Seq::SeqFastaSpeedFactory object | ||||||||||||||||||||||||||||||||
| 92 | Returns : Bio::Seq::SeqFastaSpeedFactory | ||||||||||||||||||||||||||||||||
| 93 | Args : None | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | =cut | ||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | 34 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 98 | 34 | my($class,@args) = @_; | |||||||||||||||||||||||||||||||
| 99 | 34 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||
| 100 | 34 | return $self; | |||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | =head2 create | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | Title : create | ||||||||||||||||||||||||||||||||
| 107 | Usage : my $seq = $seqbuilder->create(-seq => 'CAGT', -id => 'name'); | ||||||||||||||||||||||||||||||||
| 108 | Function: Instantiates a new Bio::Seq object, correctly built but very | ||||||||||||||||||||||||||||||||
| 109 | fast, knowing stuff about Bio::PrimarySeq and Bio::Seq | ||||||||||||||||||||||||||||||||
| 110 | Returns : A Bio::Seq object | ||||||||||||||||||||||||||||||||
| 111 | Args : Initialization parameters for the sequence object we want: | ||||||||||||||||||||||||||||||||
| 112 | -id | ||||||||||||||||||||||||||||||||
| 113 | -primary_id | ||||||||||||||||||||||||||||||||
| 114 | -display_id | ||||||||||||||||||||||||||||||||
| 115 | -desc | ||||||||||||||||||||||||||||||||
| 116 | -seq | ||||||||||||||||||||||||||||||||
| 117 | -alphabet | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | 58 | ▶ | sub create { | ||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 122 | 58 | my ($self,@args) = @_; | |||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | 58 | my %param = @args; | |||||||||||||||||||||||||||||||
| 125 | 58 | @param{ map { lc $_ } keys %param } = values %param; # lowercase keys | |||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 58 | my $sequence = $param{'-seq'}; | |||||||||||||||||||||||||||||||
| 128 | 58 | my $fulldesc = $param{'-desc'}; | |||||||||||||||||||||||||||||||
| 129 | 58 | ▶ | my $id = defined $param{'-id'} ? $param{'-id'} : $param{'-primary_id'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | 58 | my $alphabet = $param{'-alphabet'}; | |||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 58 | my $seq = bless {}, 'Bio::Seq'; | |||||||||||||||||||||||||||||||
| 133 | 58 | my $t_pseq = $seq->{'primary_seq'} = bless {}, 'Bio::PrimarySeq'; | |||||||||||||||||||||||||||||||
| 134 | 58 | $t_pseq->{'seq'} = $sequence; | |||||||||||||||||||||||||||||||
| 135 | 58 | $t_pseq->{'length'} = CORE::length($sequence); | |||||||||||||||||||||||||||||||
| 136 | 58 | $t_pseq->{'desc'} = $fulldesc; | |||||||||||||||||||||||||||||||
| 137 | 58 | $t_pseq->{'display_id'} = $id; | |||||||||||||||||||||||||||||||
| 138 | 58 | $t_pseq->{'primary_id'} = $id; | |||||||||||||||||||||||||||||||
| 139 | 58 | $seq->{'primary_id'} = $id; # currently Bio::Seq does not delegate this | |||||||||||||||||||||||||||||||
| 140 | 58 | ▶ | if( $sequence and !$alphabet ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$sequence and not $alphabet
MC/DC50%1/2
$sequence and not $alphabet
$sequence
not $alphabet
Truth table66%2/3
A and not(B)
A= $sequenceB= not $alphabet
| |||||||||||||||||||||||||||||||||
| 141 | 55 | $t_pseq->_guess_alphabet(); | |||||||||||||||||||||||||||||||
| 142 | ▶ | } elsif ( $sequence and $alphabet ) { | |||||||||||||||||||||||||||||||
|
Condition33%1/3
$sequence and $alphabet
MC/DC0%0/2
$sequence and $alphabet
$sequence
$alphabet
Truth table33%1/3
A and B
A= $sequenceB= $alphabet
| |||||||||||||||||||||||||||||||||
| 143 | 0 | $t_pseq->{'alphabet'} = $alphabet; | |||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 58 | return $seq; | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 27 | 1; | |||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||