IMP logo
IMP Reference Guide  2.5.0
The Integrative Modeling Platform
mol2.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/mol2.h
3  * \brief Functions to read mol2s
4  *
5  * Copyright 2007-2015 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_MOL_2_H
10 #define IMPATOM_MOL_2_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include "Hierarchy.h"
14 #include "atom_macros.h"
15 #include "internal/mol2.h"
16 
17 #include <IMP/Model.h>
18 #include <IMP/Particle.h>
19 #include <IMP/file.h>
20 
21 IMPATOM_BEGIN_NAMESPACE
22 
23 //! A base class for choosing which Mol2 atoms to read
24 /**
25  */
26 class IMPATOMEXPORT Mol2Selector : public IMP::Object {
27  public:
28  Mol2Selector() : Object("Mol2Selector%1%") {}
29  virtual bool get_is_selected(const std::string& atom_line) const = 0;
30  virtual ~Mol2Selector();
31 };
32 
33 //! Read all atoms
34 class AllMol2Selector : public Mol2Selector {
35  public:
36  bool get_is_selected(const std::string& mol2_line) const IMP_OVERRIDE {
37  return (true || mol2_line.empty());
38  }
39 };
40 
41 //! Defines a selector that will pick only non-hydrogen atoms
42 class IMPATOMEXPORT NonHydrogenMol2Selector : public Mol2Selector {
43  public:
44  bool get_is_selected(const std::string& mol2_line) const IMP_OVERRIDE {
45  String atom_type = internal::pick_mol2atom_type(mol2_line);
46  return (atom_type[0] != 'H');
47  }
48 };
49 
50 /** @name Mol2 IO
51 
52  \imp can also read and write Mol2 files. As with read_pdb(), selector
53  objects are used to determine which atoms are read.
54 
55  The read function produces a hierarchy containing the molecule. The write
56  hierarchy writes all the Residue types in the hierarchy to the file.
57  @{
58 */
59 //! Create a hierarchy from a Mol2 file.
60 IMPATOMEXPORT Hierarchy read_mol2(TextInput mol2_file,
61  Model* model,
62  Mol2Selector* mol2sel = nullptr);
63 
64 //! Write a ligand hierarchy as a mol2 file
65 /** For now, this has to be a hierarchy created by read_mol2()
66  */
67 IMPATOMEXPORT void write_mol2(Hierarchy rhd, TextOutput file_name);
68 
69 /** @} */
70 
71 IMPATOM_END_NAMESPACE
72 
73 #endif /* IMPATOM_MOL_2_H */
Storage of a model, its restraints, constraints and particles.
Read all atoms.
Definition: mol2.h:34
Handling of file input/output.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Decorator for helping deal with a hierarchy of molecules.
The standard decorator for manipulating molecular structures.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
Hierarchy read_mol2(TextInput mol2_file, Model *model, Mol2Selector *mol2sel=nullptr)
Create a hierarchy from a Mol2 file.
void write_mol2(Hierarchy rhd, TextOutput file_name)
Write a ligand hierarchy as a mol2 file.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
Defines a selector that will pick only non-hydrogen atoms.
Definition: mol2.h:42
Various important macros for implementing decorators.
Object(std::string name)
Construct an object with the given name.
std::string String
Basic string value.
Definition: types.h:44
A base class for choosing which Mol2 atoms to read.
Definition: mol2.h:26
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.