示例#1
0
 def setUp(self):
     self.compound1 = Compound({
         "a1": "H",
         "a2": "O"
     }, {"b1": ("a1", "a2", {
         'order': 1,
         'chirality': None
     })}, {"id": "Hydroxide"})
     self.compound2 = Compound({
         "a1": "H",
         "a2": "H",
         "a3": "O",
         "a4": "H"
     }, {
         "b1": ("a1", "a3", {
             'order': 1,
             'chirality': None
         }),
         "b2": ("a2", "a3", {
             'order': 1,
             'chirality': None
         }),
         "b3": ("a3", "a4", {
             'order': 1,
             'chirality': None
         })
     }, {"id": "Hydronium"})
     self.acid1 = Acid(self.compound2, 'a1', -1.74)
     self.base1 = Base(self.compound1, 'a2', 16)
示例#2
0
    def to_compound(self):
        """Transforms the molecule dictionary into a Compound object"""

        self.compound = [
            Compound(self.molecule['atoms'], self.molecule['bonds'],
                     self.molecule['other_info']),
            Compound({}, {}, {})
        ]
示例#3
0
def compound_from_dict(atoms, bonds, other):
    """Builds a compound from dictionaries representing the atoms, bonds, and
    other necessary information.

    Parameters
    ----------
    atoms : dict
        Dictionary storing all of the atomic information.  Should be in form
        `{'a1': 'H', 'a2': 'O', 'a3': 'H'}`.
    bonds : dict
        Dictionary storing all of the bond information.  Should be in form
        `{'b1': ('a1', 'a2', {'order': 1}), 'b2': ('a2', 'a3', {'order': 1})}`.
    other : dict
        Dictionary storing any other available information about the molecule.

    Returns
    -------
    Compound
        The compound object that stores all of this information.

    Notes
    -----
    - The `other` dictionary can have a lot of information.  For example, data
    necessary to write the data to a specific filetype.  This should be stored
    as something like `cml`: {information necessary}.  Certain assumptions
    are/will be made by the API and will be documented as necessary.
    - This function is a thin wrapper for the Compound constructor.
    """

    return Compound(atoms, bonds, other)
示例#4
0
    def setUp(self):
        self.compound1 = Compound({
            "a1": "H",
            "a2": "O"
        }, {"b1": ("a1", "a2", {
            'order': 1,
            'chirality': None
        })}, {"id": "Hydroxide"})
        self.compound2 = Compound({
            "a1": "H",
            "a2": "H",
            "a3": "O",
            "a4": "H"
        }, {
            "b1": ("a1", "a3", {
                'order': 1,
                'chirality': None
            }),
            "b2": ("a2", "a3", {
                'order': 1,
                'chirality': None
            }),
            "b3": ("a3", "a4", {
                'order': 1,
                'chirality': None
            })
        }, {"id": "Hydronium"})
        self.compound3 = Compound({
            'a1': 'H',
            'a2': 'O',
            'a3': 'H'
        }, {
            'b1': ('a1', 'a2', {
                'order': 1,
                'chirality': None
            }),
            'b2': ('a2', 'a3', {
                'order': 1,
                'chirality': None
            })
        }, {'id': "Water"})

        self.acid = Acid(self.compound2, 'a1', -1.74)
        self.base = Base(self.compound1, 'a2', 16)
        self.conj_acid = Acid(self.compound3, 'a3', 16)
        self.conditions = Conditions({})
示例#5
0
 def setUp(self):
     self.water = Compound({
         'a1': 'H',
         'a2': 'H',
         'a3': 'O'
     }, {
         'b1': ('a1', 'a3', {
             'order': 1
         }),
         'b2': ('a2', 'a3', {
             'order': 1
         })
     }, {})
示例#6
0
def _parser_to_compound(parsed_file):
    """Takes the result of parsing a file and turns it into a compound object.

    Parameters
    ----------
    parsed_file : some parser object
        The parser object that has already parsed a molecular file.

    Returns
    -------
    Compound
        The resulting compound.
    """

    return Compound(parsed_file.atoms, parsed_file.bonds, parsed_file.other)
示例#7
0
    def test_water(self):
        water = Compound({
            'a1': 'H',
            'a2': 'H',
            'a3': 'O'
        }, {
            'b1': ('a1', 'a3', {
                'order': 1
            }),
            'b2': ('a2', 'a3', {
                'order': 1
            })
        }, {})

        self.assertFalse(water.resonance_structures)
        for atom in water.atoms.itervalues():
            self.assertFalse(atom.could_resonate())
        for bond in water.bonds.itervalues():
            self.assertFalse(bond.could_resonate())
示例#8
0
 def test_eq_compound(self):
     comp = Compound({}, {}, {})
     prod = Product(comp, {})
     self.assertEqual(prod, comp)
示例#9
0
 def test_getattr(self):
     comp = Compound({}, {}, {})
     prod = Product(comp, {})
     self.assertFalse('node' in vars(prod))
     self.assertTrue('node' in vars(comp))
     self.assertIs(prod.node, comp.node)