Ejemplo n.º 1
0
IMPCORE_BEGIN_NAMESPACE

Float TypedPairScore::evaluate_index(Model *m,
                                     const ParticleIndexPair &pip,
                                     DerivativeAccumulator *da) const {
  ParticlePair p(m->get_particle(pip[0]), m->get_particle(pip[1]));
  PairScore *ps = get_pair_score(p);
  if (!ps) {
    if (!allow_invalid_types_) {
      IMP_THROW(
          "Attempt to evaluate TypedPairScore on "
          "particles with invalid types ("
              << p[0]->get_value(typekey_) << ", " << p[1]->get_value(typekey_)
              << ")",
          ValueException);
    } else {
      return 0.0;
    }
  } else {
    return ps->evaluate_index(m, pip, da);
  }
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]) {
  IMP::Strings args = IMP::setup_from_argv(argc, argv,
                              "Score a protein-ligand complex",
                              "file.mol2 file.pdb [libfile]", -1);

  IMP::set_log_level(IMP::SILENT);
  std::string mol2name, pdbname;
  for (size_t i = 0; i < args.size(); ++i) {
    std::string nm(args[i]);
    if (nm.rfind(".mol2") == nm.size() - 5) {
      mol2name = nm;
    } else if (nm.rfind(".pdb") == nm.size() - 4) {
      pdbname = nm;
    } else {
      break;
    }
  }
  if (mol2name.empty() || pdbname.empty()) {
    std::cerr << "Usage: " << argv[0] << " file.mol2 file.pdb [libfile]"
              << std::endl;
    return EXIT_FAILURE;
  }
  IMP::TextInput lib;
  if (args.size() == 3) {
    lib = IMP::TextInput(args[2]);
  }
  {
    int lib_requested = 0;
    if (lib) lib_requested++;
    if (pose_score) lib_requested++;
    if (rank_score) lib_requested++;
    if (lib_requested > 1) {
      std::cerr << "Can only specify one of --pose, --rank, "
                << "or a library name" << std::endl;
      return EXIT_FAILURE;
    }
  }


  IMP_NEW(IMP::Model, m, ());
  IMP::atom::Hierarchy p, l;
  {
    IMP::SetLogState ss(IMP::SILENT);
    p = IMP::atom::read_pdb(pdbname, m, new IMP::atom::ATOMPDBSelector());
    IMP::atom::add_protein_ligand_score_data(p);
    l = IMP::atom::read_mol2(mol2name, m);
    IMP::atom::add_protein_ligand_score_data(l);
  }
  IMP::atom::Hierarchies mols =
      IMP::atom::get_by_type(l, IMP::atom::RESIDUE_TYPE);
  IMP::Pointer<IMP::atom::ProteinLigandAtomPairScore> ps
          = get_pair_score(lib);
  double d = ps->get_maximum_distance();
  IMP_NEW(IMP::core::GridClosePairsFinder, gcpf, ());
  gcpf->set_distance(d);

  IMP::ParticlesTemp patoms = IMP::atom::get_leaves(p);
  IMP::ParticleIndexes ipatoms = IMP::get_indexes(patoms);
  for (unsigned int i = 0; i < mols.size(); ++i) {
    // IMP::SetLogState ss(i==0? TERSE: IMP::SILENT);
    IMP::ParticlesTemp latoms = IMP::atom::get_leaves(mols[i]);
    IMP::ParticleIndexes ilatoms = IMP::get_indexes(latoms);
    IMP::ParticleIndexPairs ppt =
        gcpf->get_close_pairs(m, ipatoms, ilatoms);
    double score = ps->evaluate_indexes(m, ppt, NULL, 0, ppt.size());
    std::cout << "Score for " << mols[i]->get_name() << " is " << score
              << std::endl;
  }
  ps->set_was_used(true);
  return EXIT_SUCCESS;
}