Exemplo n.º 1
0
def load_tables():
    tables = {}
    for residue_type in ["ala", "gly", "prepro", "pro"]:
        file_name = libtbx.env.find_in_repositories(
            relative_path="chem_data/rotarama_data/%s.rama.combined.data" %
            residue_type,
            test=os.path.isfile)
        f = open(file_name, "r")
        data = flex.double()
        for line in f.readlines():
            val, phi, psi = line.split()
            assert ((int(phi) % 2 == 1) and (int(psi) % 2 == 1))
            data.append(float(val))
        t = lookup_table(data, 180)
        tables[residue_type] = t
    return tables
Exemplo n.º 2
0
def load_tables(params=None):
    if (params is None):
        params = master_phil.fetch().extract()
    if (params.scale_allowed <= 0.0):
        raise Sorry("Ramachandran restraint parameter scale_allowed must be " +
                    "a positive number (current value: %g)." %
                    params.scale_allowed)
    tables = {}
    for residue_type in ["ala", "gly", "prepro", "pro"]:
        file_name = libtbx.env.find_in_repositories(
            relative_path="chem_data/rotarama_data/%s.rama.combined.data" %
            residue_type,
            test=os.path.isfile)
        f = open(file_name, "r")
        data = flex.double()
        for line in f.readlines():
            val, phi, psi = line.split()
            assert ((int(phi) % 2 == 1) and (int(psi) % 2 == 1))
            data.append(float(val))
        t = lookup_table(data, 180, params.scale_allowed)
        tables[residue_type] = t
    return tables
Exemplo n.º 3
0
def load_tables (params=None) :
  import boost.python
  if (params is None) :
    params = master_phil.fetch().extract()
  if (params.scale_allowed <= 0.0) :
    raise Sorry("Ramachandran restraint parameter scale_allowed must be "+
      "a positive number (current value: %g)." % params.scale_allowed)
  tables = {}
  for residue_type in ["ala", "gly", "prepro", "pro"] :
    file_name = libtbx.env.find_in_repositories(
      relative_path="chem_data/rotarama_data/%s.rama.combined.data" %
        residue_type,
      test=os.path.isfile)
    f = open(file_name, "r")
    data = flex.double()
    for line in f.readlines() :
      val, phi, psi = line.split()
      assert ((int(phi) % 2 == 1) and (int(psi) % 2 == 1))
      data.append(float(val))
    t = lookup_table(data, 180, params.scale_allowed)
    tables[residue_type] = t
  return tables
Exemplo n.º 4
0
def load_emsley8k_tables():
    tables = {}
    name_to_file = [("general", "rama8000-general-noGPIVpreP.data", 0),
                    ("glycine", "rama8000-gly-sym.data", 1),
                    ("cis-proline", "rama8000-cispro.data", 2),
                    ("trans-proline", "rama8000-transpro.data", 3),
                    ("pre-proline", "rama8000-prepro-noGP.data", 4),
                    ("isoleucine or valine", "rama8000-ileval-nopreP.data", 5)]
    tmp = OrderedDict()
    rr = [i for i in range(-179, 180, 2)]
    for i in rr:
        for j in rr:
            tmp[(i, j)] = 0
    R = ramachandran_eval.RamachandranEval()
    outlier = ramalyze.RAMALYZE_OUTLIER
    favored = ramalyze.RAMALYZE_FAVORED
    allowed = ramalyze.RAMALYZE_ALLOWED
    for (rama_key, file_name, selfstore) in name_to_file:
        file_name = libtbx.env.find_in_repositories(
            relative_path="chem_data/rotarama_data/%s" % (file_name),
            test=os.path.isfile)
        di = {}
        outlier_vals = flex.double()
        favored_vals = flex.double()
        allowed_vals = flex.double()
        status = {}
        with open(file_name, "r") as f:
            lines = f.readlines()
        for line in lines:
            if line[0] == "#": continue
            phi, psi, val = line.split()
            phi = int(float(phi))
            psi = int(float(psi))
            val = float(val)
            di[(phi, psi)] = val
            rama_score = R.rama_eval.get_score(selfstore, phi, psi)
            evaluation = R.rama_eval.evaluate_score(selfstore, rama_score)
            if (evaluation == outlier):
                outlier_vals.append(val)
                status[(phi, psi)] = outlier
            elif (evaluation == favored):
                favored_vals.append(val)
                status[(phi, psi)] = favored
            elif (evaluation == allowed):
                allowed_vals.append(val)
                status[(phi, psi)] = allowed
            else:
                raise RuntimeError("Not supposed to be here.")
        data = flex.double()
        max_outlier = flex.max(outlier_vals)
        max_favored = flex.max(favored_vals)
        min_favored = flex.min(favored_vals)
        max_allowed = flex.max(allowed_vals)
        for k, v in zip(tmp.keys(), tmp.values()):
            try:
                val = di[k]
                if (status[k] == outlier): val = -1 + val / max_outlier
                elif (status[k] == favored):
                    val = val  #math.exp(val)**0.5/2.71828182846**0.5 #math.exp(val)**3
                elif (status[k] == allowed):
                    val = val  #math.exp(val)**0.5/2.71828182846**0.5 #math.exp(val/max_allowed)**3
            except KeyError:
                val = -1
            data.append(val)
        t = lookup_table(data, 180)
        tables[rama_key] = t
    return tables