示例#1
0
 def read_structure(f):
     atoms, coordinates = [], []
     line = f.readline()
     while line != '\n':
         line = line.split()
         atoms.append(line[1])
         coordinates.append(line[5:])
         line = f.readline()
     molecule = cc.Cartesian(atoms=atoms, coords=coordinates)
     remove_digits = partial(re.sub, r'[0-9]+', '')
     molecule['atom'] = molecule['atom'].apply(remove_digits)
     return molecule
示例#2
0
    def set_cc_positions(self, positions):
        """
        Calculates the zmat from an OpenMM modeller

        Args:
            positions (list): A list 
        """
        cc_df = self._get_cartesian_df(positions)
        self.cartesian = cc.Cartesian(cc_df)
        self.cartesian.set_bonds(self.cc_bonds)
        self.cartesian._give_val_sorted_bond_dict(use_lookup=True)
        self.zmat = self.cartesian.get_zmat(use_lookup=True)
示例#3
0
文件: IOmod.py 项目: hopefulp/sandbox
 def to_Cartesian(self):
     """
     transforms the molecule into a chemcoord.Cartesian object
     """
     natoms = self.xyz.shape[0]
     elems = copy.deepcopy(self.elements)
     for i, j in enumerate(elems): 
         elems[i] = j.strip().capitalize()
     xyz = pandas.DataFrame(self.xyz, columns=["x","y","z"], dtype='float64')
     elems = pandas.DataFrame(elems, columns=["atom"], dtype='str')
     output = chemcoord.Cartesian(pandas.concat([elems, xyz], axis=1))
     output.index = range(1, natoms+1)
     return output
示例#4
0
    if torsion[0] is not None:
        angle0 = torsion[0] * 180 / pi
    if torsion[1] is not None:
        angle1 = torsion[1] * 180 / pi
    print((angle0, angle1))

bonds = {}
num_atoms = len(rows)
bonds[0] = {1}
bonds[num_atoms - 1] = {num_atoms - 2}
for i in range(1, num_atoms - 1):
    bonds[i] = {i - 1, i + 1}
print(bonds)

df = pd.DataFrame(rows, columns=['atom', 'x', 'y', 'z'])
molecule = cc.Cartesian(df)
molecule.set_bonds(bonds)
zmat = molecule.get_zmat(use_lookup=True)
zmat_copy = molecule.get_zmat(use_lookup=True)
molecule.to_xyz(buf='xyz/1ubq_cart.xyz')

for i in range(10):
    zmat.safe_loc[:, 'dihedral'] = np.random.uniform(-10*i, 10*i, num_atoms) + zmat_copy.safe_loc[:, 'dihedral']
    xyz = zmat.get_cartesian()
    xyz.to_xyz(buf=f'xyz/1ubq_transform_{i}.xyz')
    




示例#5
0
def test_init():
    with pytest.raises(ValueError):
        cc.Cartesian(5)
    with pytest.raises(PhysicalMeaning):
        cc.Cartesian(molecule.loc[:, ['atom', 'x']])
示例#6
0
    cc_bonds[bond[0].index].add(bond[1].index)
    cc_bonds[bond[1].index].add(bond[0].index)

print(len(nitro_list))
for nitro in nitro_list:
    print(nitro)

with pd.option_context('display.max_rows', None):
    cc_df = pd.DataFrame({
        'atom': atom_names,
        'x': cc_positions[0, :],
        'y': cc_positions[1, :],
        'z': cc_positions[2, :]
    })

    molecule = cc.Cartesian(cc_df)
    molecule.set_bonds(cc_bonds)
    molecule._give_val_sorted_bond_dict(use_lookup=True)
    zmat = molecule.get_zmat(use_lookup=True)
    zmat.to_zmat(buf='zmat.xyz', implicit_index=False)
    molecule2 = zmat.get_cartesian()

    phi_indices = []
    psi_indices = []

    print('getting angles')
    print(zmat.shape)
    for i in range(len(zmat.index)):
        b_index = zmat.loc[i, 'b']
        a_index = zmat.loc[i, 'a']
        d_index = zmat.loc[i, 'd']