Top Level Namespace

Defined Under Namespace

Modules: Bio

Instance Method Summary collapse

Instance Method Details

#getTreeObjFromMcmctree(tree_file) ⇒ Object



248
249
250
251
252
253
# File 'lib/bio/nwk.rb', line 248

def getTreeObjFromMcmctree(tree_file)
  first_line = `head -1 #{tree_file}`.chomp
  tree_txt = `tail -1 #{tree_file}`.chomp
  treeio = Bio::Newick.new(tree_txt).tree
  return([first_line, treeio])
end

#getTreeObjFromNwkString(nwk_str) ⇒ Object



241
242
243
244
245
# File 'lib/bio/nwk.rb', line 241

def getTreeObjFromNwkString(nwk_str)
  nwk = Bio::Newick.new(nwk_str)
  tree = nwk.tree
  return(tree)
end

#getTreeObjs(tree_file, num = 1000000) ⇒ Object



227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/bio/nwk.rb', line 227

def getTreeObjs(tree_file, num=1000000)
  trees = Array.new
  treeio = Bio::FlatFile.open(Bio::Newick, tree_file=='-' ? $stdin : tree_file)
  while newick = treeio.next_entry
    tree = newick.tree
    tree.options[:bootstrap_style] = :traditional
    next if tree.nodes.empty?
    trees << tree
    break if trees.size >= num
  end
  return(trees)
end