sjspielman / pyvolve

Python library to simulate evolutionary sequence data
Other
78 stars 23 forks source link

Bug in Newick parser? #8

Closed niemasd closed 7 years ago

niemasd commented 7 years ago

I'm using the newest version of Pyvolve, and when I try to do the following:

pyvolve.read_tree(tree="(n2:1.0,((((((((n56:0.6475223596157642,n57:0.6475223596157642)n54:0.3524776403842358,n55:1.0)n42:0.2654658255151503,(((n118:0.24129027449114204,n119:0.24129027449114204)n114:0.758709725508858,((n120:0.01428012360314046,n121:0.01428012360314046)n116:0.5795750490559373,n117:0.5938551726590777)n115:0.4061448273409223)n44:0.0985984413379688,(n98:1.0,n99:1.0)n45:0.0985984413379688)n43:0.1668673841771815)n40:0.7345341744848497,(n84:1.0,n85:1.0)n41:1.0)n18:1.0,(((n90:0.09356455295017163,n91:0.09356455295017163)n88:0.9064354470498284,n89:1.0)n36:1.0,(n86:1.0,n87:1.0)n37:1.0)n19:1.0)n10:0.15465752049837356,(n12:1.0,(n20:1.0,(n96:1.0,n97:1.0)n21:1.0)n13:1.0)n11:0.15465752049837356)n6:0.8453424795016264,(n8:0.6954629395200476,(((((n112:0.36007064074068484,n113:0.36007064074068484)n108:0.6399293592593152,(n110:0.9913955783925932,n111:0.9913955783925932)n109:0.00860442160740682)n38:1.0,(n94:1.0,n95:1.0)n39:1.0)n16:0.13535292826182932,(((n52:1.0,n53:1.0)n34:0.10733289976195692,(n122:1.0,n123:1.0)n35:0.10733289976195692)n30:0.8926671002380431,((n80:1.0,(n82:0.13725497148778043,n83:0.13725497148778043)n81:0.8627450285122196)n32:0.16079424163593004,(((n72:0.4225806689965319,n73:0.4225806689965319)n64:0.24409158840864364,n65:0.6666722574051756)n60:0.33332774259482445,((n68:0.5538821907422786,(n70:0.49394028150939295,(n74:0.30648857452890876,n75:0.30648857452890876)n71:0.1874517069804842)n69:0.05994190923288567)n62:0.17627910447377815,((n76:0.2785436804342538,(n78:0.13836872822238622,n79:0.13836872822238622)n77:0.1401749522118676)n66:0.2973501105453762,n67:0.57589379097963)n63:0.15426750423642677)n61:0.26983870478394323)n33:0.16079424163593004)n31:0.83920575836407)n17:0.13535292826182932)n14:0.8646470717381707,(((((n50:0.3890617300464161,n51:0.3890617300464161)n48:0.6109382699535839,n49:1.0)n26:0.3772004420228381,(((n104:0.1457241995579146,n105:0.1457241995579146)n100:0.8542758004420854,((n106:0.01824109586901379,n107:0.01824109586901379)n102:0.5273851721555571,n103:0.5456262680245709)n101:0.4543737319754291)n28:0.27708888226881445,(n92:1.0,n93:1.0)n29:0.27708888226881445)n27:0.10011155975402364)n24:0.3922374106852251,(n58:1.0,n59:1.0)n25:0.7694378527080632)n22:0.2305621472919368,(n46:1.0,n47:1.0)n23:1.0)n15:1.0)n9:0.6954629395200476)n7:0.30453706047995244)n4:1.0,n5:1.0)n3:1.0)n1;")

I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/pyvolve/newick.py", line 119, in read_tree
    (tree, flags, internalNode_count, index) = _parse_tree(tstring, flags, internalNode_count, scale_tree, 0) 
  File "/usr/local/lib/python3.6/site-packages/pyvolve/newick.py", line 344, in _parse_tree
    if tstring[index]==':':
IndexError: string index out of range

I opened my Newick string in an online Newick viewer, and it looks fine structurally in comparison to the example tree (i.e., each node has either 0 or 2 children, and I have edge weights).

sjspielman commented 7 years ago

This issue has been resolved. Bug fixed which prevented Pyvolve from parsing trees with a user-labeled root. Please update to v0.8.4. Thanks!

niemasd commented 7 years ago

Works great now, thanks so much for the quick response!