IMP  2.0.0
The Integrative Modeling Platform
ligand_score.cpp
Go to the documentation of this file.
1 /**
2  * \file ligand_score.cpp \brief A class for reading mol2 files
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  *
6  */
7 
9 #include <IMP/atom/pdb.h>
10 #include <IMP/atom/mol2.h>
12 #include <IMP/particle_index.h>
13 #include <IMP/Model.h>
14 
15 int main(int argc, char *argv[]) {
17  std::string mol2name, pdbname;
18  for (int i=1; i < argc; ++i) {
19  std::string nm(argv[i]);
20  if (nm.rfind(".mol2") == nm.size()-5) {
21  mol2name= nm;
22  } else if (nm.rfind(".pdb") == nm.size()-4) {
23  pdbname= nm;
24  } else {
25  break;
26  }
27  }
28  if (mol2name.empty() || pdbname.empty()) {
29  std::cerr << "Usage: " << argv[0]
30  << " file.mol2 file.pdb [libfile]" << std::endl;
31  return EXIT_FAILURE;
32  }
34  if (argc==4) {
35  lib= IMP::base::TextInput(argv[3]);
36  }
37 
38  IMP_NEW(IMP::Model, m, ());
40  {
41  IMP::SetLogState ss(IMP::SILENT);
42  p= IMP::atom::read_pdb(pdbname, m, new IMP::atom::ATOMPDBSelector());
43  IMP::atom::add_protein_ligand_score_data(p);
44  l= IMP::atom::read_mol2(mol2name, m);
45  IMP::atom::add_protein_ligand_score_data(l);
46  }
47  IMP::atom::Hierarchies mols
48  = IMP::atom::get_by_type(l, IMP::atom::RESIDUE_TYPE);
49  IMP::Pointer<IMP::atom::ProteinLigandAtomPairScore> ps;
50  if (lib) {
51  ps = new IMP::atom::ProteinLigandAtomPairScore(100000, lib);
52  } else {
54  }
55  double d= ps->get_maximum_distance();
57  gcpf->set_distance(d);
58 
59  IMP::ParticlesTemp patoms= IMP::atom::get_leaves(p);
60  IMP::ParticleIndexes ipatoms= IMP::get_indexes(patoms);
61  for (unsigned int i=0; i< mols.size(); ++i) {
62  //IMP::SetLogState ss(i==0? TERSE: IMP::SILENT);
63  IMP::ParticlesTemp latoms= IMP::atom::get_leaves(mols[i]);
64  IMP::ParticleIndexes ilatoms= IMP::get_indexes(latoms);
65  IMP::ParticleIndexPairs ppt= gcpf->get_close_pairs(m, ipatoms, ilatoms);
66  double score=ps->evaluate_indexes(m, ppt, NULL, 0, ppt.size());
67  std::cout << "Score for " << mols[i]->get_name() << " is "
68  << score << std::endl;
69  }
70  ps->set_was_used(true);
71  return EXIT_SUCCESS;
72 }