Skip to content

Commit

Permalink
Fixing some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
evogytis committed Jun 28, 2023
1 parent 61e46a4 commit 6a7bf34
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions baltic/baltic.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def renameTips(self,d=None):
k.name=d[k.name] ## change its name

def sortBranches(self,descending=True,sort_function=None,sortByHeight=True):
mod=-1 if descending else -1
mod=-1 if descending else 1
if sort_function==None: sort_function=lambda k: (k.is_node(),-len(k.leaves)*mod,k.length*mod) if k.is_node() else (k.is_node(),k.length*mod)
if sortByHeight: # Sort nodes by height and group nodes and leaves together
""" Sort descendants of each node. """
Expand Down Expand Up @@ -1273,12 +1273,12 @@ def loadNexus(tree_path,tip_regex='\|([0-9]+\-[0-9]+\-[0-9]+)',date_fmt='%Y-%m-%
for line in handle:
l=line.strip('\n')

cerberus=re.search('dimensions ntax=([0-9]+);',l.lower())
cerberus=re.search('Dimensions ntax=([0-9]+);',l)
if cerberus is not None:
tipNum=int(cerberus.group(1))
if verbose==True: print('File should contain %d taxa'%(tipNum))

cerberus=re.search(treestring_regex,l.lower())
cerberus=re.search(treestring_regex,l)
if cerberus is not None:
treeString_start=l.index('(')
ll=make_tree(l[treeString_start:]) ## send tree string to make_tree function
Expand All @@ -1292,7 +1292,7 @@ def loadNexus(tree_path,tip_regex='\|([0-9]+\-[0-9]+\-[0-9]+)',date_fmt='%Y-%m-%
elif ';' not in l:
print('tip not captured by regex:',l.replace('\t',''))

if 'translate' in l.lower():
if 'Translate' in l:
tipFlag=True
if ';' in l:
tipFlag=False
Expand Down

0 comments on commit 6a7bf34

Please sign in to comment.