home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
develop.63b38c487d,2024/12/21
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
include
IMP
atom
version 20241221.develop.63b38c487d
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-2022 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 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 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 */
Model.h
Storage of a model, its restraints, constraints and particles.
IMP::atom::AllMol2Selector
Read all atoms.
Definition:
mol2.h:34
file.h
Handling of file input/output.
IMP::TextInput
Definition:
file.h:89
IMP::Model
Class for storing model, its restraints, constraints, and particles.
Definition:
Model.h:86
Hierarchy.h
Decorator for helping deal with a hierarchy of molecules.
IMP::atom::Hierarchy
The standard decorator for manipulating molecular structures.
Definition:
atom/Hierarchy.h:192
IMP::Object
Common base class for heavy weight IMP objects.
Definition:
Object.h:111
IMP::TextOutput
Definition:
file.h:50
IMP::atom::read_mol2
Hierarchy read_mol2(TextInput mol2_file, Model *model, Mol2Selector *mol2sel=nullptr)
Create a hierarchy from a Mol2 file.
IMP::atom::write_mol2
void write_mol2(Hierarchy rhd, TextOutput file_name)
Write a ligand hierarchy as a mol2 file.
Particle.h
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
IMP::atom::NonHydrogenMol2Selector
Defines a selector that will pick only non-hydrogen atoms.
Definition:
mol2.h:42
atom_macros.h
Macros for maintaining molecular hierarchies.
IMP::Object::Object
Object(std::string name)
Construct an object with the given name.
IMP::String
std::string String
Basic string value.
Definition:
types.h:43
IMP::atom::Mol2Selector
A base class for choosing which Mol2 atoms to read.
Definition:
mol2.h:26