コード例 #1
0
def split_fragment_names(line, residue, resname):
    bead = gen.strip_header(line)
    group = g_var.res_top[resname]['GROUPS'][bead]
    if group not in residue:
        residue[group] = {}
    if bead not in residue[group]:
        residue[group][bead]={} 
    return residue, group, bead   
コード例 #2
0
def read_itp(filename_itp, footer=False):
    posre = {}
    molecule = {}
    mol_type = False
    atoms = False
    if os.path.exists(filename_itp):
        with open(filename_itp, 'r') as itp_input:
            for line in itp_input.readlines():
                if not (line.isspace()
                        or len(line) == 0) and not line.startswith(';'):
                    line_sep = line.split()
                    if line.startswith('[') and gen.strip_header(
                            line) == 'moleculetype':
                        mol_type = True
                    elif line.startswith('[') and gen.strip_header(
                            line) == 'atoms':
                        atoms, mol_type = True, False
                    elif line.startswith('['):
                        atoms = False
                        mol_type = False
                    elif mol_type:
                        molecule[line_sep[0]] = []
                        posre[line_sep[0]] = []
                        mol = line_sep[0]
                    elif atoms:
                        molecule[mol].append(line_sep[4])
                        if len(line.split()) >= 8:
                            if int(float(line.split()[7])) > 1:
                                posre[mol].append(
                                    '   {0:5}{1:3}{2:11}{3:11}{4:11}\n'.format(
                                        line.split()[0], 1, 50, 50, 50))
                    if '#ifdef NP' in line:
                        footer = True
        return molecule, posre, footer
    else:
        sys.exit('Cannot find itp file: ', filename_itp)
コード例 #3
0
def check_frag_file(directory, molecule):
    exists = []
    wrong = []
    for mol, beads in molecule.items():
        beads.sort()
        bead_list = []
        if os.path.exists(directory + mol + '/' + mol + '.pdb'):
            exists.append(mol)
            with open(directory + mol + '/' + mol + '.pdb', 'r') as pdb_input:
                for line_nr, line in enumerate(pdb_input.readlines()):
                    if line.startswith('['):
                        bead_list.append(gen.strip_header(line))
                bead_list.sort()

            if bead_list == beads:
                print(mol, 'Correct')
            else:
                l1 = mol + ' Incorrect: ' + directory + mol + '/' + mol + '.pdb'
                l2 = '\nMartini ' + mol + ': ' + ', '.join(map(str, beads))
                l3 = '\nCG2AT2  ' + mol + ': ' + ', '.join(map(str, bead_list))
                wrong.append([l1 + l2 + l3])
    for residue in wrong:
        print(residue)
    return exists