Beispiel #1
0
def countNexusTrees(nexFileName) :
  """ Number of trees in a nexus file."""
  nexFile = fileFromName(nexFileName)
  c = 0
  for l in nexFile:
    if l.startswith("tree ") :
      c += 1
  return c
Beispiel #2
0
def countNexusTrees(nexFileName) :
  """ Number of trees in a nexus file (cheat: just counts number of lines
  beginning with 'tree')."""
  nexFile = fileFromName(nexFileName)
  c = 0
  for l in nexFile:
    if l.startswith("tree ") :
      c += 1
  return c
Beispiel #3
0
def getDistanceMatrix(saveName) :
  fl = fileFromName(saveName)
  labs = [x.strip() for x in next(fl)[2:].split('\t')]
  dists = array.array('f',repeat(0.0,nPairs(labs)))
  i = 0
  for x in fl:
    dists[i] = float(x.strip())
    i += 1
  fl.close()
  return dists,labs
 def __init__(self, instream) :
   self.stream = fileFromName(instream) if isinstance(instream,str) else instream
   self._grabLine()
   while self.nextline.strip() != '#NEXUS' :
     self._grabLine()