Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
metexplore
met4j
Commits
caaddbf2
Commit
caaddbf2
authored
Jan 20, 2022
by
lcottret
Browse files
Fields of BioParticipant and BioReactant unmodifiable
parent
5ffb3db9
Pipeline
#48439
passed with stages
in 50 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
met4j-core/src/main/java/fr/inrae/toulouse/metexplore/met4j_core/biodata/BioParticipant.java
View file @
caaddbf2
...
...
@@ -49,9 +49,9 @@ import java.util.Objects;
*/
public
abstract
class
BioParticipant
extends
BioEntity
{
private
BioPhysicalEntity
physicalEntity
;
private
final
BioPhysicalEntity
physicalEntity
;
private
Double
quantity
;
private
final
Double
quantity
;
/**
* Constructor
...
...
@@ -63,7 +63,13 @@ public abstract class BioParticipant extends BioEntity {
public
BioParticipant
(
String
id
,
@Nonnull
BioPhysicalEntity
physicalEntity
,
Double
quantity
)
{
super
(
id
);
this
.
physicalEntity
=
physicalEntity
;
this
.
setQuantity
(
quantity
);
if
(
Double
.
isNaN
(
quantity
)
||
Double
.
isInfinite
(
quantity
)
||
quantity
<=
0
)
{
ErrorUtils
.
error
(
"Illegal argument for "
+
quantity
+
" "
+
this
.
getPhysicalEntity
().
getId
()+
": the quantity must be finite and positive"
);
throw
new
IllegalArgumentException
();
}
this
.
quantity
=
quantity
;
}
...
...
@@ -77,18 +83,6 @@ public abstract class BioParticipant extends BioEntity {
}
/**
* <p>Setter for the field <code>physicalEntity</code>.</p>
*
* @param physicalEntity the physicalEntity to set
*/
public
void
setPhysicalEntity
(
BioPhysicalEntity
physicalEntity
)
{
this
.
physicalEntity
=
physicalEntity
;
}
/**
* <p>Getter for the field <code>quantity</code>.</p>
*
...
...
@@ -99,22 +93,6 @@ public abstract class BioParticipant extends BioEntity {
}
/**
* <p>Setter for the field <code>quantity</code>.</p>
*
* @param quantity the quantity to set
*/
public
void
setQuantity
(
Double
quantity
)
{
if
(
Double
.
isNaN
(
quantity
)
||
Double
.
isInfinite
(
quantity
)
||
quantity
<=
0
)
{
ErrorUtils
.
error
(
"Illegal argument for "
+
quantity
+
" "
+
this
.
getPhysicalEntity
().
getId
()+
": the quantity must be finite and positive"
);
throw
new
IllegalArgumentException
();
}
this
.
quantity
=
quantity
;
}
/** {@inheritDoc} */
@Override
public
boolean
equals
(
Object
o
)
{
...
...
met4j-core/src/main/java/fr/inrae/toulouse/metexplore/met4j_core/biodata/BioReactant.java
View file @
caaddbf2
...
...
@@ -50,7 +50,7 @@ import java.util.Objects;
*/
public
class
BioReactant
extends
BioParticipant
{
private
BioCompartment
location
=
null
;
private
final
BioCompartment
location
;
/**
* Constructor
...
...
@@ -61,7 +61,7 @@ public class BioReactant extends BioParticipant {
*/
public
BioReactant
(
@Nonnull
BioMetabolite
metabolite
,
Double
stoichiometry
,
@Nonnull
BioCompartment
location
)
{
super
(
metabolite
.
getId
()+
"__"
+
stoichiometry
+
"__"
+
location
.
getId
(),
metabolite
,
stoichiometry
);
this
.
setL
ocation
(
location
)
;
this
.
l
ocation
=
location
;
}
/**
...
...
@@ -73,15 +73,6 @@ public class BioReactant extends BioParticipant {
return
location
;
}
/**
* Set location
*
* @param location a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioCompartment}
*/
protected
void
setLocation
(
BioCompartment
location
)
{
this
.
location
=
location
;
}
/**
* Get the associated metabolite
*
...
...
met4j-core/src/test/java/fr/inrae/toulouse/metexplore/met4j_core/biodata/BioParticipantTest.java
View file @
caaddbf2
...
...
@@ -48,9 +48,7 @@ public class BioParticipantTest {
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testSetNaNQuantity
()
{
BioParticipant
p
=
new
BioParticipantFake
(
new
BioMetabolite
(
"test"
),
2.0
);
Double
nan
=
Double
.
NaN
;
p
.
setQuantity
(
nan
);
BioParticipant
p
=
new
BioParticipantFake
(
new
BioMetabolite
(
"test"
),
Double
.
NaN
);
}
...
...
@@ -60,9 +58,7 @@ public class BioParticipantTest {
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testSetInfiniteQuantity
()
{
BioParticipant
p
=
new
BioParticipantFake
(
new
BioMetabolite
(
"test"
),
2.0
);
Double
inf
=
Double
.
POSITIVE_INFINITY
;
p
.
setQuantity
(
inf
);
BioParticipant
p
=
new
BioParticipantFake
(
new
BioMetabolite
(
"test"
),
Double
.
POSITIVE_INFINITY
);
}
/**
...
...
@@ -71,12 +67,9 @@ public class BioParticipantTest {
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testSetNegativeOrNullQuantity
()
{
BioParticipant
p
=
new
BioParticipantFake
(
new
BioMetabolite
(
"test"
),
2.0
);
Double
n
=
0.0
;
p
.
setQuantity
(
n
);
n
=
-
10.0
;
p
.
setQuantity
(
n
);
new
BioParticipantFake
(
new
BioMetabolite
(
"test"
),
0.0
);
new
BioParticipantFake
(
new
BioMetabolite
(
"test"
),
-
10.0
);
}
}
met4j-core/src/test/java/fr/inrae/toulouse/metexplore/met4j_core/biodata/BioReactionTest.java
View file @
caaddbf2
...
...
@@ -56,7 +56,7 @@ public class BioReactionTest {
public
static
BioMetabolite
l1
,
l2
,
r1
,
r2
;
public
static
BioReactant
l1Reactant
,
l2Reactant
,
r1Reactant
,
r2Reactant
;
public
static
BioReaction
reaction
;
public
static
BioReaction
reaction
,
reaction2
;
public
static
BioGene
g1
,
g2
,
g3
;
...
...
@@ -79,8 +79,9 @@ public class BioReactionTest {
r2Reactant
=
new
BioReactant
(
r2
,
1.0
,
cpt2
);
reaction
=
new
BioReaction
(
"testreaction"
);
reaction2
=
new
BioReaction
(
"testreaction2"
);
network
.
add
(
reaction
,
cpt1
,
cpt2
,
l1
,
l2
,
r1
,
r2
);
network
.
add
(
reaction
,
reaction2
,
cpt1
,
cpt2
,
l1
,
l2
,
r1
,
r2
);
network
.
affectToCompartment
(
cpt1
,
l1
,
l2
);
network
.
affectToCompartment
(
cpt2
,
r1
,
r2
);
...
...
@@ -88,6 +89,9 @@ public class BioReactionTest {
network
.
affectLeft
(
reaction
,
l1Reactant
,
l2Reactant
);
network
.
affectRight
(
reaction
,
r1Reactant
,
r2Reactant
);
network
.
affectLeft
(
reaction2
,
l1Reactant
);
network
.
affectRight
(
reaction2
,
l2Reactant
);
BioEnzyme
e1
=
new
BioEnzyme
(
"e1"
);
BioProtein
p1
=
new
BioProtein
(
"p1"
);
BioProtein
p2
=
new
BioProtein
(
"p2"
);
...
...
@@ -136,11 +140,8 @@ public class BioReactionTest {
// Positive test
assertTrue
(
"Must be a transport reaction"
,
reaction
.
isTransportReaction
());
// Negative Test
r1Reactant
.
setLocation
(
cpt1
);
r2Reactant
.
setLocation
(
cpt1
);
assertFalse
(
"Must not be a transport reaction"
,
reaction
.
isTransportReaction
());
assertFalse
(
"Must not be a transport reaction"
,
reaction
2
.
isTransportReaction
());
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment