Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | List of all members
cif::CCD_compound_factory_impl Class Reference
Inheritance diagram for cif::CCD_compound_factory_impl:
Inheritance graph
[legend]
Collaboration diagram for cif::CCD_compound_factory_impl:
Collaboration graph
[legend]

Public Member Functions

 CCD_compound_factory_impl (std::shared_ptr< compound_factory_impl > next, const fs::path &file)
 
 CCD_compound_factory_impl (std::shared_ptr< compound_factory_impl > next)
 
compound * create (const std::string &id) override
 
- Public Member Functions inherited from cif::compound_factory_impl
 compound_factory_impl (std::shared_ptr< compound_factory_impl > next)
 
 compound_factory_impl (const fs::path &file, std::shared_ptr< compound_factory_impl > next)
 
virtual ~compound_factory_impl ()
 
compound * get (std::string id)
 
std::shared_ptr< compound_factory_implnext () const
 
bool is_known_peptide (const std::string &resName)
 
bool is_known_base (const std::string &resName)
 

Public Attributes

cif::parser::datablock_index mIndex
 
fs::path mCompoundsFile
 

Additional Inherited Members

- Protected Attributes inherited from cif::compound_factory_impl
std::shared_timed_mutex mMutex
 
std::vector< compound * > m_compounds
 
std::set< std::string > m_known_peptides
 
std::set< std::string > m_known_bases
 
std::set< std::string > m_missing
 
std::shared_ptr< compound_factory_implm_next
 

Detailed Description

Definition at line 465 of file compound.cpp.

Constructor & Destructor Documentation

◆ CCD_compound_factory_impl() [1/2]

cif::CCD_compound_factory_impl::CCD_compound_factory_impl ( std::shared_ptr< compound_factory_impl next,
const fs::path &  file 
)
inline

Definition at line 468 of file compound.cpp.

470  , mCompoundsFile(file)
471  {
472  }
compound_factory_impl(std::shared_ptr< compound_factory_impl > next)
Definition: compound.cpp:378
std::shared_ptr< compound_factory_impl > next() const
Definition: compound.cpp:343

◆ CCD_compound_factory_impl() [2/2]

cif::CCD_compound_factory_impl::CCD_compound_factory_impl ( std::shared_ptr< compound_factory_impl next)
inline

Definition at line 474 of file compound.cpp.

476  {
477  }
compound_factory_impl(std::shared_ptr< compound_factory_impl > next)
Definition: compound.cpp:378
std::shared_ptr< compound_factory_impl > next() const
Definition: compound.cpp:343

Member Function Documentation

◆ create()

compound * cif::CCD_compound_factory_impl::create ( const std::string &  id)
overridevirtual

Reimplemented from cif::compound_factory_impl.

Definition at line 485 of file compound.cpp.

486 {
487  compound *result = nullptr;
488 
489  std::unique_ptr<std::istream> ccd;
490 
491  if (mCompoundsFile.empty())
492  {
493  ccd = cif::load_resource("components.cif");
494  if (not ccd)
495  {
496  std::cerr << "Could not locate the CCD components.cif file, please make sure the software is installed properly and/or use the update-libcifpp-data to fetch the data." << std::endl;
497  return nullptr;
498  }
499  }
500  else
501  ccd.reset(new std::ifstream(mCompoundsFile));
502 
503  cif::file file;
504 
505  if (mIndex.empty())
506  {
507  if (cif::VERBOSE > 1)
508  {
509  std::cout << "Creating component index "
510  << "...";
511  std::cout.flush();
512  }
513 
514  cif::parser parser(*ccd, file);
515  mIndex = parser.index_datablocks();
516 
517  if (cif::VERBOSE > 1)
518  std::cout << " done" << std::endl;
519 
520  // reload the resource, perhaps this should be improved...
521  if (mCompoundsFile.empty())
522  {
523  ccd = cif::load_resource("components.cif");
524  if (not ccd)
525  throw std::runtime_error("Could not locate the CCD components.cif file, please make sure the software is installed properly and/or use the update-libcifpp-data to fetch the data.");
526  }
527  else
528  ccd.reset(new std::ifstream(mCompoundsFile));
529  }
530 
531  if (cif::VERBOSE > 1)
532  {
533  std::cout << "Loading component " << id << "...";
534  std::cout.flush();
535  }
536 
537  cif::parser parser(*ccd, file);
538  parser.parse_single_datablock(id, mIndex);
539 
540  if (cif::VERBOSE > 1)
541  std::cout << " done" << std::endl;
542 
543  if (not file.empty())
544  {
545  auto &db = file.front();
546  if (db.name() == id)
547  {
548  result = new compound(db);
549 
550  std::shared_lock lock(mMutex);
551  m_compounds.push_back(result);
552  }
553  }
554 
555  if (result == nullptr and cif::VERBOSE > 0)
556  std::cerr << "Could not locate compound " << id << " in the CCD components file" << std::endl;
557 
558  return result;
559 }
std::vector< compound * > m_compounds
Definition: compound.cpp:369
std::unique_ptr< std::istream > load_resource(std::filesystem::path name)
Definition: utilities.cpp:943
int VERBOSE
Definition: utilities.cpp:58
std::shared_timed_mutex mMutex
Definition: compound.cpp:367
cif::parser::datablock_index mIndex
Definition: compound.cpp:481

Member Data Documentation

◆ mCompoundsFile

fs::path cif::CCD_compound_factory_impl::mCompoundsFile

Definition at line 482 of file compound.cpp.

◆ mIndex

cif::parser::datablock_index cif::CCD_compound_factory_impl::mIndex

Definition at line 481 of file compound.cpp.


The documentation for this class was generated from the following file: