Beispiel #1
0
#valid_indices = np.concatenate((np.arange(1,48), np.arange(88,91)))
valid_indices = np.arange(1, 42)
valid_indices = ['{}'.format(val) for val in valid_indices]
#renumber_indices = {"88": "48", "89":"49", "90":"50"}

original_itp = open('dppc.itp', 'r').readlines()
itplines = itp_utils.remove_comments(original_itp)
newitp = []

newitp.append('; Made by alex on {}\n'.format(datetime.datetime.now()))
newitp.append('[ moleculetype ]\n')
newitp.append(' ; name	nrexcl\n')
newitp.append('pchd      3\n')

atoms_section = itp_utils.read_section('atoms', itplines)
newitp.append('[ atoms ]\n')
newitp.append('; nr	type	resnr	residu	atom	cgnr	charge	mass\n')

for line in atoms_section:
    first = line.split()[0]
    if _is_valid([first], valid_indices):
        newline = line.split()
        #if newline[0] in renumber_indices:
        #    newline[0] = renumber_indices[newline[0]]
        #if newline[5] in renumber_indices:
        #    newline[5] = renumber_indices[newline[5]]

        line = "{:6}{:6}{:6}{:6}{:6}{:6}{:8}{:8}".format(*newline)
        newitp.append(line + "\n")
## Pull the atomtypes from the itp files
## Print out the atomtypes that aren't yet included in types.txt
## This is useful for expanding our lammps charmm36 forcefield with
## Atomtypes from new gromacs itp files
####################

atomtype_dict = xml_utils.parse_type_dict(xml_utils.ATOMTYPES_FILE())
curr_dir = os.getcwd()
atomtypes = []
# Iterate through all prottype folders, picking out the atomtypes from the itp file
all_folders = [thing for thing in os.listdir() if os.path.isdir(thing)]
for folder in all_folders:
    os.chdir(os.path.join(curr_dir, folder))
    itpfile = [thing for thing in os.listdir() if os.path.isfile(thing) \
            and 'itp' in thing[-4:]]

    if itpfile:
        itpfile = glob.glob('*.itp')[0]
        itplines = open(itpfile, 'r').readlines()
        itplines = itp_utils.remove_comments(itplines)
        atomtype_lines = itp_utils.read_section('atoms', itplines)
        for line in atomtype_lines:
            atomtypes.append(line.split()[1])

# Look for all the new and unique atomtypes
atomtypes = set(atomtypes)
atomtype_dict = set(atomtype_dict)
uniques = atomtypes - atomtype_dict
for i in sorted(list(uniques)):
    print(i)
Beispiel #3
0
import networkx as nx
import pdb

import scripts.itp_utils as itp_utils

itpfile = open('ecer3.itp','r').readlines()
itpfile = itp_utils.remove_comments(itpfile)
bonds = itp_utils.read_section('bonds', itpfile)
pairs = itp_utils.read_section('pairs', itpfile) # For verification


# Make a Network X graph by adding edges for each bond
bondgraph = nx.Graph()
for line in bonds:
    first = line.split()[0]
    second = line.split()[1]
    bondgraph.add_edge(first,second)
# Cool, we are definitely getting all the bonds here


count =0 
# all pairs is actually a set of quadruples corresponding to the atoms (and
# the ones in between) that make the pair
all_quadruples = set()
all_pairs = set()
for n1 in bondgraph.nodes_iter():
    for n2 in bondgraph.nodes_iter():
        path = nx.shortest_path(bondgraph, n1,n2)
        if len(path) == 4:
            pair = (sorted((n1,n2))[0], sorted((n1,n2))[1])
            if pair not in all_pairs: