Exemplo n.º 1
0
def run(args=(), params=None, out=sys.stdout):
    assert (params.convert.file_name is not None)
    file_name = params.convert.file_name
    error_message = 'Unable to parse %s. ' % file_name
    error_message += 'Please make sure that the file exists and is a valid model in PDB or CIF format.'
    if (not os.path.exists(file_name)):
        raise Sorry(error_message)
    try:
        model = pdb_input_from_any(file_name=file_name)
    except Exception:
        raise Sorry(error_message)
    output_file = os.path.splitext(os.path.basename(file_name))[0]
    if (model.file_format == "pdb"):
        print >> out, "Converting %s to mmCIF format." % file_name
        run_program(program_class=pdb_as_cif.Program, args=[file_name])
        output_file += '.cif'
    elif (model.file_format == 'cif'):
        print >> out, "Converting %s to PDB format." % file_name
        cif_as_pdb.run([file_name])
        output_file += '.pdb'
    else:
        raise Sorry(error_message)
    if (not os.path.exists(output_file)):
        raise Sorry('Could not find output file. Please check that %s exists' %
                    output_file)
    return output_file
Exemplo n.º 2
0
def exercise_emringer_residue_scan():
  pdb_file = libtbx.env.find_in_repositories(
    relative_path="phenix_regression/mmtbx/em_ringer/tst_emringer_model.pdb",
    test=os.path.isfile)
  map_file = libtbx.env.find_in_repositories(
    relative_path="phenix_regression/mmtbx/em_ringer/tst_emringer_map.ccp4",
    test=os.path.isfile)
  assert (not None in [pdb_file, map_file])
  emringer_results = run_program(program_class=emringer.Program, args=[pdb_file, map_file, 'quiet=True'])
  results = emringer_results.ringer_result
  scoring = emringer_results.scoring_result
  rolling = emringer_results.rolling_result
  #results, scoring, rolling = emringer.run([pdb_file, map_file], out=null_out())
  # Make sure the right number of residues (22 out of 28) get scanned
  assert len(results)==22
  modelled_list = [290.742121792,192.844056257,45.4781110306,294.247825632,303.618891108,58.7694040824,331.70068496,46.7136045049,290.167261226,304.261231829,282.651244586,268.729721112,195.972333785,305.321933311,314.81066224,286.028424514,311.180807466,313.004918133,296.67781565,296.949191638,169.644245088,192.496265164]
  peak_list = [270,180,260,75,305,30,310,90,265,270,270,240,280,260,310,285,295,100,260,165,155,200]
  peak_rhos = [0.175600306502,0.351591946536,0.206238983746,0.3269057296,0.68375562882,0.251143527693,0.29106077218,0.199922124642,0.298461589197,0.563313760047,0.412696803251,0.511080434089,0.310001828446,0.228239176285,0.563148497472,0.490755919184,0.200978032127,0.274929619102,0.299229846335,0.179215798655,0.150783734124,0.210869945593]
  for i in range(22):
    # Make sure the modelled angle is correctly read
    assert approx_equal(results[i]._angles[1].angle_current, modelled_list[i])
    # Make sure the peak is chosen correctly
    assert approx_equal(results[i]._angles[1].peak_chi, peak_list[i])
    # Make sure the peak rhos are correct
    assert approx_equal(results[i]._angles[1].peak_rho, peak_rhos[i])

  emringer_results2 = run_program(program_class=emringer.Program, args=[pdb_file, map_file, "rolling_window_threshold=0.5", 'quiet=True'])
  #results, scoring2, rolling2 = emringer.run([pdb_file, map_file, "rolling_window_threshold=0.5"], out=null_out())
  results2 = emringer_results2.ringer_result
  scoring2 = emringer_results2.scoring_result
  rolling2 = emringer_results2.rolling_result
  assert rolling.threshold == 0
  assert rolling2.threshold == 0.5
Exemplo n.º 3
0
def exercise_02():
    if (os.path.isfile("tst_pdb_as_cif_2.cif")):
        os.remove("tst_pdb_as_cif_2.cif")
    open("tst_pdb_as_cif_2.pdb", "w").write("""\
CRYST1  209.050  447.220  608.960  90.00  90.00  90.00 P 21 21 21
ATOM  99999  N3    U   367     -23.562  29.366 106.688  1.00135.52      A16S N
ANISOU99999  N3    U   367    20423  14326  16741  -1922  -2828  -1650  A16S N
ATOM  A0000  C4    U   367     -23.357  30.626 106.161  1.00133.22      A16S C
ANISOUA0000  C4    U   367    20015  14160  16442  -1873  -2801  -1645  A16S C
""")
    run_program(
        program_class=pdb_as_cif.Program,
        args=["tst_pdb_as_cif_2.pdb"],
        logger=null_out(),
    )
    assert os.path.isfile("tst_pdb_as_cif_2.cif")
    inp = open("tst_pdb_as_cif_2.cif", "r")
    cntr = 0
    for l in inp.readlines():
        l = l.strip()
        # These are for align_columns=True in iotbx.cif.write_whole_cif_file()
        # if(l.startswith("ATOM   99999  N3  .  U  .  367  ?")): cntr+=1
        # if(l.startswith("ATOM  100000  C4  .  U  .  367  ?")): cntr+=1
        # if(l.startswith("99999  N3  .  U  .  367  ?")): cntr+=1
        # if(l.startswith("100000  C4  .  U  .  367  ?")): cntr+=1

        # These are for align_columns=False in iotbx.cif.write_whole_cif_file()
        if (l.startswith("ATOM 1 N3 . U A16S 367 ? ")): cntr += 1
        if (l.startswith("ATOM 2 C4 . U A16S 367 ?")): cntr += 1
        if (l.startswith("1 N3 . U A16S 367 ? ")): cntr += 1
        if (l.startswith("2 C4 . U A16S 367 ?")): cntr += 1
    assert cntr == 4, cntr
Exemplo n.º 4
0
def exercise_01():
    if (os.path.isfile("tst_pdb_as_cif_1.cif")):
        os.remove("tst_pdb_as_cif_1.cif")
    open("tst_pdb_as_cif_1.pdb", "w").write("""\
CRYST1   97.470  113.870  196.190  90.00  90.00  90.00 P 21 21 21   16
SCALE1      0.010260  0.000000  0.000000        0.00000
SCALE2      0.000000  0.008782  0.000000        0.00000
SCALE3      0.000000  0.000000  0.005097        0.00000
ATOM      1  N   MET A  43       8.153  31.407  59.548  1.00182.68           N
ATOM      2  CA  MET A  43       8.561  30.228  58.722  1.00182.68           C
ATOM      3  C   MET A  43       9.997  29.817  59.022  1.00182.68           C
ATOM      4  O   MET A  43      10.910  30.123  58.254  1.00182.68           O
ATOM      5  CB  MET A  43       8.435  30.557  57.229  1.00182.68           C
ATOM      6  CG  MET A  43       7.111  30.162  56.605  1.00182.68           C
ATOM      7  SD  MET A  43       6.779  28.394  56.836  1.00182.68           S
ATOM      8  CE  MET A  43       7.824  27.649  55.560  1.00182.68           C
ATOM      9  N   LEU A  44      10.187  29.092  60.119  1.00182.68           N
ATOM     10  CA  LEU A  44      11.515  28.652  60.526  1.00182.68           C
ATOM     11  C   LEU A  44      12.314  27.929  59.481  1.00182.68           C
ATOM     12  O   LEU A  44      11.991  26.807  59.098  1.00182.68           O
ATOM     13  CB  LEU A  44      11.428  27.808  61.775  1.00182.68           C
ATOM     14  CG  LEU A  44      11.367  28.820  62.893  1.00182.68           C
ATOM     15  CD1 LEU A  44      10.820  28.175  64.124  1.00182.68           C
ATOM     16  CD2 LEU A  44      12.755  29.420  63.073  1.00182.68           C
""")
    run_program(
        program_class=pdb_as_cif.Program,
        args=["tst_pdb_as_cif_1.pdb"],
        logger=null_out(),
    )
    assert os.path.isfile("tst_pdb_as_cif_1.cif")
    cif_in = iotbx.pdb.input("tst_pdb_as_cif_1.cif")
    hierarchy = cif_in.construct_hierarchy()
    open("tst_pdb_as_cif_2.pdb", "w").write("""\
CRYST1    1.000    1.000    1.000  90.00  90.00  90.00 P 1
SCALE1      1.000000  0.000000  0.000000        0.00000
SCALE2      0.000000  1.000000  0.000000        0.00000
SCALE3      0.000000  0.000000  1.000000        0.00000
ATOM      1 N    ALA     1      26.216  26.069  22.329  1.00  4.70
ATOM      2 CA   ALA     1      25.368  26.545  21.218  1.00  6.09
ATOM      3 C    ALA     1      26.005  26.154  19.885  1.00 11.13
ATOM      4 O    ALA     1      27.207  25.902  19.835  1.00 16.15
ATOM      5 CB   ALA     1      25.434  28.079  21.272  1.00  4.53
ATOM      6 N    GLY     2      25.198  26.203  18.856  1.00  8.14
ATOM      7 CA   GLY     2      25.677  25.977  17.535  1.00 10.65
ATOM      8 C    GLY     2      26.113  24.580  17.267  1.00  9.83
ATOM      9 O    GLY     2      26.154  23.705  18.108  1.00  9.22
""")
    out = StringIO()
    try:
        run_program(
            program_class=pdb_as_cif.Program,
            args=["tst_pdb_as_cif_2.pdb"],
            logger=out,
        )
    except Exception, e:
        pass
Exemplo n.º 5
0
def exercise_cryo_fit2():  #Checks that cryo_fit2 runs well
    pdb_file = libtbx.env.find_in_repositories(
        relative_path=
        "cryo_fit2/regression/input/tst_cryo_fit2_tRNA_EFTU_within_10.pdb",
        test=os.path.isfile)

    ##### <begin> This copy operation seems odd, but needed to test CRYST1 header addition test
    pdb_file_no_CRYST1 = pdb_file[:-4] + "_no_CRYST1.pdb"

    command_string = "cp " + pdb_file_no_CRYST1 + " " + pdb_file
    libtbx.easy_run.call(command=command_string)
    ##### <end> This copy operation seems odd, but needed to test CRYST1 header addition test

    pdb_file = libtbx.env.find_in_repositories(
        relative_path=
        "cryo_fit2/regression/input/tst_cryo_fit2_tRNA_EFTU_within_10.pdb",
        test=os.path.isfile)
    map_file = libtbx.env.find_in_repositories(
        relative_path=
        "cryo_fit2/regression/input/tst_cryo_fit2_tRNA_EFTU_within_10_assume_reso_4.ccp4",
        test=os.path.isfile)
    resolution = "resolution=4"
    max_steps_for_exploration = "max_steps_for_exploration=20"
    max_steps_for_final_MD = "max_steps_for_final_MD=20"
    assert (not None in [pdb_file, map_file])
    cryo_fit2_results = run_program(program_class=cryo_fit2_program.Program, \
                                    args=[pdb_file, map_file, resolution, \
                                          max_steps_for_exploration, max_steps_for_final_MD])
Exemplo n.º 6
0
def exercise_cryo_fit2(): #Checks that cryo_fit2 runs well
  
  pdb_file = libtbx.env.find_in_repositories(
    relative_path="cryo_fit2/regression/input/tst_cryo_fit2_helix_1_8.pdb",
    test=os.path.isfile)
  
  ##### <begin> This copy operation seems odd, but needed to test CRYST1 header addition test
  pdb_file_no_CRYST1 = pdb_file[:-4] + "_no_CRYST1.pdb"
  
  command_string = "cp " + pdb_file_no_CRYST1 + " " + pdb_file
  libtbx.easy_run.call(command=command_string)
  ##### <end> This copy operation seems odd, but needed to test CRYST1 header addition test
  
  map_file = libtbx.env.find_in_repositories(
    relative_path="cryo_fit2/regression/input/tst_cryo_fit2_helix_1_8_reso_20.ccp4",
    test=os.path.isfile)
  explore = "explore=False"
  resolution = "resolution=20"
  stronger_ss = "stronger_ss=False"
  max_steps_for_exploration = "max_steps_for_exploration=50"
  max_steps_for_final_MD = "max_steps_for_final_MD=50"
  start_temperature = "start_temperature=300"
  final_temperature = "final_temperature=280"
  MD_in_each_cycle = "MD_in_each_cycle=2"
  number_of_steps = "number_of_steps=50"
  assert (not None in [pdb_file, map_file])
  cryo_fit2_results = run_program(program_class=cryo_fit2_program.Program, \
                                  args=[pdb_file, map_file, resolution, start_temperature, final_temperature, \
                                        MD_in_each_cycle, number_of_steps, stronger_ss, explore, \
                                        max_steps_for_final_MD, max_steps_for_exploration])
Exemplo n.º 7
0
def exercise_cryo_fit2():  #Checks that cryo_fit2 runs well
    pdb_file = libtbx.env.find_in_repositories(
        relative_path="cryo_fit2/regression/input/tst_cryo_fit2_helix_1_8.pdb",
        test=os.path.isfile)

    pdb_file_no_CRYST1 = pdb_file[:-4] + "_no_CRYST1.pdb"

    command_string = "cp " + pdb_file_no_CRYST1 + " " + pdb_file
    libtbx.easy_run.call(command=command_string)

    pdb_file = libtbx.env.find_in_repositories(
        relative_path="cryo_fit2/regression/input/tst_cryo_fit2_helix_1_8.pdb",
        test=os.path.isfile)
    map_file = libtbx.env.find_in_repositories(
        relative_path=
        "cryo_fit2/regression/input/tst_cryo_fit2_helix_1_8_reso_20.ccp4",
        test=os.path.isfile)
    resolution = "resolution=20"
    stronger_ss = "stronger_ss=False"
    map_weight = "map_weight=0.001"  # for faster regression test
    explore = "explore=False"
    start_temperature = "start_temperature=300"
    final_temperature = "final_temperature=280"
    MD_in_each_cycle = "MD_in_each_cycle=2"
    number_of_steps = "number_of_steps=1"
    assert (not None in [pdb_file, map_file])
    cryo_fit2_results = run_program(program_class=cryo_fit2_program.Program, \
                                    args=[pdb_file, map_file, resolution, start_temperature, final_temperature, \
                                          MD_in_each_cycle, number_of_steps, map_weight, explore])
def exercise_cryo_fit2():  #Checks that cryo_fit2 runs well
    pdb_file = libtbx.env.find_in_repositories(
        relative_path="cryo_fit2/regression/input/tst_cryo_fit2_helix_1_8.pdb",
        test=os.path.isfile)

    pdb_file_no_CRYST1 = pdb_file[:-4] + "_no_CRYST1.pdb"

    command_string = "cp " + pdb_file_no_CRYST1 + " " + pdb_file
    libtbx.easy_run.call(command=command_string)

    pdb_file = libtbx.env.find_in_repositories(
        relative_path="cryo_fit2/regression/input/tst_cryo_fit2_helix_1_8.pdb",
        test=os.path.isfile)
    map_file = libtbx.env.find_in_repositories(
        relative_path=
        "cryo_fit2/regression/input/tst_cryo_fit2_helix_1_8_reso_20.ccp4",
        test=os.path.isfile)
    resolution = "resolution=20"
    stronger_ss = "stronger_ss=True"
    explore = "explore=True"
    max_steps_for_exploration = "max_steps_for_exploration=20"
    max_steps_for_final_MD = "max_steps_for_final_MD=20"
    assert (not None in [pdb_file, map_file])
    cryo_fit2_results = run_program(program_class=cryo_fit2_program.Program, \
                                    args=[pdb_file, map_file, resolution, stronger_ss, explore,\
                                          max_steps_for_exploration, max_steps_for_final_MD])
def test_dry_run():
    class testProgram(ProgramTemplate):
        def validate(self):
            raise Sorry('This is a test')

    try:
        run_program(program_class=testProgram, args=['--dry-run', '--quiet'])
    except Sorry:
        pass
    else:
        raise Exception_expected

    class testProgram(ProgramTemplate):
        def validate(self):
            pass

    try:
        run_program(program_class=testProgram, args=['--dry-run', '--quiet'])
    except Exception:
        raise Exception_not_expected
Exemplo n.º 10
0
def exercise_emringer_insertion_codes():
  """
  Checks that emringer doesn't crash when there are insertion codes.
  The correctness of output is not checked.
  """
  pdb_file = libtbx.env.find_in_repositories(
    relative_path="phenix_regression/mmtbx/em_ringer/tst_emringer_insertion_codes_model.pdb",
    test=os.path.isfile)
  map_file = libtbx.env.find_in_repositories(
    relative_path="phenix_regression/mmtbx/em_ringer/tst_emringer_map.ccp4",
    test=os.path.isfile)
  assert (not None in [pdb_file, map_file])
  emringer_results = run_program(program_class=emringer.Program, args=[pdb_file, map_file, 'quiet=True'])
Exemplo n.º 11
0
from __future__ import absolute_import, division, print_function
# LIBTBX_SET_DISPATCHER_NAME phenix.evalurama

from mmtbx.programs import evalurama
from iotbx.cli_parser import run_program

run_program(evalurama.Program)
Exemplo n.º 12
0
from __future__ import absolute_import, division, print_function
# LIBTBX_SET_DISPATCHER_NAME mmtbx.ss_idealization

from mmtbx.programs import ss_idealization
from iotbx.cli_parser import run_program

run_program(ss_idealization.Program)
Exemplo n.º 13
0
from __future__ import division, print_function

from iotbx.cli_parser import run_program
from mmtbx.programs import emringer

if __name__ == '__main__':
    run_program(program_class=emringer.Program)

# =============================================================================
# old code - maybe necessary until GUI is updated

# LIBTBX_SET_DISPATCHER_NAME phenix.emringer
# LIBTBX_PRE_DISPATCHER_INCLUDE_SH PHENIX_GUI_ENVIRONMENT=1
# LIBTBX_PRE_DISPATCHER_INCLUDE_SH export PHENIX_GUI_ENVIRONMENT
"""
Implementation of the EMRinger method, with plots, for use with the
EMRinger workflow.

References:
  Barad BA, Echols N, Wang RYR, Cheng YC, DiMaio F, Adams PD, Fraser JS. (2015)
  Side-chain-directed model and map validation for 3D Electron Cryomicroscopy.
  Nature Methods, in press.

  Lang PT, Ng HL, Fraser JS, Corn JE, Echols N, Sales M, Holton JM, Alber T.
  Automated electron-density sampling reveals widespread conformational
  polymorphism in proteins. Protein Sci. 2010 Jul;19(7):1420-31. PubMed PMID:
  20499387
"""

# Any software that wants to use the pkl output of this tool
# should import ringer_residue and ringer_chi from it.
Exemplo n.º 14
0
from __future__ import absolute_import, division, print_function
from iotbx.cli_parser import run_program
from iotbx.programs import box_around_molecule

if __name__ == '__main__':
    run_program(program_class=box_around_molecule.Program)
Exemplo n.º 15
0
from __future__ import division, print_function

from iotbx.cli_parser import run_program
from mmtbx.programs import validate_ligands

if __name__ == '__main__':
  run_program(program_class=validate_ligands.Program)

#old stuff

#from __future__ import division
#from libtbx.str_utils import make_sub_header
#from libtbx.utils import Sorry
#import os
#import sys
#
#def master_phil () :
#  from mmtbx.command_line import generate_master_phil_with_inputs
#  return generate_master_phil_with_inputs(
#    enable_automatic_twin_detection=True,
#    phil_string="""
#ligand_code = None
#  .type = str
#  .multiple = True
#reference_structure = None
#  .type = path
#only_segid = None
#  .type = str
#verbose = False
#  .type = bool
#""")
Exemplo n.º 16
0
from __future__ import absolute_import, division, print_function

from iotbx.cli_parser import run_program
from mmtbx.programs import probe2

run_program(probe2.Program)
Exemplo n.º 17
0
from __future__ import division
# LIBTBX_SET_DISPATCHER_NAME phenix.cablam_idealization

from iotbx.cli_parser import run_program
from mmtbx.programs import cablam_idealization

run_program(cablam_idealization.Program)
# LIBTBX_SET_DISPATCHER_NAME mmtbx.process_predicted_model
# LIBTBX_SET_DISPATCHER_NAME phenix.process_predicted_model
from __future__ import division, print_function

from iotbx.cli_parser import run_program
from mmtbx.programs import process_predicted_model

if __name__ == '__main__':
    run_program(program_class=process_predicted_model.Program)
Exemplo n.º 19
0
from __future__ import absolute_import, division, print_function

# LIBTBX_SET_DISPATCHER_NAME iotbx.unique_with_biomt
# LIBTBX_SET_DISPATCHER_NAME phenix.unique_with_biomt

from iotbx.programs import unique_with_biomt
from iotbx.cli_parser import run_program

result = run_program(unique_with_biomt.Program)
Exemplo n.º 20
0
# LIBTBX_SET_DISPATCHER_NAME phenix.polder
from __future__ import absolute_import, division, print_function

from iotbx.cli_parser import run_program
from mmtbx.programs import polder

if __name__ == '__main__':
    run_program(program_class=polder.Program)
Exemplo n.º 21
0
from __future__ import absolute_import, division, print_function
# LIBTBX_SET_DISPATCHER_NAME phenix.pdbtools

from iotbx.cli_parser import run_program
from mmtbx.programs import pdbtools

run_program(pdbtools.Program)
Exemplo n.º 22
0
# LIBTBX_SET_DISPATCHER_NAME mmtbx.nonbonded_overlaps
from __future__ import division, print_function

from iotbx.cli_parser import run_program
from mmtbx.programs import nonbonded_overlaps

if __name__ == '__main__':
    run_program(program_class=nonbonded_overlaps.Program)

# from __future__ import division
# from __future__ import print_function
# import mmtbx.monomer_library.pdb_interpretation as pdb_inter
# import cctbx.geometry_restraints.nonbonded_overlaps as nbo
# import mmtbx.validation.clashscore as mvc
# from libtbx.utils import null_out
# from libtbx.utils import Sorry
# from libtbx.utils import Usage
# import iotbx.phil
# import sys

# master_phil_str = """
#   model = None
#     .type = path
#     .optional = False
#     .help = '''input PDB file'''

#   cif = None
#     .type = path
#     .optional = True
#     .help = '''Optional Crystallographic Information File (CIF)'''
from __future__ import absolute_import, division, print_function
# LIBTBX_SET_DISPATCHER_NAME phenix.secondary_structure_validation

from mmtbx.programs import ss_validation
from iotbx.cli_parser import run_program

run_program(ss_validation.Program)
Exemplo n.º 24
0
# LIBTBX_SET_DISPATCHER_NAME phenix.HKLinfo
# LIBTBX_SET_DISPATCHER_NAME cctbx.HKLinfo
from __future__ import absolute_import, division, print_function

from iotbx.cli_parser import run_program
from crys3d.programs import HKLinfo

if __name__ == '__main__':
    run_program(program_class=HKLinfo.Program)
Exemplo n.º 25
0
from __future__ import absolute_import, division, print_function
# LIBTBX_SET_DISPATCHER_NAME phenix.comparama

from mmtbx.programs import comparama
from iotbx.cli_parser import run_program

run_program(comparama.Program)
Exemplo n.º 26
0
from __future__ import absolute_import, division, print_function

from iotbx.cli_parser import run_program
from mmtbx.programs import hydrogenate

run_program(hydrogenate.Program)
Exemplo n.º 27
0
# LIBTBX_SET_DISPATCHER_NAME phenix.pdb_as_cif
from __future__ import absolute_import, division, print_function

from iotbx.cli_parser import run_program
from mmtbx.programs import pdb_as_cif

if __name__ == '__main__':
    run_program(program_class=pdb_as_cif.Program)
Exemplo n.º 28
0
from __future__ import division, print_function

from iotbx.cli_parser import run_program
from amber_adaptbx.programs import h_bond_information

if __name__ == '__main__':
  run_program(program_class=h_bond_information.Program)
Exemplo n.º 29
0
# -*- coding: utf-8 -*-
from __future__ import division, print_function
# LIBTBX_SET_DISPATCHER_NAME cctbx.development.ntc_validation

from iotbx.cli_parser import run_program
from mmtbx.programs.ntc_validation import Program

# =============================================================================

if (__name__ == '__main__'):
  results = run_program(program_class=Program)
Exemplo n.º 30
0
from __future__ import division
# LIBTBX_SET_DISPATCHER_NAME phenix.hbond

from mmtbx.programs import hbond
from iotbx.cli_parser import run_program

run_program(hbond.Program)