IMPRMF_BEGIN_INTERNAL_NAMESPACE

HierarchyLoadXYZs::HierarchyLoadXYZs(RMF::FileConstHandle f)
  : reference_frame_factory_(f), ip_factory_(f) {
  // backwards compat
  RMF::Category cat = f.get_category("IMP");
  rb_index_key_ = f.get_key(cat, "rigid body", RMF::IntTraits());
}
Beispiel #2
0
int main(int argc, char** argv) {
  try {
    options.add_options()("frame,f",
                          boost::program_options::value<unsigned int>(&frame),
                          "Frame to use");
    RMF_ADD_INPUT_FILE("rmf");
    process_options(argc, argv);

    RMF::FileConstHandle rh = RMF::open_rmf_file_read_only(input);
    if (!rh.get_description().empty()) {
      std::cout << "description: " << rh.get_description() << std::endl;
    }
    if (!rh.get_producer().empty()) {
      std::cout << "producer: " << rh.get_producer() << std::endl;
    }
    rh.set_current_frame(RMF::FrameID(frame));
    std::cout << "frames: " << rh.get_number_of_frames() << std::endl;
    RMF::show_info(rh, std::cout);
    RMF::decorator::AlternativesFactory af(rh);
    using RMF::operator<<;
    std::cout << "resolutions: " << RMF::decorator::get_resolutions(
                                        rh.get_root_node(), RMF::PARTICLE, 0)
              << std::endl;
    std::cout << "gaussian resolutions: "
              << RMF::decorator::get_resolutions(rh.get_root_node(),
                                                 RMF::GAUSSIAN_PARTICLE, 0)
              << std::endl;
    return 0;
  }
  catch (const std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
  }
}
Beispiel #3
0
int main(int argc, char** argv) {
  try {
    RMF_ADD_INPUT_FILE("rmf");
    RMF_ADD_OUTPUT_FILE("xml");
    int frame = 0;
    options.add_options()("frame,f", boost::program_options::value<int>(&frame),
                          "Frame to use, if -1 just show static data")(
        "verbose,v", "Show the attribute values for each node.");

    process_options(argc, argv);

    RMF::FileConstHandle rh = RMF::open_rmf_file_read_only(input);
    std::ostream* out;
    std::ofstream fout;
    if (!output.empty()) {
      fout.open(output.c_str());
      if (!fout) {
        std::cerr << "Error opening file " << output << std::endl;
        return 1;
      }
      out = &fout;
    } else {
      out = &std::cout;
    }
    RMF::Categories cs = rh.get_categories();
    *out << "<?xml version=\"1.0\"?>\n";
    *out << "<rmf>\n";
    *out << "<description>\n";
    *out << rh.get_description() << std::endl;
    *out << "</description>\n";
    *out << "<path>\n";
    *out << input << std::endl;
    *out << "</path>\n";
    std::set<RMF::NodeConstHandle> seen;
    rh.set_current_frame(RMF::FrameID(frame));
    show_hierarchy(rh.get_root_node(), cs, seen, *out);
    *out << "</rmf>\n";
    return 0;
  }
  catch (const std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
  }
}
Beispiel #4
0
int main(int argc, char **argv) {
  try {
    RMF_ADD_INPUT_FILE("rmf");
    process_options(argc, argv);


    RMF::FileConstHandle rh = RMF::open_rmf_file_read_only(input);
    for (unsigned int i = 0; i < rh.get_number_of_frames(); ++i) {
      rh.set_current_frame(i);
      std::string cmt = rh.get_current_frame().get_name();
      if (!cmt.empty()) {
        std::cout << i << ": " << cmt << std::endl;
      }
    }
    return 0;
  } catch (const std::exception &e) {
    std::cerr << "Error: " << e.what() << std::endl;
  }
}
Beispiel #5
0
LoadLinks get_load_linkers(RMF::FileConstHandle fh) {
  LoadLinks ret;
  typedef std::pair<std::string, int> P;
  IMP_FOREACH(P kl, known_load_linkers) {
    if (fh.get_has_associated_data(kl.second)) {
      ret.push_back(fh.get_associated_data<LoadLinkAssociationType>(kl.second));
    }
  }
  IMP_LOG_VERBOSE("Found " << ret.size() << " load linkers" << std::endl);
  return ret;
}
Beispiel #6
0
int main(int argc, char** argv) {
  try {
    RMF_ADD_INPUT_FILE("rmf");
    RMF_ADD_OUTPUT_FILE("pdb");
    RMF_ADD_FRAMES;
    process_options(argc, argv);

    RMF::FileConstHandle rh = RMF::open_rmf_file_read_only(input);
    std::ostream* out;
    std::ofstream fout;
    if (!output.empty()) {
      fout.open(output.c_str());
      if (!fout) {
        std::cerr << "Error opening file " << output << std::endl;
        return 1;
      }
      out = &fout;
    } else {
      out = &std::cout;
    }
    RMF::decorator::IntermediateParticleFactory ipf(rh);
    RMF::decorator::AtomFactory af(rh);
    RMF::decorator::ChainFactory cf(rh);
    RMF::decorator::ResidueFactory rf(rh);
    RMF::NodeConstHandle rn = rh.get_root_node();
    for (unsigned int input_frame = start_frame, output_frame = 0;
         input_frame < rh.get_number_of_frames();
         input_frame += step_frame, ++output_frame) {
      rh.set_current_frame(RMF::FrameID(input_frame));
      *out << (boost::format("MODEL%1$9d") % (output_frame + 1)) << std::endl;
      write_atoms(*out, 0, rn, ipf, af, cf, rf);
      *out << "ENDMDL" << output_frame + 1 << std::endl;
    }
    return 0;
  }
  catch (const std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
  }
}
Beispiel #7
0
IMPRMF_BEGIN_NAMESPACE
void load_frame(RMF::FileConstHandle fh, RMF::FrameID frame) {
  bool except = false;
  std::string what;
  try {
    fh.set_current_frame(frame);
    IMP_FOREACH(LoadLink * ll, internal::get_load_linkers(fh)) { ll->load(fh); }
  }
  catch (const std::exception& e) {
    except = true;
    what = e.what();
  }
  // Work around an MSVC 2012 compiler bug (exceptions thrown within a
  // catch block cannot be caught)
  if (except) {
    IMP_THROW(what, IOException);
  }
}
Beispiel #8
0
void set_linker(RMF::FileConstHandle fh, unsigned int id,
                LoadLinkAssociationType l) {
  fh.add_associated_data(id, l);
}
Beispiel #9
0
bool get_has_linker(RMF::FileConstHandle fh, unsigned int id) {
  return fh.get_has_associated_data(id);
}
Beispiel #10
0
int main(int argc, char* argv[])
{
 IMP::setup_from_argv(argc,argv,"Test score of a model");

 // read input
 std::string inputfile="config.ini";

 // parsing input
 SPBParameters mydata=get_SPBParameters(inputfile,"0");

 // create a new model
 IMP_NEW(Model,m,());
 IMP_NEW(RestraintSet, allrs, (m, "All restraints"));

 // List of particles for layer restraint
 IMP_NEW(container::ListSingletonContainer,CP_ps,(m));
 IMP_NEW(container::ListSingletonContainer,IL2_ps,(m));

 // List of MonteCarloMovers for MC, not used here
 core::MonteCarloMovers mvs;

 //
 // ISD PARTICLES
 //
 std::map<std::string,IMP::Pointer<Particle> > ISD_ps=
   add_ISD_particles(m,allrs,mydata,mvs);
 // create list of particles from map
 Particles ISD_ps_list;
 std::map<std::string, IMP::Pointer<Particle> >::iterator itr;
 for(itr = ISD_ps.begin(); itr != ISD_ps.end(); ++itr){
  ISD_ps_list.push_back((*itr).second);
 }
 //
 // PROTEIN REPRESENTATION
 //
 atom::Hierarchies all_mol=
   create_representation(m,allrs,mydata,CP_ps,IL2_ps,mvs,
     ISD_ps["SideXY"],ISD_ps["SideZ"],0);

 //
 // CREATING RESTRAINTS
 //
 std::map< std::string, IMP::Pointer<RestraintSet> > rst_map=
        spb_assemble_restraints(m,allrs,mydata,all_mol,CP_ps,IL2_ps,ISD_ps);


 //
 // CREATE LIST TO LINK TO RMF
 //
 atom::Hierarchies hhs;
 for(unsigned int i=0;i<all_mol.size();++i){
  atom::Hierarchies hs=all_mol[i].get_children();
  for(unsigned int j=0;j<hs.size();++j) {hhs.push_back(hs[j]);}
 }

 // print statistics

 // open rmf for coordinates
 RMF::FileConstHandle rhc =
   RMF::open_rmf_file_read_only(argv[1]);
 // read various info
 RMF::Category my_kc_read   = rhc.get_category("my data");

 RMF::FloatKey my_key0_read = rhc.get_key<RMF::FloatTag>(my_kc_read,"my score");

 // linking hierarchies
 rmf::link_hierarchies(rhc, hhs);
 // number of frames
 unsigned int nframes=rhc.get_number_of_frames();

 // open rmf for ISD particles
 RMF::FileConstHandle rhc_ISD =
        RMF::open_rmf_file_read_only(argv[2]);
 // linking particles
 rmf::link_particles(rhc_ISD, ISD_ps_list);
 // number of frames
 unsigned int nframes_ISD=rhc_ISD.get_number_of_frames();

 // check number of frames are the same
 if(nframes!=nframes_ISD) {exit(1);}


 // cycle on frames
 for(unsigned int imc = 0; imc < nframes; imc++){

   // load coordinates
   rmf::load_frame(rhc,RMF::FrameID(imc));
   //rhc.set_current_frame(RMF::FrameID(imc));

   // and ISD particles
   //rhc_ISD.set_current_frame(RMF::FrameID(imc));
   rmf::load_frame(rhc_ISD,RMF::FrameID(imc));

   // get score and REM index
   Float score = (rhc.get_root_node()).get_value(my_key0_read);

  // do the scoring here
  //

  double totalscore = allrs->evaluate(false);

  std::cout << "Stored score" << score <<
  " Calculated score " <<totalscore <<std::endl;

         // get all the restraints in the model

         for(unsigned i=0;i<allrs->get_number_of_restraints();++i) {
         IMP::Pointer<IMP::Restraint> rst=dynamic_cast<
            IMP::Restraint*>(allrs->get_restraint(i));
         std::cout<< rst->get_name() << " " << rst->get_score() <<std::endl;
  }
  for(unsigned i=0;i<rst_map["FRET_R"]->get_number_of_restraints();++i){
            IMP::Pointer<isd::FretRestraint> rst=
            dynamic_cast<isd::FretRestraint*>(
            rst_map["FRET_R"]->get_restraint(i));
    std::string name = rst->get_name();
    Float fmod       = rst->get_model_fretr();
    Float fmod_err   = rst->get_standard_error();
    Float fexp       = rst->get_experimental_value();

     printf("TimeStep %10d Name %30s  Model %6.3f",imc,name.c_str(),fmod);
     printf("Model_Error %6.3f  Exp %6.3f\n",fmod_err,fexp);

      }

 break;
 }

 // close RMFs
 rhc     = RMF::FileHandle();
 rhc_ISD = RMF::FileHandle();


 return 0;


}
Beispiel #11
0
 IMP_FOREACH(Pair pp, local_) {
   IMP_LOG_VERBOSE("Loading local coordinates for "
                   << m->get_particle_name(pp.second) << std::endl);
   algebra::Vector3D rf(get_coordinates(fh.get_node(pp.first), ip_factory_));
   core::RigidBodyMember(m, pp.second).set_internal_coordinates(rf);
 }
Beispiel #12
0
 IMP_FOREACH(Pair pp, global_) {
   IMP_LOG_VERBOSE("Loading global coordinates for "
                   << m->get_particle_name(pp.second) << std::endl);
   algebra::Vector3D rf(get_coordinates(fh.get_node(pp.first), ip_factory_));
   core::XYZ(m, pp.second).set_coordinates(rf);
 }
Beispiel #13
0
bool get_has_associated_node(RMF::FileConstHandle nh, Object *oi) {
  return nh.get_node_from_association(oi) != RMF::NodeConstHandle();
}
Beispiel #14
0
RMF::NodeConstHandle get_node_from_association(RMF::FileConstHandle nh,
                                               Object *oi) {
  AssociationType o(oi);
  return nh.get_node_from_association(o);
}