tlubitz / SBtab

SBtab - Table format for Systems Biology:
www.sbtab.net
MIT License
6 stars 8 forks source link

adding SBtabTable to SBtabDocument fails #103

Closed eladnoor closed 3 years ago

eladnoor commented 3 years ago

As far as I understand, now SBtabTable can also be created without a filename. In this case, the attribute will not exist. When using SBtabDocument.add_sbtab(), however, the filename is copied from the input argument, and if it was not initialized, there is an AttributeError.

To recreate the bug:

In [2]: from sbtab import SBtab                                                                                                                       

In [3]: a = SBtab.SBtabTable()                                                                                                                        

In [4]: b = SBtab.SBtabDocument()                                                                                                                      

In [5]: b.add_sbtab(a)                                                                                                                                
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-702e1fdff3e7> in <module>
----> 1 b.add_sbtab(a)

~/git/equilibrator-pathway/venv/lib/python3.8/site-packages/sbtab/SBtab.py in add_sbtab(self, sbtab)
    987         '''
    988         if not self.filename:
--> 989             self.filename = sbtab.filename
    990 
    991         if sbtab.table_id in self.id_to_sbtab.keys():

AttributeError: 'SBtabTable' object has no attribute 'filename'