BuildACell / bioCRNpyler

A modular compiler for biological chemical reaction networks
BSD 3-Clause "New" or "Revised" License
39 stars 24 forks source link

CRN.species is a DataFrame #108

Open dr3y opened 4 years ago

dr3y commented 4 years ago

it would be nice if species in a CRN (and reactions!?) were in a dataframe format so you could pull out certain species for example CRN.species(type="rna") = [rna_myrna1,rna_myrna2]

zoltuz commented 4 years ago

Something like this would do it:

class ChemicalReactionNetwork(object):
    @species.setter
    def species(new_species: List[Species]=None, type=None):
        if new_species:
          self._species += new_species
        elif type:
         return Species._filter_by_type(self._species,type=type)
        else: 
          pass

But the one above looks messy, now that I'm writing it out. Probably CRN.get_species would be better since we want to filter by type and etc

 class ChemicalReactionNetwork(object):
       def get_species(type=None) -> List[Species]:
        if type:
          return Species._filter_by_type(self.species,type=type)
        else:
          return self.species