Skip to content

Instantly share code, notes, and snippets.

@armanbilge
Created August 9, 2013 23:29
Show Gist options
  • Save armanbilge/6198178 to your computer and use it in GitHub Desktop.
Save armanbilge/6198178 to your computer and use it in GitHub Desktop.
Isolates a target tree from a BEAST trees file
#!/usr/bin/env perl
#
# isolate_target_tree.pl
# Usage: isolate_target_tree.pl <target_tree_id> <trees_file>
use strict;
use warnings;
my $target_tree = shift;
# Print up to the first tree declaration, then print only the target tree
my $is_preamble = 1;
while (<>) {
$is_preamble = 0 if /^tree STATE_.*/;
print if $is_preamble or /$target_tree\s/;
}
print "End;\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment