-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathexample_descriptor_aa_blast_profile.cpp
More file actions
157 lines (128 loc) · 5.73 KB
/
Copy pathexample_descriptor_aa_blast_profile.cpp
File metadata and controls
157 lines (128 loc) · 5.73 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// (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_aa_blast_profile.h"
// includes from bcl - sorted alphabetically
#include "assemble/bcl_assemble_protein_model_with_cache.h"
#include "biol/bcl_biol_aa.h"
#include "chemistry/bcl_chemistry_atom_conformational_interface.h"
#include "descriptor/bcl_descriptor_base.h"
#include "io/bcl_io_file.h"
#include "io/bcl_io_ofstream.h"
#include "util/bcl_util_implementation.h"
// external includes - sorted alphabetically
namespace bcl
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//!
//! @example example_descriptor_aa_blast_profile.cpp
//!
//! @author teixeipl
//! @date Feb 6, 2013
//! @remarks status complete
//! @remarks reviewed by nobody on
//!
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class ExampleDescriptorAABlastProfile :
public ExampleInterface
{
public:
ExampleDescriptorAABlastProfile *Clone() const
{
return new ExampleDescriptorAABlastProfile( *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
{
// form the blast vector, blast list and blast profile
const double blast_array[ 20] = { 0, -2, 0, -1, -2, -1, -1, -1, -2, -3, -3, -1, -2, -3, -2, 6, 0, -4, -3, -3};
const linal::Vector< double> blast_vector( 20, blast_array);
biol::BlastProfile blast_profile( blast_vector);
linal::Vector< float> blast_description( blast_vector);
// form an AA and set the blast profile
biol::AA amino_acid( util::ShPtr< biol::AAData>( new biol::AAData( biol::GetAATypes().ALA, 1, 1)));
amino_acid.SetBlastProfile( blast_profile);
biol::AASequence aa_sequence;
aa_sequence.PushBack( amino_acid);
//////////////////////////////////
// construction and destruction //
//////////////////////////////////
// default constructor
descriptor::AABlastProfile blast;
// clone
util::ShPtr< descriptor::AABlastProfile> sp_blast( blast.Clone());
/////////////////
// data access //
/////////////////
// test the GetLength function
BCL_ExampleCheck( blast.GetSizeOfFeatures(), 20);
////////////////
// operations //
////////////////
// sequence to chain to protein model to protein model with cache
util::ShPtr< assemble::Chain> sp_chain( new assemble::Chain( util::CloneToShPtr( aa_sequence)));
assemble::ProteinModelWithCache protein_model_with_cache( assemble::ProteinModel( sp_chain), false);
descriptor::Iterator< biol::AABase> itr( blast.GetType());
itr.SetObject( protein_model_with_cache);
blast.SetObject( protein_model_with_cache);
// check the descriptions produced
BCL_ExampleCheck( blast( itr), blast_description);
//////////////////////
// input and output //
//////////////////////
//////////////////////
// helper functions //
//////////////////////
// set to ignore the terminal's line width; this way this example file won't change depending on the terminal's
// line width. This is necessary because currently most of the WriteHelp functions used by various classes do not
// support taking a io::FixedLineWidthWriter as an argument
util::GetLogger().SetIgnoreTerminalLineWidth( true);
// write current descriptors to file
io::OFStream write;
BCL_ExampleMustOpenOutputFile
(
write,
GetExamples().GetExamplePath() + "/../../scripts/machine_learning/descriptors/aa/AADescriptorsHelp.txt"
);
write << "Numeric descriptors\n";
util::Implementation< descriptor::Base< biol::AABase, float> >::ResetHaveDisplayedHelp();
util::Implementation< descriptor::Base< chemistry::AtomConformationalInterface, float> >::ResetHaveDisplayedHelp();
io::FixedLineWidthWriter writer;
util::Implementation< descriptor::Base< biol::AABase, float> >::WriteInstancesHelp( writer);
writer << "\nIdentification descriptors\n";
util::Implementation< descriptor::Base< biol::AABase, char> >::ResetHaveDisplayedHelp();
util::Implementation< descriptor::Base< biol::AABase, char> >::WriteInstancesHelp( writer);
write << writer.String();
io::File::CloseClearFStream( write);
// reset fixed-width status
util::GetLogger().SetIgnoreTerminalLineWidth( false);
return 0;
}
static const ExampleClass::EnumType s_Instance;
}; //end ExampleDescriptorAABlastProfile
const ExampleClass::EnumType ExampleDescriptorAABlastProfile::s_Instance
(
GetExamples().AddEnum( ExampleDescriptorAABlastProfile())
);
} // namespace bcl