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 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //
 27 #include "DNAGeometryMessenger.hh"
 28 
 29 #include "DNAGeometry.hh"
 30 #include "UtilityFunctions.hh"
 31 
 32 #include "G4UIcmdWith3VectorAndUnit.hh"
 33 #include "G4UIcmdWithABool.hh"
 34 #include "G4UIcmdWithADouble.hh"
 35 #include "G4UIcmdWithADoubleAndUnit.hh"
 36 #include "G4UIcmdWithAString.hh"
 37 #include "G4UIcmdWithAnInteger.hh"
 38 #include "G4UIcmdWithoutParameter.hh"
 39 #include "G4UIdirectory.hh"
 40 
 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 42 
 43 DNAGeometryMessenger::DNAGeometryMessenger(DNAGeometry* dnaGeometry)
 44   : fpDNAGeometry(dnaGeometry),
 45     fpDNADirectory(new G4UIdirectory("/dnageom/")),
 46     fpNewPlacementVolumeFile(new G4UIcmdWithAString("/dnageom/placementVolume", this)),
 47     fpVoxelPlacementsFile(new G4UIcmdWithAString("/dnageom/definitionFile", this)),
 48     fpVoxelSideLength(new G4UIcmdWith3VectorAndUnit("/dnageom/placementSize", this)),
 49     fpFractalScaling(new G4UIcmdWith3VectorAndUnit("/dnageom/fractalScaling", this)),
 50     fpAnglesAsPi(new G4UIcmdWithABool("/dnageom/setVoxelPlacementAnglesAsMultiplesOfPi", this)),
 51     fpCustomMoleculeSizes(new G4UIcmdWithABool("/dnageom/useCustomMoleculeSizes", this)),
 52     fpAddMoleculeSize(new G4UIcmdWithAString("/dnageom/moleculeSize", this)),
 53     fpCheckDNAOverlaps(new G4UIcmdWithABool("/dnageom/checkOverlaps", this)),
 54     fpVerbosity(new G4UIcmdWithAnInteger("/dnageom/verbose", this)),
 55     fpSmartless(new G4UIcmdWithAnInteger("/dnageom/setSmartVoxels", this)),
 56     fpIntRangeDirect(new G4UIcmdWithADoubleAndUnit("/dnageom/interactionDirectRange", this)),
 57     fpRadicalKillDistance(new G4UIcmdWithADoubleAndUnit("/dnageom/radicalKillDistance", this)),
 58     fpUseHistoneScav(new G4UIcmdWithABool("/dnageom/activateHistoneScavenging", this)),
 59     fpDrawCellVolumes(new G4UIcmdWithABool("/dnageom/drawCellVolumes", this)),
 60     fpTestDirectory(new G4UIdirectory("/dnatests/")),
 61     fpChromosomeTest(new G4UIcmdWithoutParameter("/dnatests/chromosome", this)),
 62     fpBasePairTest(new G4UIcmdWithoutParameter("/dnatests/basepairs", this)),
 63     fpUniqueIDTest(new G4UIcmdWithoutParameter("/dnatests/uniqueid", this))
 64 {
 65   // Fractals
 66   fpDNADirectory->SetGuidance("Commands to control the fractal.");
 67 
 68   fpNewPlacementVolumeFile->SetGuidance("Set a placement volume");
 69   fpNewPlacementVolumeFile->SetGuidance("format: name path");
 70   fpNewPlacementVolumeFile->SetParameterName("name path", false);
 71 
 72   fpVoxelPlacementsFile->SetGuidance("Path to file that defines placement locations");
 73   fpVoxelPlacementsFile->SetParameterName("path", false);
 74 
 75   fpVoxelSideLength->SetGuidance("Side length for each placement (x, y, z)");
 76   fpVoxelSideLength->SetParameterName("xlength", "ylength", "zlength", false);
 77 
 78   fpFractalScaling->SetGuidance("Scaling of XYZ in fractal definition file");
 79   fpFractalScaling->SetParameterName("xlength", "ylength", "zlength", false);
 80 
 81   fpAnglesAsPi->SetGuidance("Take the angles in the voxel placement file as multiples of pi");
 82   fpAnglesAsPi->SetGuidance("E.g. set to true if the angle 0.5 should mean 90 degrees");
 83   fpAnglesAsPi->SetParameterName("true/false angles as pi", false);
 84   fpAnglesAsPi->SetDefaultValue(false);
 85 
 86   fpCustomMoleculeSizes->SetGuidance("Enable custom molecule sizes");
 87   fpCustomMoleculeSizes->SetGuidance("These can now be set via /dnageom/moleculeSize");
 88   fpCustomMoleculeSizes->SetParameterName("true/false custom sizes", false);
 89   fpCustomMoleculeSizes->SetDefaultValue(false);
 90 
 91   fpAddMoleculeSize->SetGuidance("Set a molecule size in angstrom.");
 92   fpAddMoleculeSize->SetGuidance("format: molecule_name x y z");
 93   fpAddMoleculeSize->SetGuidance("E.G.: PHOSPHATE 3 4 5");
 94   fpAddMoleculeSize->SetGuidance("Note: molecule names are case insensitive");
 95   fpAddMoleculeSize->SetParameterName("name x y z units", false);
 96 
 97   // control
 98   fpCheckDNAOverlaps->SetGuidance("Check overlaps in DNA geometry region");
 99   fpCheckDNAOverlaps->SetParameterName("true/false check overlaps", false);
100 
101   fpVerbosity->SetGuidance("Verbosity for DNA geometry");
102   fpVerbosity->SetParameterName("int verbose level", false);
103 
104   fpSmartless->SetGuidance("Optimisation value (int) for smart voxels");
105   fpSmartless->SetGuidance("The G4 default is 2");
106   fpSmartless->SetParameterName("Optimasation value", false);
107 
108   fpIntRangeDirect->SetGuidance("Critical range to start recording SSBs from direct effects");
109   fpIntRangeDirect->SetParameterName("Range", false);
110 
111   fpRadicalKillDistance->SetGuidance("Distance from base pairs at which to kill radicals");
112   fpRadicalKillDistance->SetParameterName("Range", false);
113 
114   fpUseHistoneScav->SetGuidance("Activate Histone scavenging function with default radius");
115   fpUseHistoneScav->SetGuidance("Radius can be controlled with /dnageom/histoneScavengingRadius");
116   fpUseHistoneScav->SetParameterName("true/false, set histone scavenging on", false);
117 
118   fpDrawCellVolumes->SetGuidance(
119     "Draw cell/chromosome volumes rather than DNA (makes DNA invisible)");
120   fpDrawCellVolumes->SetParameterName("true/false draw cell volumes", false);
121 
122   // Tests
123   fpTestDirectory->SetGuidance("Tests of the DNA geometry");
124 
125   fpChromosomeTest->SetGuidance("Test Chromosome Placement classes");
126 
127   fpBasePairTest->SetGuidance("Test Base Pair indices are correct");
128 
129   fpUniqueIDTest->SetGuidance("Test Unique ID Algorithm");
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133 
134 void DNAGeometryMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
135 {
136   // Fractals
137   if (command == fpNewPlacementVolumeFile.get()) {
138     std::vector<G4String> cmd = utility::Split(newValue, ' ');
139     // input validation
140     if (!(cmd.size() == 2 || cmd.size() == 3)) {
141       G4cout << "Invalid input. Command takes 2 string parameters only" << G4endl
142              << "separated by a space, or three parameters" << G4endl
143              << "where the last is a boolean." << G4endl;
144     }
145     else {
146       G4String vname = (G4String)cmd[0];
147       G4String path = (G4String)cmd[1];
148       G4bool twist = false;
149       if (cmd.size() == 3) {
150         if ((G4String)cmd[2] == "true") {
151           twist = true;
152         }
153         else if ((G4String)cmd[2] != "false") {
154           G4ExceptionDescription errmsg;
155           errmsg << "Invalid input. Third value must be a boolean"
156                  << "written as true or false." << G4endl;
157           G4Exception("DNAGeometryMessenger::SetNewValue", "DNAGeometry001", FatalException,
158                       errmsg);
159         }
160       }
161 
162       if (utility::Path_exists(path)) {
163         fpDNAGeometry->AddVoxelFile(vname, path, twist);
164       }
165       else {
166         G4ExceptionDescription errmsg;
167         errmsg << path << " has wrong path or does not exist :";
168         G4Exception("DNAGeometryMessenger::SetNewValue", "DNAGeometry002", FatalException, errmsg);
169       }
170     }
171   }
172   else if (command == fpVoxelPlacementsFile.get()) {
173     G4String path = newValue;
174     if (utility::Path_exists(path)) {
175       fpDNAGeometry->SetFractalFilename(path);
176     }
177     else {
178       G4ExceptionDescription errmsg;
179       errmsg << "The fractal file path has wrong path or does not exist : " << path << G4endl;
180       G4Exception("DNAGeometryMessenger::SetNewValue", "DNAGeometry003", FatalException, errmsg);
181     }
182   }
183   else if (command == fpVoxelSideLength.get()) {
184     fpDNAGeometry->SetVoxelSideLength(G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(newValue));
185   }
186   else if (command == fpFractalScaling.get()) {
187     fpDNAGeometry->SetFractalScaling(G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(newValue));
188   }
189   else if (command == fpAnglesAsPi.get()) {
190     fpDNAGeometry->SetFractalAnglesAsPi(G4UIcmdWithABool::GetNewBoolValue(newValue));
191   }
192   else if (command == fpCustomMoleculeSizes.get()) {
193     fpDNAGeometry->EnableCustomMoleculeSizes(G4UIcmdWithABool::GetNewBoolValue(newValue));
194   }
195   else if (command == fpAddMoleculeSize.get()) {
196     std::vector<G4String> cmd = utility::Split(newValue, ' ');
197     // input validation
198     if (cmd.size() == 4) {
199       G4cout << "Invalid input. Command takes 4  parameters only" << G4endl
200              << "separated by a space, e.g. phosphate 1 2 3" << G4endl;
201     }
202     else {
203       try {
204         G4String name = cmd[0];
205         G4int x_size = std::stod(cmd[1]);
206         G4int y_size = std::stod(cmd[2]);
207         G4int z_size = std::stod(cmd[3]);
208         G4ThreeVector molecule_size = G4ThreeVector(x_size, y_size, z_size);
209         fpDNAGeometry->AddChangeMoleculeSize(name, molecule_size);
210       }
211       catch (const std::invalid_argument& ia) {
212         G4cerr << "Invalid argument to convert to double: " << ia.what() << G4endl;
213       }
214     }
215   }
216   // control
217   else if (command == fpCheckDNAOverlaps.get()) {
218     fpDNAGeometry->SetOverlaps(G4UIcmdWithABool::GetNewBoolValue(newValue));
219   }
220   else if (command == fpVerbosity.get()) {
221     fpDNAGeometry->SetVerbosity(G4UIcmdWithAnInteger::GetNewIntValue(newValue));
222   }
223   else if (command == fpSmartless.get()) {
224     fpDNAGeometry->SetSmartless(G4UIcmdWithAnInteger::GetNewIntValue(newValue));
225   }
226   else if (command == fpIntRangeDirect.get()) {
227     fpDNAGeometry->SetDirectInteractionRange(
228       G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(newValue));
229   }
230   else if (command == fpRadicalKillDistance.get()) {
231     fpDNAGeometry->SetRadicalKillDistance(G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(newValue));
232   }
233   else if (command == fpUseHistoneScav.get()) {
234     fpDNAGeometry->SetHistoneScav(G4UIcmdWithABool::GetNewBoolValue(newValue));
235   }
236   else if (command == fpDrawCellVolumes.get()) {
237     fpDNAGeometry->SetDrawCellVolumes(G4UIcmdWithABool::GetNewBoolValue(newValue));
238   }
239   else if (command == fpChromosomeTest.get()) {
240     fpDNAGeometry->ChromosomeTest();
241   }
242   else if (command == fpBasePairTest.get()) {
243     fpDNAGeometry->BasePairIndexTest();
244   }
245   else if (command == fpUniqueIDTest.get()) {
246     fpDNAGeometry->UniqueIDTest();
247   }
248 }
249 
250 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
251