Develop Biology
The language of life
Genome.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) 2022 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
22#include "bio/genetic/Genome.h"
23#include "bio/genetic/Plasmid.h"
25
26namespace bio {
27namespace genetic {
28
29GenomeImplementation::GenomeImplementation()
30 :
31 genetic::Class< GenomeImplementation >(
32 this,
33 "Genome",
34 NULL,
35 filter::Genetic())
36{
37 Add< TranscriptionFactor >(transcription_factor::Genome());
38}
39
40GenomeImplementation::~GenomeImplementation()
41{
42
43}
44
45void GenomeImplementation::CacheProteins()
46{
47 mc_registerPlasmid = RotateTo< molecular::Protein* >("RegisterPlasmid");
48 mc_fetchPlasmid = RotateTo< molecular::Protein* >("FetchPlasmid");
49 mc_registrationSite = mc_registerPlasmid->GetIdWithoutCreation("Plasmid Binding Site");
50 mc_nameSite = mc_fetchPlasmid->GetIdWithoutCreation("Name Binding Site");
51 mc_idSite = mc_fetchPlasmid->GetIdWithoutCreation("Id Binding Site");
52 mc_fetchSite = mc_fetchPlasmid->GetIdWithoutCreation("Return Site");
53}
54
55StandardDimension GenomeImplementation::RegisterPlasmid(Plasmid* toRegister)
56{
57 BIO_SANITIZE(toRegister, ,
58 return PlasmidPerspective::InvalidId())
59 StandardDimension ret = PlasmidPerspective::InvalidId();
60 LockThread();
61 mc_registerPlasmid->RotateTo(mc_registrationSite)->Bind(ChemicalCast< chemical::Substance* >(toRegister));
62 if (mc_registerPlasmid->Activate() == code::Success())
63 {
64 ret = toRegister->GetId();
65 }
66 UnlockThread();
67 return ret;
68}
69
70Plasmid* GenomeImplementation::FetchPlasmid(StandardDimension plasmidId)
71{
72 Plasmid* ret = NULL;
73 LockThread();
74 mc_fetchPlasmid->RotateTo(mc_idSite)->Bind(plasmidId);
75 mc_fetchPlasmid->Activate();
76 ret = mc_fetchPlasmid->RotateTo< Plasmid* >(mc_fetchSite);
77 UnlockThread();
78 return ret;
79
80}
81
82Plasmid* GenomeImplementation::FetchPlasmid(Name plasmidName)
83{
84 Plasmid* ret = NULL;
85 LockThread();
86 mc_fetchPlasmid->RotateTo(mc_nameSite)->Bind(plasmidName);
87 mc_fetchPlasmid->Activate();
88 ret = mc_fetchPlasmid->RotateTo< Plasmid* >(mc_fetchSite);
89 UnlockThread();
90 return ret;
91}
92
93} //genetic namespace
94} //bio namespace
#define BIO_SANITIZE(test, success, failure)
virtual Surface * RotateTo(StandardDimension surfaceId)
Definition: Molecule.cpp:48
Code Success()
Filter Genetic()
TranscriptionFactor Genome()
Definition: Cell.h:31
const char * Name
Definition: Types.h:46