def check_for_multiple_molecule_entries(self): tp = Topology('topol.top', assign_types = False) mol_dic = OrderedDict() for m in tp.molecules: if mol_dic.has_key(m[0]): mol_dic[m[0]]+=m[1] else: mol_dic[m[0]] = m[1] tp.molecules = [] for key, val in mol_dic.items(): tp.molecules.append( [key, val] ) tp.write('topol.top')
def main(argv): options = [ Option( "-split", "bool", False, "Write splitted topologies for vdw and q morphes"), Option( "-scale_mass", "bool", True, "scale_mass"), ] files = [ FileOption("-p", "r",["top"],"topol.top", "Input Topology File"), FileOption("-itp", "r",["itp"],"topol.itp", "Optional Input ITP File"), FileOption("-o", "w",["top","itp"],"newtop.top", "Topology or ITP output file "), FileOption("-ff", "dir",["ff"],"amber99sbmut", "Mutation force field "), FileOption("-log", "w",["log"],"bstate.log", "Log file"), ] help_text = ('This script adds a B state to an .itp or .top file for a hybrid residue.', 'Hybrid residues in the topology file are recognized automatically.', '-scale_mass flag sets dummy masses to 1.0, this option is set to True by default.', 'Currently available force fields:', ' - amber99sbmut (Hornak et al, 2006)', ' - amber99sb-star-ildn-mut (Best & Hummer, 2009; Lindorff-Larsen et al, 2010)', ' - charmm22starmut.ff (Piana et al, 2011)', ' - charmm36mut (Best et al, 2012)', ' - oplsaamut (Jorgensen et al, 1996; Kaminski et al, 2001)', '', '', 'Please cite:', 'Vytautas Gapsys, Servaas Michielssens, Daniel Seeliger and Bert L. de Groot.', 'Automated Protein Structure and Topology Generation for Alchemical Perturbations.', 'J. Comput. Chem. 2015, 36, 348-354. DOI: 10.1002/jcc.23804', '', 'Old pmx (pymacs) version:', 'Daniel Seeliger and Bert L. de Groot. Protein Thermostability Calculations Using', 'Alchemical Free Energy Simulations, Biophysical Journal, 98(10):2309-2316 (2010)', '', '', '', ) cmdl = Commandline( argv, options = options, fileoptions = files, program_desc = help_text, check_for_existing_files = False ) do_scale_mass = cmdl['-scale_mass'] top_file = cmdl['-p'] out_file = cmdl['-o'] log_file = cmdl['-log'] mtp_file = os.path.join( get_ff_path(cmdl['-ff']), 'mutres.mtp') ffbonded_file = os.path.join( get_ff_path(cmdl['-ff']), 'ffbonded.itp') do_split = cmdl['-split'] if cmdl.opt['-itp'].is_set: input_itp = cmdl['-itp'] else: input_itp = None if input_itp and out_file.split('.')[-1] != 'itp': out_file = change_outfile_format(out_file, 'itp') print 'log_> Setting outfile name to %s' % out_file if input_itp: print 'log_> Reading input files "%s" and "%s"' % (top_file, input_itp) topol = Topology( input_itp, topfile = top_file, version = 'new', ff = cmdl['-ff'] ) else: print 'log_> Reading input file "%s"' % (top_file) topol = Topology( top_file, version = 'new', ff = cmdl['-ff'] ) # for i in topol.dihedrals: # print i[0].id,i[1].id,i[2].id,i[3].id m = Model( atoms = topol.atoms ) # create model with residue list topol.residues = m.residues # use model residue list rlist, rdic = get_hybrid_residues( m, mtp_file, version = 'new') topol.assign_fftypes() # correct b-states # for atom in m.atoms: # print atom.type # if atom.atomtypeB is not None: # print "typeB" # print atom.typeB for r in rlist: print 'log_> Hybrid Residue -> %d | %s ' % (r.id, r.resname ) find_bonded_entries( topol ) find_angle_entries( topol ) dih_predef_default = [] find_predefined_dihedrals(topol,rlist,rdic,ffbonded_file,dih_predef_default, cmdl['-ff']) find_dihedral_entries( topol, rlist, rdic, dih_predef_default ) __add_extra_DNA_impropers(topol, rlist, 1, [180,40,2],[180,40,2]) qA, qB = sum_charge_of_states( rlist ) qA_mem = copy.deepcopy( qA ) qB_mem = copy.deepcopy( qB ) print 'log_> Total charge of state A = ', topol.get_qA() print 'log_> Total charge of state B = ', topol.get_qB() topol.write( out_file, scale_mass = do_scale_mass, target_qB = qB ) # topol.check_special_dihedrals( ) # done normal topology for full switch if cmdl['-split']: # write splitted topology root, ext = os.path.splitext(out_file) out_file_qoff = root+'_qoff'+ext out_file_vdw = root+'_vdw'+ext out_file_qon = root+'_qon'+ext print '------------------------------------------------------' print 'log_> Creating splitted topologies............' print 'log_> Making "qoff" topology : "%s"' % out_file_qoff contQ = copy.deepcopy(qA_mem) topol.write( out_file_qoff, stateQ = 'AB', stateTypes = 'AA', dummy_qB='off', scale_mass = do_scale_mass, target_qB = qA, stateBonded = 'AA', full_morphe = False ) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------' print 'log_> Making "vdw" topology : "%s"' % out_file_vdw contQ = copy.deepcopy(qA_mem) topol.write( out_file_vdw, stateQ = 'BB', stateTypes = 'AB', dummy_qA='off', dummy_qB = 'off', scale_mass = do_scale_mass, target_qB = contQ, stateBonded = 'AB' , full_morphe = False) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------' print 'log_> Making "qon" topology : "%s"' % out_file_qon topol.write( out_file_qon, stateQ = 'BB', stateTypes = 'BB', dummy_qA='off', dummy_qB = 'on', scale_mass = do_scale_mass, target_qB = qB_mem, stateBonded = 'BB' , full_morphe = False) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------' print print 'making b-states done...........' print
def main(argv): options = [ Option("-split", "bool", False, "Write splitted topologies for vdw and q morphes"), Option("-scale_mass", "bool", True, "scale_mass"), Option("-dna", "bool", False, "generate hybrid residue for the DNA nucleotides"), Option("-rna", "bool", False, "generate hybrid residue for the RNA nucleotides"), ] files = [ FileOption("-p", "r", ["top"], "topol.top", "Input Topology File"), FileOption("-itp", "r", ["itp"], "topol.itp", "Optional Input ITP File"), FileOption("-o", "w", ["top", "itp"], "newtop.top", "Topology or ITP output file "), FileOption("-ff", "dir", ["ff"], "amber99sbmut", "Mutation force field "), FileOption("-log", "w", ["log"], "bstate.log", "Log file"), ] help_text = ( 'This script adds a B state to an .itp or .top file for a hybrid residue.', 'Hybrid residues in the topology file are recognized automatically.', '-scale_mass flag sets dummy masses to 1.0, this option is set to True by default.', 'Currently available force fields:', ' - amber99sbmut (Hornak et al, 2006)', ' - amber99sb-star-ildn-mut (Best & Hummer, 2009; Lindorff-Larsen et al, 2010)', ' - charmm22starmut.ff (Piana et al, 2011)', ' - charmm36mut (Best et al, 2012)', ' - oplsaamut (Jorgensen et al, 1996; Kaminski et al, 2001)', '', '', 'Please cite:', 'Vytautas Gapsys, Servaas Michielssens, Daniel Seeliger and Bert L. de Groot.', 'Automated Protein Structure and Topology Generation for Alchemical Perturbations.', 'J. Comput. Chem. 2015, 36, 348-354. DOI: 10.1002/jcc.23804', '', 'Old pmx (pymacs) version:', 'Daniel Seeliger and Bert L. de Groot. Protein Thermostability Calculations Using', 'Alchemical Free Energy Simulations, Biophysical Journal, 98(10):2309-2316 (2010)', '', '', '', ) cmdl = Commandline(argv, options=options, fileoptions=files, program_desc=help_text, check_for_existing_files=False) do_scale_mass = cmdl['-scale_mass'] top_file = cmdl['-p'] out_file = cmdl['-o'] log_file = cmdl['-log'] bDNA = cmdl['-dna'] bRNA = cmdl['-rna'] if bDNA: mtp_file = os.path.join(get_ff_path(cmdl['-ff']), 'mutres_dna.mtp') elif bRNA: mtp_file = os.path.join(get_ff_path(cmdl['-ff']), 'mutres_rna.mtp') else: mtp_file = os.path.join(get_ff_path(cmdl['-ff']), 'mutres.mtp') ffbonded_file = os.path.join(get_ff_path(cmdl['-ff']), 'ffbonded.itp') do_split = cmdl['-split'] if cmdl.opt['-itp'].is_set: input_itp = cmdl['-itp'] else: input_itp = None if input_itp and out_file.split('.')[-1] != 'itp': out_file = change_outfile_format(out_file, 'itp') print 'log_> Setting outfile name to %s' % out_file if input_itp: # print 'log_> Reading input files "%s" and "%s"' % (top_file, input_itp) # topol = Topology( input_itp, topfile = top_file, version = 'new', ff = cmdl['-ff'] ) print 'log_> Reading input .itp file "%s""' % (input_itp) topol = Topology(input_itp, topfile=None, version='new', ff=cmdl['-ff'], ffpath=get_ff_path(cmdl['-ff'])) else: print 'log_> Reading input .top file "%s"' % (top_file) topol = Topology(top_file, topfile=top_file, version='new', ff=cmdl['-ff']) # for i in topol.dihedrals: # print i[0].id,i[1].id,i[2].id,i[3].id m = Model(atoms=topol.atoms) # create model with residue list topol.residues = m.residues # use model residue list rlist, rdic = get_hybrid_residues(m, mtp_file, version='new') topol.assign_fftypes() # correct b-states # for atom in m.atoms: # print atom.type # if atom.atomtypeB is not None: # print "typeB" # print atom.typeB for r in rlist: print 'log_> Hybrid Residue -> %d | %s ' % (r.id, r.resname) find_bonded_entries(topol) find_angle_entries(topol) dih_predef_default = [] find_predefined_dihedrals(topol, rlist, rdic, ffbonded_file, dih_predef_default, cmdl['-ff']) find_dihedral_entries(topol, rlist, rdic, dih_predef_default) __add_extra_DNA_RNA_impropers(topol, rlist, 1, [180, 40, 2], [180, 40, 2]) qA, qB = sum_charge_of_states(rlist) qA_mem = copy.deepcopy(qA) qB_mem = copy.deepcopy(qB) print 'log_> Total charge of state A = ', topol.get_qA() print 'log_> Total charge of state B = ', topol.get_qB() topol.write(out_file, scale_mass=do_scale_mass, target_qB=qB) # topol.check_special_dihedrals( ) # done normal topology for full switch if cmdl['-split']: # write splitted topology root, ext = os.path.splitext(out_file) out_file_qoff = root + '_qoff' + ext out_file_vdw = root + '_vdw' + ext out_file_qon = root + '_qon' + ext print '------------------------------------------------------' print 'log_> Creating splitted topologies............' print 'log_> Making "qoff" topology : "%s"' % out_file_qoff contQ = copy.deepcopy(qA_mem) topol.write(out_file_qoff, stateQ='AB', stateTypes='AA', dummy_qB='off', scale_mass=do_scale_mass, target_qB=qA, stateBonded='AA', full_morphe=False) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------' print 'log_> Making "vdw" topology : "%s"' % out_file_vdw contQ = copy.deepcopy(qA_mem) topol.write(out_file_vdw, stateQ='BB', stateTypes='AB', dummy_qA='off', dummy_qB='off', scale_mass=do_scale_mass, target_qB=contQ, stateBonded='AB', full_morphe=False) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------' print 'log_> Making "qon" topology : "%s"' % out_file_qon topol.write(out_file_qon, stateQ='BB', stateTypes='BB', dummy_qA='off', dummy_qB='on', scale_mass=do_scale_mass, target_qB=qB_mem, stateBonded='BB', full_morphe=False) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------' print print 'making b-states done...........' print
def main(argv): options = [ Option( "-split", "bool", False, "Write splitted topologies for vdw and q morphes"), Option( "-scale_mass", "bool", True, "scale_mass"), ] files = [ FileOption("-p", "r",["top"],"topol.top", "Input Topology File"), FileOption("-itp", "r",["itp"],"topol.top", "Optional Input ITP File"), FileOption("-o", "w",["top","itp"],"newtop.top", "Topology or ITP output file "), FileOption("-log", "w",["log"],"bstate.log", "Log file"), ] help_text = [''] cmdl = Commandline( argv, options = options, fileoptions = files, program_desc = help_text, check_for_existing_files = False ) do_scale_mass = cmdl['-scale_mass'] top_file = cmdl['-p'] out_file = cmdl['-o'] log_file = cmdl['-log'] do_split = cmdl['-split'] if cmdl.opt['-itp'].is_set: input_itp = cmdl['-itp'] else: input_itp = None if input_itp and out_file.split('.')[-1] != 'itp': out_file = change_outfile_format(out_file, 'itp') print 'log_> Setting outfile name to %s' % out_file if input_itp: print 'log_> Reading input files "%s" and "%s"' % (top_file, input_itp) topol = Topology( input_itp, topfile = top_file) else: print 'log_> Reading input file "%s"' % (top_file) topol = Topology( top_file ) m = Model( atoms = topol.atoms ) # create model with residue list topol.residues = m.residues # use model residue list rlist, rdic = get_hybrid_residues( m, 'ffamber99sb.mtp') topol.assign_fftypes() # correct b-states for r in rlist: print 'log_> Hybrid Residue -> %d | %s ' % (r.id, r.resname ) find_bonded_entries( topol ) find_angle_entries( topol ) find_predefined_dihedrals(topol,rlist,rdic) find_dihedral_entries( topol ) __add_extra_DNA_impropers(topol, rlist, 1, [180,40,2],[180,40,2]) qA, qB = sum_charge_of_states( rlist ) qA_mem = copy.deepcopy( qA ) qB_mem = copy.deepcopy( qB ) print 'log_> Total charge of state A = ', topol.get_qA() print 'log_> Total charge of state B = ', topol.get_qB() topol.write( out_file, scale_mass = do_scale_mass, target_qB = qB ) # topol.check_special_dihedrals( ) # done normal topology for full switch if cmdl['-split']: # write splitted topology root, ext = os.path.splitext(out_file) out_file_qoff = root+'_qoff'+ext out_file_vdw = root+'_vdw'+ext out_file_qon = root+'_qon'+ext print '------------------------------------------------------' print 'log_> Creating splitted topologies............' print 'log_> Making "qoff" topology : "%s"' % out_file_qoff contQ = copy.deepcopy(qA_mem) topol.write( out_file_qoff, stateQ = 'AB', stateTypes = 'AA', dummy_qB='off', scale_mass = do_scale_mass, target_qB = qA, stateBonded = 'AA', full_morphe = False ) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------' print 'log_> Making "vdw" topology : "%s"' % out_file_vdw contQ = copy.deepcopy(qA_mem) topol.write( out_file_vdw, stateQ = 'BB', stateTypes = 'AB', dummy_qA='off', dummy_qB = 'off', scale_mass = do_scale_mass, target_qB = contQ, stateBonded = 'AB' , full_morphe = False) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------' print 'log_> Making "qon" topology : "%s"' % out_file_qon topol.write( out_file_qon, stateQ = 'BB', stateTypes = 'BB', dummy_qA='off', dummy_qB = 'on', scale_mass = do_scale_mass, target_qB = qB_mem, stateBonded = 'BB' , full_morphe = False) print 'log_> Charge of state A: %g' % topol.qA print 'log_> Charge of state B: %g' % topol.qB print '------------------------------------------------------'