RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
GPChromosome.h
1/***********************************************************************
2 * The rDock program was developed from 1998 - 2006 by the software team
3 * at RiboTargets (subsequently Vernalis (R&D) Ltd).
4 * In 2006, the software was licensed to the University of York for
5 * maintenance and distribution.
6 * In 2012, Vernalis and the University of York agreed to release the
7 * program as Open Source software.
8 * This version is licensed under GNU-LGPL version 3.0 with support from
9 * the University of Barcelona.
10 * http://rdock.sourceforge.net/
11 ***********************************************************************/
12
13// GP chromosome. Keeps the list of integers that represent a chromosome and
14// a list of cells that represent a program.
15
16#ifndef _RBT_GPCHROMOSOME_H
17#define _RBT_GPCHROMOSOME_H
18
19#include "rxdock/Commands.h"
20#include "rxdock/geneticprogram/Cell.h"
21#include "rxdock/geneticprogram/GPTypes.h"
22
23namespace rxdock {
24
25namespace geneticprogram {
26
28public:
29 static const std::string _CT;
31 // Constructors
33 GPChromosome(int, int, int, int, int, int);
35
37 // Destructor
39 virtual ~GPChromosome();
40
41 void Clear();
42 std::ostream &Print(std::ostream &) const;
43 friend std::ostream &operator<<(std::ostream &s, const GPChromosome &p);
44 friend std::istream &operator>>(std::istream &s, GPChromosome &p);
45 const int &operator[](int idx) const { return chrom[idx]; }
46 int &operator[](int idx) { return chrom[idx]; }
47 GPChromosome &operator=(const GPChromosome &c);
48 int size() const { return chrom.size(); }
49 CellPtr Cells(int idx) const { return (cells[idx]); }
50 void SetConstant(ReturnType, int);
51 void ResetConstant(int);
52 int GetStartingCell() { return (chrom[chrom.size() - 1]); }
53 ReturnType GetRCte(int ncell) { return cells[ncell]->GetResult(); }
54 Commands GetCommand(int ncell) {
55 if (ncell < nProgramInputs)
56 throw Error(_WHERE_, "This cell does not have a command");
57 Commands comm(chrom[(nFunctionsInputs + 1) * (ncell - nProgramInputs) +
58 nFunctionsInputs]);
59 return comm;
60 }
61 int GetArgument(int ncell, int narg) {
62 if (ncell < nProgramInputs)
63 throw Error(_WHERE_, "This cell does not have arguments");
64 return (chrom[(nFunctionsInputs + 1) * (ncell - nProgramInputs) + narg]);
65 }
66 bool IsProgramInput(int ncell) { return (ncell < nProgramInputs); }
67
68private:
70 // Private data
72 std::vector<int> chrom;
73 CellList cells;
74 int nProgramInputs, nFunctionsInputs, nProgramOutputs, nRows, nColumns;
75};
76
77// Useful typedefs
78typedef SmartPtr<GPChromosome> GPChromosomePtr; // Smart pointer
79
80std::ostream &operator<<(std::ostream &s, const GPChromosome &p);
81std::istream &operator>>(std::istream &s, GPChromosome &p);
82
83} // namespace geneticprogram
84
85} // namespace rxdock
86
87#endif //_RBTGPCHROMOSOME_H_
Definition Commands.h:20
Definition Error.h:59
Definition SmartPointer.h:48
Definition GPChromosome.h:27