-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathexample_descriptor_molecule_cached_string.cpp
More file actions
128 lines (107 loc) · 4.58 KB
/
Copy pathexample_descriptor_molecule_cached_string.cpp
File metadata and controls
128 lines (107 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// (c) Copyright BCL @ Vanderbilt University 2014
// (c) BCL Homepage: http://www.meilerlab.org/bclcommons
// (c) BCL Code Repository: https://github.com/BCLCommons/bcl
// (c)
// (c) The BioChemical Library (BCL) was originally developed by contributing members of the Meiler Lab @ Vanderbilt University.
// (c)
// (c) The BCL is now made available as an open-source software package distributed under the permissive MIT license,
// (c) developed and maintained by the Meiler Lab at Vanderbilt University and contributing members of the BCL Commons.
// (c)
// (c) External code contributions to the BCL are welcome. Please visit the BCL Commons GitHub page for information on how you can contribute.
// (c)
// (c) This file is part of the BCL software suite and is made available under the MIT license.
// (c)
// include example header
#include "example.h"
// include the header of the class which this example is for
#include "descriptor/bcl_descriptor_molecule_cached_string.h"
// includes from bcl - sorted alphabetically
#include "chemistry/bcl_chemistry_fragment_ensemble.h"
#include "io/bcl_io_file.h"
// external includes - sorted alphabetically
namespace bcl
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//!
//! @example example_descriptor_molecule_cached_string.cpp
//!
//! @author kothiwsk
//! @date Feb 14, 2014
//! @remarks status complete
//! @remarks reviewed by nobody on
//!
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class ExampleDescriptorMoleculeCachedString :
public ExampleInterface
{
public:
ExampleDescriptorMoleculeCachedString *Clone() const
{
return new ExampleDescriptorMoleculeCachedString( *this);
}
/////////////////
// data access //
/////////////////
//! @brief returns class name
//! @return the class name as const ref std::string
const std::string &GetClassIdentifier() const
{
return GetStaticClassName( *this);
}
int Run() const
{
// create input stream for reading a smallmolecule ensemble
io::IFStream input;
BCL_ExampleMustOpenInputFile( input, AddExampleInputPathToFilename( e_Chemistry, "test_set.5_structures.sdf"));
// read in ensemble
chemistry::FragmentEnsemble ensemble( input);
// close stream
io::File::CloseClearFStream( input);
// make a property that looks up the mGluR5 Category
descriptor::MoleculeCachedString mglur5_category;
BCL_ExampleCheck( mglur5_category.GetAlias(), "Cached");
// create the label for the property
util::ObjectDataLabel mglur5_category_label( "Cached(mGluR5 Category,size=12)");
BCL_ExampleAssert( mglur5_category.TryRead( util::ObjectDataLabel( "mGluR5 Category"), util::GetLogger()), true);
// check the resulting label
BCL_ExampleCheck
(
(
util::Implementation< descriptor::Base< chemistry::AtomConformationalInterface, char> >( mglur5_category).GetLabel()
),
mglur5_category_label
);
// make a second property that looks for a property that will be added containing common delimiters
descriptor::MoleculeCachedString test_delimiters_ignored;
BCL_ExampleAssert
(
test_delimiters_ignored.TryRead( util::ObjectDataLabel( "Delimiters"), util::GetLogger()),
true
);
BCL_ExampleAssert
(
test_delimiters_ignored.TryRead( util::ObjectDataLabel( "Cached(Delimiters,size=100)"), util::GetLogger()),
true
);
// get the first molecule out of the ensemble
chemistry::ConformationInterface &first_molecule( *ensemble.Begin());
// check that the mglur5 category retriever works
BCL_ExampleCheck( std::string( mglur5_category.SumOverObject( first_molecule).Begin(), 11), "Potentiator");
// add a property called Delimiters to the first molecule
std::string delimiters( "\"' \t()[]\r\n,+-;:<>{}!@#$%^&*()=`\\|");
first_molecule.StoreProperty( "Delimiters", delimiters);
// test that delimiters are ignored
BCL_ExampleCheck
(
util::TrimString( std::string( test_delimiters_ignored.SumOverObject( first_molecule).Begin(), delimiters.size())),
delimiters
);
return 0;
} // Run
static const ExampleClass::EnumType s_Instance;
}; //end ExampleDescriptorMoleculeCachedString
const ExampleClass::EnumType ExampleDescriptorMoleculeCachedString::s_Instance
(
GetExamples().AddEnum( ExampleDescriptorMoleculeCachedString())
);
} // namespace bcl