Skip to content

Commit 133165f

Browse files
committed
clang tidy issues solved
1 parent a0ed4e3 commit 133165f

File tree

6 files changed

+127
-85
lines changed

6 files changed

+127
-85
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,7 @@ doc/latex
121121
*.dat
122122

123123
# Draft code for comparing models
124-
draft_code_my_own_analysis/
124+
draft_code_my_own_analysis/
125+
126+
# Temporary files
127+
cout.txt

src/cart_cell.cc

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "tumor_cell.h"
2525
#include "utils_aux.h"
2626
#include "core/agent/agent.h"
27+
#include "core/agent/agent_pointer.h"
2728
#include "core/agent/new_agent_event.h"
2829
#include "core/container/math_array.h"
2930
#include "core/diffusion/diffusion_grid.h"
@@ -143,7 +144,7 @@ void CarTCell::ChangeVolumeExponentialRelaxationEquation(
143144

144145
// compute Displacement
145146
Real3 CarTCell::CalculateDisplacement(const InteractionForce* force,
146-
real_t squared_radius, real_t dt) {
147+
real_t squared_radius, real_t /*dt*/) {
147148
auto* sim = Simulation::GetActive();
148149

149150
// real_t h = dt;
@@ -167,7 +168,7 @@ Real3 CarTCell::CalculateDisplacement(const InteractionForce* force,
167168
// compute motility
168169
if (rng->Uniform(0.0, 1.0) < kMotilityProbability) {
169170
// random direction as unitary vector
170-
Real3 random_direction = GenerateRandomDirection();
171+
const Real3 random_direction = GenerateRandomDirection();
171172
Real3 direction_to_immunostimulatory_factor;
172173
// returns normalized gradient towards the immunostimulatory factor source
173174
immunostimulatory_factor_dgrid_->GetGradient(
@@ -179,8 +180,9 @@ Real3 CarTCell::CalculateDisplacement(const InteractionForce* force,
179180
// Convert to unit direction
180181
if (motility[0] * motility[0] + motility[1] * motility[1] +
181182
motility[2] * motility[2] >
182-
0)
183+
0) {
183184
motility.Normalize();
185+
}
184186
// Scale by migration speed and add to the velocity
185187
translation_velocity_on_point_mass += motility * kMigrationSpeedCart;
186188
}
@@ -189,9 +191,10 @@ Real3 CarTCell::CalculateDisplacement(const InteractionForce* force,
189191
//--------------------------------------------
190192
// CAR-T killing or victim cell escaping
191193
//--------------------------------------------
192-
if (state_ == CarTCellState::kAlive) { // If cell is not apoptotic
193-
194-
if (attached_to_tumor_cell_) { // attached to tumor cell
194+
// If cell is not apoptotic
195+
if (state_ == CarTCellState::kAlive) {
196+
// if it is attached to tumor cell
197+
if (attached_to_tumor_cell_) {
195198
// try to kill the cancer cell and in case of failure see if it manages to
196199
// scape the order needs to be this one because it should try to kill
197200
// before seeing if it scapes
@@ -210,7 +213,7 @@ Real3 CarTCell::CalculateDisplacement(const InteractionForce* force,
210213
//--------------------------------------------
211214
// Compute forces between the cells and check for a new attachment
212215
auto calculate_forces_and_elastic_displacement =
213-
L2F([&](Agent* neighbor, real_t squared_distance) {
216+
L2F([&](Agent* neighbor, real_t /*squared_distance*/) {
214217
// Adhesion repulsion forces between cells
215218
// We check for every neighbor object if they touch us, i.e. push us
216219
// away and aggregate the velocities
@@ -222,21 +225,21 @@ Real3 CarTCell::CalculateDisplacement(const InteractionForce* force,
222225
// CAR-T adhesion to new victim cell
223226
Real3 displac = neighbor->GetPosition() - current_position;
224227

225-
if (TumorCell* cancer_cell = dynamic_cast<TumorCell*>(neighbor)) {
228+
if (auto* cancer_cell = dynamic_cast<TumorCell*>(neighbor)) {
226229
// movement towards the tumor cells
227-
real_t sq_norm_displac = displac[0] * displac[0] +
228-
displac[1] * displac[1] +
229-
displac[2] * displac[2];
230+
const real_t sq_norm_displac = displac[0] * displac[0] +
231+
displac[1] * displac[1] +
232+
displac[2] * displac[2];
230233

231234
// The cart moves towards the tumor cell only if they are not
232235
// touching already If they are too close the only force affecting
233236
// is the adhesion force to avoid CAR-T non-stop pushing tumor
234237
// cells. In case of being closer than
235-
// kMaxSquaredDistanceCartMovingTowardsTumorCell there is a
238+
// gKMaxSquaredDistanceCartMovingTowardsTumorCell there is a
236239
// probability kProbabilityPushing for the CAR-T to keep pushing the
237240
// tumor cell
238241
if (sq_norm_displac >
239-
kMaxSquaredDistanceCartMovingTowardsTumorCell) {
242+
gKMaxSquaredDistanceCartMovingTowardsTumorCell) {
240243
translation_velocity_on_point_mass[0] +=
241244
displac[0] * kElasticConstantCart;
242245
translation_velocity_on_point_mass[1] +=
@@ -247,8 +250,9 @@ Real3 CarTCell::CalculateDisplacement(const InteractionForce* force,
247250

248251
// If the CAR-T has not succeeded in attaching to a tumor cell yet,
249252
// it tries again
250-
if (!attached_to_tumor_cell_)
253+
if (!attached_to_tumor_cell_) {
251254
TryToGetAttachedTo(cancer_cell, sq_norm_displac, rng);
255+
}
252256
}
253257
});
254258
ctxt->ForEachNeighbor(calculate_forces_and_elastic_displacement, *this,
@@ -281,14 +285,14 @@ void CarTCell::TryToGetAttachedTo(TumorCell* victim, real_t squared_distance,
281285
(victim->GetOncoproteinLevel() - kOncoproteinLimit) /
282286
kOncoproteinDifference;
283287
// Clamp scale_factor to be in [0,1]
284-
if (oncoprotein_scale_factor > 1.0)
288+
if (oncoprotein_scale_factor > 1.0) {
285289
oncoprotein_scale_factor = 1.0;
290+
}
286291
// If oncoprotein level is lower than the limit the cancer cell does not get
287292
// detected
288293
if (oncoprotein_scale_factor <= 0.0) {
289-
oncoprotein_scale_factor = 0.0;
290-
// the probability is going to be 0 so return the function is the most
291-
// efficient
294+
// oncoprotein_scale_factor = 0.0; the probability is going to be 0 so
295+
// return the function is the most efficient
292296
return;
293297
}
294298

@@ -298,8 +302,9 @@ void CarTCell::TryToGetAttachedTo(TumorCell* victim, real_t squared_distance,
298302
kDifferenceCartAdhesionDistances;
299303
// Clamp scale_factor to be in [0,1]. We already checked that it is > 0
300304
// because squared_distance < kSquaredMaxAdhesionDistanceCart
301-
if (distance_scale_factor > 1.0)
305+
if (distance_scale_factor > 1.0) {
302306
distance_scale_factor = 1.0;
307+
}
303308

304309
// It tries to attach the CAR-T cell to the tumor cell with probability
305310
// kAdhesionRateCart * oncoprotein_scale_factor * distance_scale_factor *
@@ -320,41 +325,41 @@ void CarTCell::TryToGetAttachedTo(TumorCell* victim, real_t squared_distance,
320325
}
321326
}
322327
}
323-
324-
return;
325328
}
326329

327330
// Try to induce apoptosis
328331
bool CarTCell::TryToInduceApoptosis(bdm::AgentPointer<TumorCell> attached_cell,
329-
Random* rng) {
332+
Random* rng) const {
330333
// If there is no attached cell (this should not happen)
331334

332-
if (!attached_to_tumor_cell_)
335+
if (!attached_to_tumor_cell_) {
333336
return false;
337+
}
334338

335339
// factor of how high is the oncoprotein levelof the cancer cell
336340
real_t scale_factor =
337341
(attached_cell->GetOncoproteinLevel() - kOncoproteinLimit) /
338342
kOncoproteinDifference;
339343
// Clamp scale_factor to be in [0,1]
340-
if (scale_factor > 1.0)
344+
if (scale_factor > 1.0) {
341345
scale_factor = 1.0;
346+
}
342347
// If oncoprotein level is lower than the limit the cancer cell does not
343348
// become apoptotic
344349
if (scale_factor < 0.0) {
345-
scale_factor = 0.0;
346-
// the probability is going to be 0 so return the function is the most
347-
// efficient
350+
// scale_factor = 0.0; the probability is going to be 0 so return the
351+
// function is the most efficient
348352
return false;
349353
}
350354
// CAR-T success of killing probability: aggressive cancer cells (high
351355
// oncoprotein level) are more likely to be killed
352-
bool succeeded =
356+
const bool succeeded =
353357
rng->Uniform(0.0, 1.0) < kKillRateCart * scale_factor * kDtMechanics;
354358

355359
// The CAR-T has succeeded to induce apoptosis on the Cancer Cell
356-
if (succeeded)
360+
if (succeeded) {
357361
attached_cell->StartApoptosis();
362+
}
358363

359364
return succeeded;
360365
}

src/cart_cell.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424

2525
#include "tumor_cell.h"
2626
#include "core/agent/agent.h"
27+
#include "core/agent/agent_pointer.h"
2728
#include "core/agent/cell.h"
2829
#include "core/agent/new_agent_event.h"
2930
#include "core/behavior/behavior.h"
3031
#include "core/container/math_array.h"
3132
#include "core/diffusion/diffusion_grid.h"
3233
#include "core/interaction_force.h"
3334
#include "core/real_t.h"
35+
#include "core/util/random.h"
3436

3537
namespace bdm {
3638

@@ -207,7 +209,7 @@ class CarTCell : public Cell {
207209
/// @param rng Pointer to the random number generator
208210
/// @return true if apoptosis was induced, false otherwise
209211
bool TryToInduceApoptosis(bdm::AgentPointer<TumorCell> attached_cell,
210-
Random* rng);
212+
Random* rng) const;
211213

212214
private:
213215
/// Current state of the CAR-T cell

src/hyperparams.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "core/util/math.h"
2727
#include <cmath>
2828
#include <cstddef>
29+
#include <map>
2930

3031
namespace bdm {
3132

@@ -276,7 +277,12 @@ constexpr real_t kElasticConstantCart = 0.01;
276277
/// - The value represents the number of CAR-T cells administered on that day.
277278
/// Example: On day 0 and day 8, 3957 CAR-T cells are introduced (matching the
278279
/// initial tumor cell count).
279-
inline std::map<size_t, size_t> kTreatment = {{0, 3957}, {8, 3957}};
280+
// FIXME: add this parameters in an external no recompiled file which will also
281+
// avoid cppcoreguidelines-avoid-magic-numbers warning
282+
inline const std::map<size_t, size_t> gKTreatment = {
283+
{0, 3957},
284+
{8,
285+
3957}}; // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
280286

281287
/// Do not modify this line: 1-kMigrationBiasCart
282288
constexpr real_t kMigrationOneMinusBiasCart = 1.0 - kMigrationBiasCart;
@@ -296,19 +302,19 @@ constexpr real_t kDifferenceCartAdhesionDistances =
296302
kMaxAdhesionDistanceCart - kMinAdhesionDistanceCart;
297303

298304
/// Do not change this line: radius tumor cell
299-
const real_t kRadiusTumorCell =
305+
const real_t gKRadiusTumorCell =
300306
std::cbrt(kDefaultVolumeNewTumorCell * 3. / (4. * Math::kPi));
301307

302308
/// Do not change this line: radius cart cell
303-
const real_t kRadiusCarTCell =
309+
const real_t gKRadiusCarTCell =
304310
std::cbrt(kDefaultVolumeNewCarTCell * 3. / (4. * Math::kPi));
305311

306312
// Do not change this line: maximum squared distance to avoid CAR-T pushing
307313
// tumor cells If a CAR-T and a Tumor Cell are closer than this distance, the
308314
// CAR-T cell will only move to the tumor cell with the adhesion forces
309315
//(radiusCART + radiusTumorCell + 0.1 to avoid numerical errors)**2
310-
const real_t kMaxSquaredDistanceCartMovingTowardsTumorCell =
311-
std::pow(kRadiusCarTCell + kRadiusTumorCell + 1, 2);
316+
const real_t gKMaxSquaredDistanceCartMovingTowardsTumorCell =
317+
std::pow(gKRadiusCarTCell + gKRadiusTumorCell + 1, 2);
312318

313319
} // namespace bdm
314320

0 commit comments

Comments
 (0)