Develop Biology
The language of life
Expressor.cpp
Go to the documentation of this file.
1/*
2 * This file is a part of the Biology project by eons LLC.
3 * Biology (aka Develop Biology) is a framework for approaching software
4 * development from a natural sciences perspective.
5 *
6 * Copyright (C) 2021 Séon O'Shannon & eons LLC
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
23#include "bio/genetic/Plasmid.h"
25
26namespace bio {
27namespace genetic {
28
29Expressor::~Expressor()
30{
31
32}
33
34Code Expressor::Activate(StandardDimension proteinId)
35{
36 Code ret = code::Success();
37 molecular::Protein* toActivate = GetById< molecular::Protein* >(proteinId);
38 BIO_SANITIZE(toActivate, ,
39 return false);
40 return toActivate->Activate();
41}
42
43Code Expressor::Activate(Name proteinName)
44{
45 return Activate(molecular::ProteinPerspective::Instance().GetIdWithoutCreation(proteinName));
46}
47
49{
50 Plasmid* plasmidBuffer;
51 Code ret = code::Success();
52 for (
53 SmartIterator dna = GetAll< Plasmid* >()->Begin();
54 !dna.IsAtEnd();
55 ++dna
56 )
57 {
58 plasmidBuffer = dna;
59 if (AddToTranscriptome(plasmidBuffer->TranscribeFor(this)) != code::Success() && ret == code::Success())
60 {
62 }
63 }
64 for (
65 Transcriptome::const_iterator rna = m_transcriptome.begin();
66 rna != m_transcriptome.end();
67 ++rna
68 )
69 {
70 if (Translate(*rna) != code::Success() && ret == code::Success())
71 {
73 }
74 }
75 return ret;
76}
77
78Code Expressor::AddToTranscriptome(const RNA* toExpress)
79{
80 BIO_SANITIZE(toExpress, ,
81 return code::BadArgument1());
82 m_transcriptome.push_back(toExpress);
83 return code::Success();
84}
85
86Code Expressor::Translate(const RNA* mRNA)
87{
88 BIO_SANITIZE(mRNA, ,
90
91 Code ret = code::Success();
92
93 Gene* geneBuffer;
94 for (
95 Transcriptome::const_iterator rna = m_transcriptome.begin();
96 rna != m_transcriptome.end();
97 ++rna
98 )
99 {
100 for (
101 SmartIterator gen = (*rna)->GetAll< Gene* >()->Begin();
102 !gen.IsAtEnd();
103 ++gen
104 )
105 {
106 geneBuffer = gen;
107 if (!geneBuffer->m_insertion.Seek(this))
108 {
109 ret = code::UnknownError();
110 }
111 }
112 }
113 return ret;
114}
115
116} //molecular namespace
117} //bio namespace
#define BIO_SANITIZE(test, success, failure)
bool IsAtEnd() const
virtual Code AddToTranscriptome(const RNA *toExpress)
Definition: Expressor.cpp:78
virtual Code Translate(const RNA *mRNA)
Definition: Expressor.cpp:86
Transcriptome m_transcriptome
Definition: Expressor.h:134
virtual Code ExpressGenes()
Definition: Expressor.cpp:48
Insertion m_insertion
Definition: Gene.h:77
virtual chemical::Substance * Seek(chemical::Substance *insertIn) const
Definition: Insertion.cpp:51
virtual RNA * TranscribeFor(Expressor *expressor) const
Definition: Plasmid.cpp:49
virtual Code Activate()
Definition: Protein.cpp:58
virtual Id GetIdWithoutCreation(Name name) const
Definition: Perspective.h:310
Code TranscriptionError()
Code UnknownError()
Code BadArgument1()
Code Success()
Code TranslationError()
Definition: Cell.h:31
const char * Name
Definition: Types.h:46