IMP  2.0.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-2013 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::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
35 public:
37  return (true || mol2_line.empty()),
38  out << "");
39 };
40 
41 
42 //! Defines a selector that will pick only non-hydrogen atoms
43 class IMPATOMEXPORT NonHydrogenMol2Selector : public Mol2Selector {
44  public:
46  String atom_type = internal::pick_mol2atom_type(mol2_line);
47  return (atom_type[0] != 'H'), out << "");
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 IMPATOMEXPORT Hierarchy read_mol2(base::TextInput mol2_file,
60  Model* model,
61  Mol2Selector* mol2sel
62  = nullptr);
63 
64 IMPATOMEXPORT void write_mol2(Hierarchy rhd,
65  base::TextOutput file_name);
66 
67 /** @} */
68 
69 IMPATOM_END_NAMESPACE
70 
71 #endif /* IMPATOM_MOL_2_H */