def exercise():
    lysozyme = """KVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQATNRNTDGSTDYGILQINSRWWCNDGRTPGSRNLCNIPCSALLSSDITASVNCAKKIVSDGNGMNAWVAWRNRCKGTDVQAWIRGCRL"""
    homologs = rcsb_web_services.sequence_search(lysozyme, d_max=2.0)
    assert (len(homologs) > 500)
    atp_binding = rcsb_web_services.chemical_id_search("ATP",
                                                       protein_only=True)
    assert (len(atp_binding) > 650)
    report = rcsb_web_services.get_high_resolution_for_structures(atp_binding)
    assert (len(report) == len(atp_binding)) and (len(report[0]) == 2)
    # print (report)
    report = rcsb_web_services.get_high_resolution_and_residue_count_for_structures(
        atp_binding)
    assert (len(report) == len(atp_binding)) and (len(report[0]) == 3)
    # print (report)
    ligand_info = rcsb_web_services.get_ligand_info_for_structures(['1mru'])
    # print (ligand_info)
    assert ligand_info == [
        ['1MRU', 'A', 'MG', 24.305, 'Mg', 'MAGNESIUM ION', '[Mg++]'],
        ['1MRU', 'B', 'MG', 24.305, 'Mg', 'MAGNESIUM ION', '[Mg++]'],
        [
            '1MRU', 'A', 'AGS', 523.247, 'C10 H16 N5 O12 P3 S',
            'PHOSPHOTHIOPHOSPHORIC ACID-ADENYLATE ESTER',
            'Nc1ncnc2n(cnc12)[CH]3O[CH](CO[P](O)(=O)O[P](O)(=O)O[P](O)(O)=S)[CH](O)[CH]3O'
        ],
        [
            '1MRU', 'B', 'AGS', 523.247, 'C10 H16 N5 O12 P3 S',
            'PHOSPHOTHIOPHOSPHORIC ACID-ADENYLATE ESTER',
            'Nc1ncnc2n(cnc12)[CH]3O[CH](CO[P](O)(=O)O[P](O)(=O)O[P](O)(O)=S)[CH](O)[CH]3O'
        ]
    ]
def exercise () :
  from mmtbx.wwpdb import rcsb_web_services
  lysozyme = """KVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQATNRNTDGSTDYGILQINSRWWCNDGRTPGSRNLCNIPCSALLSSDITASVNCAKKIVSDGNGMNAWVAWRNRCKGTDVQAWIRGCRL"""
  homologs = rcsb_web_services.sequence_search(lysozyme, d_max=2.0)
  assert (len(homologs) > 500)
  atp_binding = rcsb_web_services.chemical_id_search("ATP", protein_only=True)
  assert (len(atp_binding) > 650)
  report = rcsb_web_services.get_high_resolution_for_structures(atp_binding)
  assert (len(report) == len(atp_binding)) and (len(report[0]) == 2)
  ligand_info = rcsb_web_services.get_ligand_info_for_structures(['1mru'])
  assert (len(ligand_info) == 4)
  print "OK"
def exercise () :
  from mmtbx.wwpdb import rcsb_web_services
  lysozyme = """KVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQATNRNTDGSTDYGILQINSRWWCNDGRTPGSRNLCNIPCSALLSSDITASVNCAKKIVSDGNGMNAWVAWRNRCKGTDVQAWIRGCRL"""
  homologs = rcsb_web_services.sequence_search(lysozyme, d_max=2.0)
  assert (len(homologs) > 500)
  atp_binding = rcsb_web_services.chemical_id_search("ATP", protein_only=True)
  assert (len(atp_binding) > 650)
  report = rcsb_web_services.get_high_resolution_for_structures(atp_binding)
  assert (len(report) == len(atp_binding)) and (len(report[0]) == 2)
  ligand_info = rcsb_web_services.get_ligand_info_for_structures(['1mru'])
  assert (len(ligand_info) == 4)
  assert (ligand_info[1][-1] == u'[Mg+2]')
  print "OK"
Exemplo n.º 4
0
def fetch_similar_pdb_ids(
    sequence,
    min_identity=0.95,
    min_resolution=3.0,
    xray_only=True,
    data_only=False,
    expect=0.0000001,
    sort_by_resolution=True,
    ligands=None,
    log=None):
  """
  Finds closely related structures in the RCSB database, optionally limited to
  structures with specific ligands.
  """
  if (log is None) : log = null_out()
  from mmtbx.wwpdb import rcsb_web_services
  allowed_set = None
  if (ligands is not None) and (len(ligands) > 0):
    for lig_str in ligands :
      resnames = lig_str.replace(" ", ",").split(",")
      for resname in resnames :
        ids = rcsb_web_services.chemical_id_search(
          resname=resname,
          d_max=min_resolution,
          xray_only=xray_only,
          data_only=data_only)
        if (allowed_set is None) : allowed_set = set([])
        allowed_set.update([ pdb_id.lower() for pdb_id in ids ])
  matching_ids = rcsb_web_services.sequence_search(
    sequence=sequence,
    min_identity=min_identity,
    expect=expect,
    xray_only=xray_only,
    data_only=data_only,
    d_max=min_resolution,
    sort_by_resolution=sort_by_resolution,
    log=log)
  filtered = []
  for pdb_id in matching_ids :
    pdb_id = pdb_id.lower()
    if (allowed_set is not None) and (not pdb_id in allowed_set):
      continue
    filtered.append(pdb_id)
  return filtered
Exemplo n.º 5
0
def fetch_similar_pdb_ids (
    sequence,
    min_identity=0.95,
    min_resolution=3.0,
    xray_only=True,
    data_only=False,
    expect=0.0000001,
    sort_by_resolution=True,
    ligands=None,
    log=None) :
  """
  Finds closely related structures in the RCSB database, optionally limited to
  structures with specific ligands.
  """
  if (log is None) : log = null_out()
  from mmtbx.wwpdb import rcsb_web_services
  allowed_set = None
  if (ligands is not None) and (len(ligands) > 0) :
    for lig_str in ligands :
      resnames = lig_str.replace(" ", ",").split(",")
      for resname in resnames :
        ids = rcsb_web_services.chemical_id_search(
          resname=resname,
          d_max=min_resolution,
          xray_only=xray_only,
          data_only=data_only)
        if (allowed_set is None) : allowed_set = set([])
        allowed_set.update([ pdb_id.lower() for pdb_id in ids ])
  matching_ids = rcsb_web_services.sequence_search(
    sequence=sequence,
    min_identity=min_identity,
    expect=expect,
    xray_only=xray_only,
    data_only=data_only,
    d_max=min_resolution,
    sort_by_resolution=sort_by_resolution,
    log=log)
  filtered = []
  for pdb_id in matching_ids :
    pdb_id = pdb_id.lower()
    if (allowed_set is not None) and (not pdb_id in allowed_set) :
      continue
    filtered.append(pdb_id)
  return filtered
def run(args, out=sys.stdout):
    if (len(args) == 0) or ("--help" in args):
        raise Usage("""mmtbx.find_residue_in_pdb RESNAME [options]

Use the RCSB web services to retrieve a list of PDB structures containing the
specified chemical ID.

Full parameters:
%s
""" % master_phil.as_str(prefix="  "))
    sources = []

    def process_unknown(arg):
        if (1 <= len(arg) <= 3) and (arg.isalnum()):
            return libtbx.phil.parse("resname=%s" % arg)

    cai = libtbx.phil.command_line.argument_interpreter(
        master_phil=master_phil)
    working_phil = cai.process_and_fetch(args=args,
                                         custom_processor=process_unknown)
    params = working_phil.extract()
    if (params.resname is None):
        raise Sorry("No residue ID specified.")
    from mmtbx.wwpdb import rcsb_web_services
    pdb_ids = rcsb_web_services.chemical_id_search(
        resname=params.resname,
        d_max=params.d_max,
        polymeric_type=params.polymeric_type,
        xray_only=params.xray_only,
        data_only=params.data_only,
        identity_cutoff=params.identity_cutoff)
    pdb_ids = [id.lower() for id in pdb_ids]
    if (len(pdb_ids) == 0):
        raise Sorry("No structures found matching the specified criteria.")
    else:
        if (not params.quiet):
            print >> out, "%d PDB IDs retrieved:" % len(pdb_ids)
            i = 0
            while (i < len(pdb_ids)):
                print >> out, "  %s" % " ".join(pdb_ids[i:i + 16])
                i += 16
        else:
            print >> out, "%d PDB IDs matching" % len(pdb_ids)
Exemplo n.º 7
0
def run (args, out=sys.stdout) :
  if (len(args) == 0) or ("--help" in args) :
    raise Usage("""mmtbx.find_residue_in_pdb RESNAME [options]

Use the RCSB web services to retrieve a list of PDB structures containing the
specified chemical ID.

Full parameters:
%s
""" % master_phil.as_str(prefix="  "))
  sources = []
  def process_unknown (arg) :
    if (1 <= len(arg) <= 3) and (arg.isalnum()) :
      return libtbx.phil.parse("resname=%s" % arg)
  cai = libtbx.phil.command_line.argument_interpreter(master_phil=master_phil)
  working_phil = cai.process_and_fetch(args=args,
    custom_processor=process_unknown)
  params = working_phil.extract()
  if (params.resname is None) :
    raise Sorry("No residue ID specified.")
  from mmtbx.wwpdb import rcsb_web_services
  pdb_ids = rcsb_web_services.chemical_id_search(
    resname=params.resname,
    d_max=params.d_max,
    polymeric_type=params.polymeric_type,
    xray_only=params.xray_only,
    data_only=params.data_only,
    identity_cutoff=params.identity_cutoff)
  pdb_ids = [ id.lower() for id in pdb_ids ]
  if (len(pdb_ids) == 0) :
    raise Sorry("No structures found matching the specified criteria.")
  else :
    if (not params.quiet) :
      print >> out, "%d PDB IDs retrieved:" % len(pdb_ids)
      i = 0
      while (i < len(pdb_ids)) :
        print >> out, "  %s" % " ".join(pdb_ids[i:i+16])
        i += 16
    else :
      print >> out, "%d PDB IDs matching" % len(pdb_ids)
def exercise_2():
    fes_binding = rcsb_web_services.chemical_id_search("FES", xray_only=False)
    assert len(fes_binding) > 765, len(fes_binding)