IMP  2.3.1
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-2014 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/kernel/Model.h>
18 #include <IMP/kernel/Particle.h>
19 #include <IMP/base/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::base::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  IMP_MOL2_SELECTOR(AllMol2Selector, return (true || mol2_line.empty()),
37  out << "");
38 };
39 
40 //! Defines a selector that will pick only non-hydrogen atoms
41 class IMPATOMEXPORT NonHydrogenMol2Selector : public Mol2Selector {
42  public:
44  String atom_type = internal::pick_mol2atom_type(mol2_line);
45  return (atom_type[0] != 'H'), out << "");
46 };
47 
48 /** @name Mol2 IO
49 
50  \imp can also read and write Mol2 files. As with read_pdb(), selector
51  objects are used to determine which atoms are read.
52 
53  The read function produces a hierarchy containing the molecule. The write
54  hierarchy writes all the Residue types in the hierarchy to the file.
55  @{
56 */
57 //! Create a hierarchy from a Mol2 file.
58 IMPATOMEXPORT Hierarchy read_mol2(base::TextInput mol2_file,
59  kernel::Model* model,
60  Mol2Selector* mol2sel = nullptr);
61 
62 //! Write a ligand hierarchy as a mol2 file
63 /** For now, this has to be a hierarchy created by read_mol2()
64  */
65 IMPATOMEXPORT void write_mol2(Hierarchy rhd, base::TextOutput file_name);
66 
67 /** @} */
68 
69 IMPATOM_END_NAMESPACE
70 
71 #endif /* IMPATOM_MOL_2_H */
Read all atoms.
Definition: mol2.h:34
Handling of file input/output.
#define IMP_MOL2_SELECTOR(Name, selected, show)
Define the basic things you need for a mol2 selector.
Definition: atom_macros.h:31
Decorator for helping deal with a hierarchy of molecules.
The standard decorator for manipulating molecular structures.
Object(std::string name)
Construct an object with the given name.
Hierarchy read_mol2(base::TextInput mol2_file, kernel::Model *model, Mol2Selector *mol2sel=nullptr)
Create a hierarchy from a Mol2 file.
void write_mol2(Hierarchy rhd, base::TextOutput file_name)
Write a ligand hierarchy as a mol2 file.
Storage of a model, its restraints, constraints and particles.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
Classes to handle individual model particles. (Note that implementation of inline functions in in int...
Defines a selector that will pick only non-hydrogen atoms.
Definition: mol2.h:41
Various important macros for implementing decorators.
std::string String
Basic string value.
Definition: types.h:44
A base class for choosing which Mol2 atoms to read.
Definition: mol2.h:26
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73