Ejemplo n.º 1
0
    def from_dict(cls, json_obj):
        """Recreate an object from the JSON representation.

        Parameters
        ----------
            json_obj : dict
                JSON representation
        Returns
        -------
            StatMech : StatMech object
        """
        json_obj = json_pMuTT.remove_class(json_obj)
        name = json_obj['name']
        trans_model = json_pMuTT.json_to_pMuTT(json_obj['trans_model'])
        vib_model = json_pMuTT.json_to_pMuTT(json_obj['vib_model'])
        rot_model = json_pMuTT.json_to_pMuTT(json_obj['rot_model'])
        elec_model = json_pMuTT.json_to_pMuTT(json_obj['elec_model'])
        nucl_model = json_pMuTT.json_to_pMuTT(json_obj['nucl_model'])
        notes = json_obj['notes']

        return cls(name=name,
                   trans_model=trans_model,
                   vib_model=vib_model,
                   rot_model=rot_model,
                   elec_model=elec_model,
                   nucl_model=nucl_model,
                   notes=notes)
Ejemplo n.º 2
0
    def from_dict(cls, json_obj):
        """Recreate an object from the JSON representation.

        Parameters
        ----------
            json_obj : dict
                JSON representation
        Returns
        -------
            Nasa : Nasa object
        """
        json_obj = remove_class(json_obj)
        # Reconstruct statmech model
        json_obj['statmech_model'] = json_to_pMuTT(json_obj['statmech_model'])
        json_obj['references'] = json_to_pMuTT(json_obj['references'])
        json_obj['cat_site'] = json_to_pMuTT(json_obj['cat_site'])
        json_obj['mix_models'] = json_to_pMuTT(json_obj['mix_models'])
        return cls(**json_obj)
Ejemplo n.º 3
0
    def from_dict(cls, json_obj):
        """Recreate an object from the JSON representation.

        Parameters
        ----------
            json_obj : dict
                JSON representation
        Returns
        -------
            EmpiricalBase : EmpiricalBase object
        """
        json_obj = remove_class(json_obj)
        # Reconstruct statmech model
        json_obj['statmech_model'] = \
            json_to_pMuTT(json_obj['statmech_model'])
        json_obj['references'] = \
            json_to_pMuTT(json_obj['references'])
        json_obj['mix_models'] = \
            [json_to_pMuTT(mix_model) for mix_model in json_obj['mix_models']]

        return cls(**json_obj)
Ejemplo n.º 4
0
    def from_dict(cls, json_obj):
        """Recreate an object from the JSON representation.

        Parameters
        ----------
            json_obj : dict
                JSON representation
        Returns
        -------
            PhaseDiagram : PhaseDiagram object
        """
        json_obj = remove_class(json_obj)
        json_obj['reactions'] = [json_to_pMuTT(reaction)
                                 for reaction in json_obj['reactions']]
        return cls(**json_obj)
Ejemplo n.º 5
0
    def from_dict(cls, json_obj):
        """Recreate an object from the JSON representation.

        Parameters
        ----------
            json_obj : dict
                JSON representation
        Returns
        -------
            References : References object
        """
        json_obj = remove_class(json_obj)
        json_obj['offset'] = np.array(json_obj['offset'])
        json_obj['references'] = [json_to_pMuTT(ref_dict)
                                  for ref_dict in json_obj['references']]
        return cls(**json_obj)
Ejemplo n.º 6
0
Archivo: db.py Proyecto: himaghna/pMuTT
    def find(self, **kwargs):
        """Find records in collection using desired criteria

        Parameters
        ----------
            max_records : int
                Maximum number of records to return
            kwargs : keyword arguments
                Arguments to use for `self.collection.find` method. See 
                `pymongo.collection.Collection.find`_ method
        Returns
        -------
            results : list of pMuTT objects
        .. _`pymongo.collection.Collection.find`: http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.find     
        """
        return [
            json_to_pMuTT(result) for result in self.collection.find(**kwargs)
        ]
Ejemplo n.º 7
0
Archivo: db.py Proyecto: himaghna/pMuTT
    def get_specie_from_smiles(self, smiles, obj_type=None, max_records=1):
        """Searches database for object matching SMILES string

        Parameters
        ----------
            smiles : str
                Smiles representation of interested species
            obj_type : str, optional
                Type of object to return. Default will return the first
                encountered specie matching the smiles string regardless of
                type. Suggested types are:
                
                - 'nasa'
                - 'shomate'
                - 'statmech'

            max_records : int, optional
                Maximum number of records to find. Set this parameter to a
                -1 if all records are desired. Default is 1
        Returns
        -------
            specie : pMuTT model object or list of pMuTT model objects
                Object(s) representing the interested species
        """
        # Set up filter to find records
        db_filter = {'smiles': smiles}
        if obj_type is not None:
            db_filter['type'] = obj_type

        # Get species from database
        species = []
        for i, result in enumerate(self.collection.find(filter=db_filter)):
            specie = json_to_pMuTT(result)
            # Only return one record if desired
            if max_records == 1:
                species = specie
                break
            species.append(specie)
            # Determine if record limit reached
            if (i + 1) == max_records:
                break
        return species