Skip to content

Commit 7a05f06

Browse files
author
wqiu
committed
biotree: add --boot-all; bioaln: add orf-slice
1 parent defb068 commit 7a05f06

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

bin/bioaln

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,17 +416,18 @@ Generate an alignment of every-third (mostly synonymous) bases (assuming a CDS a
416416

417417
Make a shuffled (not bootstrapped, which is sampling I<with> replacement) alignment. This operation I<permutes> alignment columns. It is used for testing the significance of long-runs of conserved sites in an alignment (e.g., conserved intergenic spacer sequences).
418418

419-
=item --slice, -s 'start|-,end|-'
419+
=item --slice, -s 'start|-,end|-'; or -s"file:orfs.tsv"
420420

421421
Get a slice of the alignment.
422422

423423
Using a '-' character in the first or second position defaults to the beginning or end, respectively. Therefore specifying -s'-,-' is the same as grabbing the whole alignment.
424424

425-
--slice'20,80' or --slice '20,80' or -s='20,80' or --slice='20,80': Slice from position 20 to 80, inclusive.
426-
--slice'-,80': Slice from beginning up to, and including position 80
427-
--slice'20,-': Slice from position 20 up to, and including, the end of the alignment
425+
--slice '20,80' or --slice '20,80' or -s='20,80' or --slice='20,80': Slice from position 20 to 80, inclusive.
426+
--slice '-,80': Slice from beginning up to, and including position 80
427+
--slice '20,-': Slice from position 20 up to, and including, the end of the alignment
428+
--slice 'file:orfs.tsv': slice using coordinates from a file. The file should contain 4 tab/space-delimited columns: locus_tag (no space), start (numerical), end (numerical), strand(0/1)
428429

429-
NOTE: --slice'-,x' (where x is '-' or a position) does NOT work. Use --slice='-,x' (or a space in place of =) instead.
430+
NOTE: --slice'-,x' (where x is '-' or a position) without a space does NOT work. Use --slice='-,x' (or a space in place of =) instead.
430431

431432
=item --split-cdhit <cdhit clrs file>
432433

bin/biotree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ GetOptions(\%opts,
2121
"man",
2222
"version|V",
2323
"as-text|t", # for preview text tree
24+
"boot-all", # show support values
2425
"ci|c=s", # attach binary trait table
2526
"clean-br|b",
2627
"clean-boot|B",
@@ -123,6 +124,10 @@ B<biotree> supports reading from STDIN, so that multiple tree manipulations coul
123124

124125
Draw an ASCII tree for quick preview (needs refinement). Default max screen width 100 characters.
125126

127+
=item --boot-all
128+
129+
Show support values for all nodes
130+
126131
=item --ci, -c 'binary-trait-file'
127132

128133
Attach a file containing binary trait values and prints consistency index for informative sites (not verified)

lib/Bio/BPWrapper/AlnManipulations.pm

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,37 @@ with improvements.
809809

810810

811811
sub aln_slice { # get alignment slice
812-
my ($begin, $end) = split(/\s*,\s*/, $opts{"slice"});
813-
812+
my $opt_str = $opts{"slice"};
813+
my $id;
814+
my $begin;
815+
my $end;
816+
my $strand;
817+
if ($opt_str =~ /^file:(\S+)$/) {
818+
my $fname = $1;
819+
open COORD, "<", $fname;
820+
while(<COORD>) {
821+
chomp;
822+
($id, $begin, $end, $strand) = split;
823+
}
824+
} else {
825+
($begin, $end) = split(/\s*,\s*/, $opt_str);
826+
}
827+
814828
# Allow for one parameter to be omitted. Default $begin to the
815829
# beginning of the alignment, and $end to the end.
816830
$begin = 1 if $begin eq "-";
817831
$end = $aln->length if $end eq "-";
818-
$aln = $aln->slice($begin, $end)
832+
$aln = $aln->slice($begin, $end);
833+
if ($strand && $strand == 0) {
834+
my $new_aln = Bio::SimpleAlign -> new();
835+
foreach ($aln->each_seq) {
836+
my $revcom = $_ -> revcom();
837+
my $end = $_ -> end;
838+
$revcom->end($end);
839+
$new_aln->add_seq($revcom);
840+
}
841+
$aln = $new_aln;
842+
}
819843
}
820844

821845
=head2 get_unique()

lib/Bio/BPWrapper/TreeManipulations.pm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ Call this after calling C<#initialize(\%opts)>.
11881188

11891189
sub write_out {
11901190
my $opts = shift;
1191+
print_all_boots() if $opts->{'boot-all'};
11911192
print_all_node_ids() if $opts->{'ids-all'};
11921193
rename_tips() if $opts->{'rename-tips'};
11931194
write_tab_tree() if $opts->{'as-text'};
@@ -1337,6 +1338,17 @@ sub print_all_node_ids {
13371338
}
13381339
}
13391340

1341+
1342+
sub print_all_boots {
1343+
my %visited;
1344+
my @node_list = ($rootnode);
1345+
&_wu($rootnode, \%visited, \@node_list);
1346+
foreach (@node_list) {
1347+
next if $_->is_Leaf || $_ eq $rootnode;
1348+
print $_->internal_id(), "\t", $_->id() || "NA", "\n";
1349+
}
1350+
}
1351+
13401352
sub _treeheight {
13411353
my $height = 0;
13421354
my $tree = $_[0];

0 commit comments

Comments
 (0)