예제 #1
0
def test_run_with_StringIO_log():
    stringio_file = StringIO()
    with tempfolder():
        run(
            arg_pdbout='out.pdb',
            arg_pdbin=get_fn('4lzt/4lzt_h.pdb'),
            arg_logfile=stringio_file)
    stringio_file.seek(0)
    assert 'Summary of pdb4amber' in stringio_file.read()
예제 #2
0
def prepare_mcpb_input(structures, software_version='g09', cut_off=2.8):
    """
    Get all the substructure files and prepare the MCPB.py input
    """
    template = dedent("""
    original_pdb master.pdb
    group_name {name}
    cut_off {cut_off}
    ion_ids {metal_id}
    ion_mol2files {metal_mol2}
    naa_mol2files {residues_mol2}
    frcmod_files {residues_frcmod}
    large_opt 1
    software_version {software_version}
    """)

    # First collect all files in the same master PDB
    pdbfiles = [
        s['pdb'] for s in structures['metals'] + structures['residues']
    ]
    if 'pdb' in structures['protein']:
        pdbfiles.append(structures['protein']['pdb'])

    with open('master.unfixed.pdb', 'w') as f:
        for line in fileinput(pdbfiles):
            f.write(line)

    # Fix residue numbering issues
    pdb4amber.run(arg_pdbin='master.unfixed.pdb', arg_pdbout='master.pdb')

    name = os.path.basename(os.getcwd())
    with open('mcbp.in', 'w') as f:
        f.write(
            template.format(
                name=name,
                metal_id=' '.join(
                    map(str, range(1,
                                   len(structures['metals']) + 1))),
                metal_mol2=' '.join([s['mol2'] for s in structures['metals']]),
                residues_mol2=' '.join(
                    [r['mol2'] for r in structures['residues']]),
                residues_frcmod=' '.join(
                    [r['frcmod'] for r in structures['residues']]),
                cut_off=cut_off,
                software_version=software_version,
            ))

    return 'mcbp.in'
예제 #3
0
def test_run_with_filename_log():
    # default
    logfile = 'pdb4amber.log'
    with tempfolder():
        run(arg_pdbout='out.pdb', arg_pdbin=get_fn('4lzt/4lzt_h.pdb'))
        with open(logfile) as fh:
            assert 'Summary of pdb4amber' in fh.read()

    # given name
    logfile = 'hello.log'
    with tempfolder():
        run(
            arg_pdbout='out.pdb',
            arg_pdbin=get_fn('4lzt/4lzt_h.pdb'),
            arg_logfile=logfile)
        with open(logfile) as fh:
            assert 'Summary of pdb4amber' in fh.read()
예제 #4
0
def prepare_protein_amber(protein, ph=7):
    """
    Prepare molecule to contain correct residues, capping groups, and so on,
    using pdb4amber

    Parameters
    ==========
    molecule : chimera.Molecule

    Returns
    =======
    pdb
    """
    print('Preparing', protein.name, '...')
    inpdb = protein.basename + '.unfixed.pdb'
    chimera.pdbWrite([protein], protein.openState.xform, inpdb)
    pdb4amber.run(arg_pdbin=inpdb,
                  arg_pdbout=protein.basename + '.pdb',
                  arg_reduce=True)
    return protein.basename + '.pdb'