lib/rphylip.rb in rphylip-0.1.0 vs lib/rphylip.rb in rphylip-0.2.0
- old
+ new
@@ -93,9 +93,18 @@
n += num_newseqs
i += 1
end
i
end
+ def remove_taxa(taxa, pruned_phylip)
+ puts "Original size #{@seqs.size}, after removal expect #{@seqs.size - taxa.size}"
+ raise "empty list of taxa to prune" if not taxa or taxa.empty?
+ taxa.each do |taxon|
+ @seqs.delete_if{|l| l.split.first.strip == taxon}
+ end
+ self.save_as(pruned_phylip)
+ puts "Final size #{@seqs.size} saved in #{pruned_phylip}"
+ end
def save_as(newfile)
self.save_seqs_as(@seqs, newfile)
end
def save_seqs_as(seqs, newfile)
File.open(newfile, "w") do |f|