Skip to content

Commit

Permalink
Merge branch 'master' into amplicons
Browse files Browse the repository at this point in the history
  • Loading branch information
fangly committed Aug 21, 2012
2 parents 8334d17 + a6515da commit 9d3435f
Show file tree
Hide file tree
Showing 112 changed files with 4,143 additions and 15,474 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,3 +17,4 @@ t/LocalDB/SeqFeature_*.t
blib*
*.bak
MYMETA.yml
MYMETA.json
37 changes: 37 additions & 0 deletions .travis.yml
@@ -0,0 +1,37 @@
language: perl
perl:
- "5.16"
- "5.14"
- "5.12"
- "5.10"

env: PERL_CPANM_OPT="--notest --force --skip-satisfied"
install:
#This should solve problem installing Perl's DB_File & GraphViz
- "sudo apt-get install libdb-dev graphviz libgd2-xpm-dev libxml2-dev 2>&1 | tail -n 4"
#These are recommended or required Perl libraries:
- "cpanm GD 2>&1 | tail -n 1"
- "cpanm HTML::TableExtract DBI Data::Stag DB_File 2>&1 | tail -n 1"
- "cpanm DBD::mysql DBD::Pg DBD::SQLite 2>&1 | tail -n 1"
- "cpanm Algorithm::Munkres Array::Compare Convert::Binary::C Error 2>&1 | tail -n 1"
- "cpanm Graph SVG SVG::Graph GraphViz 2>&1 | tail -n 1"
- "cpanm XML::DOM::XPath XML::Parser XML::Parser::PerlSAX 2>&1 | tail -n 1"
- "cpanm XML::SAX XML::SAX::Writer XML::Simple XML::LibXML XML::Twig XML::Writer 2>&1 | tail -n 1"
- "cpanm PostScript::TextBlock Set::Scalar Sort::Naturally YAML | tail -n 1"
- "cpanm Math::Random SOAP::Lite Spreadsheet::ParseExcel | tail -n 1"
- "cpanm Bio::ASN1::EntrezGene | tail -n 1"
- "cpanm Bio::Phylo | tail -n 1"
#This installs BioPerl itself:
- "perl ./Build.PL --accept"

script:
- "./Build test"

#TODO - send emails to bioperl-guts-l
notifications:
email: false

# whitelist branches
branches:
only:
- master
54 changes: 53 additions & 1 deletion Bio/Align/Utilities.pm
Expand Up @@ -101,7 +101,7 @@ require Exporter;
use base qw(Exporter);

@EXPORT = qw();
@EXPORT_OK = qw(aa_to_dna_aln bootstrap_replicates cat);
@EXPORT_OK = qw(aa_to_dna_aln bootstrap_replicates cat bootstrap_replicates_codons);
%EXPORT_TAGS = (all =>[@EXPORT, @EXPORT_OK]);
BEGIN {
use constant CODONSIZE => 3;
Expand Down Expand Up @@ -226,6 +226,58 @@ sub bootstrap_replicates {
return \@alns;
}

=head2 bootstrap_replicates_codons
Title : bootstrap_replicates_codons
Usage : my $alns = &bootstrap_replicates_codons($aln,100);
Function: Generate a pseudo-replicate of the data by randomly
sampling, with replacement, the columns from a codon alignment for
the non-parametric bootstrap. The alignment is assumed to start on
the first position of a codon.
Returns : Arrayref of L<Bio::SimpleAlign> objects
Args : L<Bio::SimpleAlign> object
Number of replicates to generate
=cut

sub bootstrap_replicates_codons {
my ($aln,$count) = @_;
$count ||= 1;
my $alen = $aln->length;
my $ncodon = int($alen/3);
my (@seqs,@nm);
$aln->set_displayname_flat(1);
for my $s ( $aln->each_seq ) {
push @seqs, $s->seq();
push @nm, $s->id;
}
my (@alns,$i);
while( $count-- > 0 ) {
my @newseqs;
for($i =0; $i < $ncodon; $i++ ) {
my $index = int(rand($ncodon));
my $seqpos = $index * 3;
my $c = 0;
for ( @seqs ) {
$newseqs[$c++] .= substr($_,$seqpos,3);
}
}
my $newaln = Bio::SimpleAlign->new();
my $i = 0;
for my $s ( @newseqs ) {
(my $tmp = $s) =~ s{[$Bio::LocatableSeq::GAP_SYMBOLS]+}{}g;
$newaln->add_seq( Bio::LocatableSeq->new
(-start => 1,
-end => length($tmp),
-display_id => $nm[$i++],
-seq => $s));
}
push @alns, $newaln;
}
return \@alns;
}


=head2 cat
Title : cat
Expand Down

0 comments on commit 9d3435f

Please sign in to comment.