Compare commits
9 Commits
Ben2
...
0fb5604d2d
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fb5604d2d | |||
| 1a1e7a24d9 | |||
| 6420a4c606 | |||
| 38a5e37380 | |||
| 3a6968f40f | |||
| 2bf0ca34df | |||
| 73e91b3264 | |||
| 4902c2c492 | |||
| 9ee8a06dd6 |
34
Projet.iml
34
Projet.iml
@@ -7,5 +7,39 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module-library" scope="TEST">
|
||||||
|
<library name="JUnit6">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/6.0.0/junit-jupiter-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/6.0.0/junit-jupiter-api-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/6.0.0/junit-platform-commons-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/jspecify/jspecify/1.0.0/jspecify-1.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/6.0.0/junit-jupiter-params-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/6.0.0/junit-jupiter-engine-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/6.0.0/junit-platform-engine-6.0.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/6.0.0/junit-jupiter-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/6.0.0/junit-jupiter-api-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/6.0.0/junit-platform-commons-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/jspecify/jspecify/1.0.0/jspecify-1.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/6.0.0/junit-jupiter-params-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/6.0.0/junit-jupiter-engine-6.0.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/6.0.0/junit-platform-engine-6.0.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -27,7 +27,7 @@ namespace ecoparasite {
|
|||||||
InputFactory o--> RawData
|
InputFactory o--> RawData
|
||||||
|
|
||||||
interface DataParsing {
|
interface DataParsing {
|
||||||
+ HashSet<Poisson> parse()
|
+ HashSet<T> parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
exception InputFileException {
|
exception InputFileException {
|
||||||
@@ -41,12 +41,17 @@ namespace ecoparasite {
|
|||||||
+ String getMessage()
|
+ String getMessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exception InvalidParsingException {
|
||||||
|
- int parsingId
|
||||||
|
- String parsingClass
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ecoparasite.poissons {
|
namespace ecoparasite.poissons {
|
||||||
|
|
||||||
class Poisson {
|
class Poisson {
|
||||||
- String specie
|
- String id
|
||||||
- Double length
|
- Double length
|
||||||
- Double weight
|
- Double weight
|
||||||
- Double infestation
|
- Double infestation
|
||||||
@@ -64,12 +69,54 @@ namespace ecoparasite {
|
|||||||
+ Mackerel()
|
+ Mackerel()
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class PartiePoisson {
|
class PartiePoisson {
|
||||||
|
- String name
|
||||||
|
- Double infestation
|
||||||
|
+ PartiePoisson(String name, Double infestation)
|
||||||
}
|
}
|
||||||
|
|
||||||
Poisson o--> PartiePoisson : # fishParts
|
Poisson o--> PartiePoisson : # fishParts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ecoparasite.population {
|
||||||
|
|
||||||
|
class Population implements ecoparasite.input.DataParsing {
|
||||||
|
- String id
|
||||||
|
- HashMap<Integer,PopulationArgs> perYear
|
||||||
|
+ Population()
|
||||||
|
}
|
||||||
|
|
||||||
|
Population o--> PopulationArgs : - total
|
||||||
|
|
||||||
|
class PopulationArgs {
|
||||||
|
- int year
|
||||||
|
- int number
|
||||||
|
- Double intensity
|
||||||
|
- Double abondance
|
||||||
|
+ PopulationArgs()
|
||||||
|
}
|
||||||
|
|
||||||
|
PopulationArgs o--> PopulationArgInterval : - length
|
||||||
|
PopulationArgs o--> PopulationArgInterval : - width
|
||||||
|
PopulationArgs o--> PopulationArgInterval : - prevalence
|
||||||
|
PopulationArgs o--> PopulationArgInterval : - ic
|
||||||
|
|
||||||
|
class PopulationArgInterval {
|
||||||
|
- Double min
|
||||||
|
- Double max
|
||||||
|
- Double mean
|
||||||
|
+ PopulationArgInterval()
|
||||||
|
+ PopulationArgInterval()
|
||||||
|
+ Double transformToDouble()
|
||||||
|
+ {static} PopulationArgInterval fromString()
|
||||||
|
}
|
||||||
|
|
||||||
|
class PopulationParsing {
|
||||||
|
+ {static} HashSet<Population> parseParasitesPeru()
|
||||||
|
- {static} void applyValueForParasitesPeru()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace ecoparasite.unknown {
|
namespace ecoparasite.unknown {
|
||||||
|
|
||||||
note top of ecoparasite.unknown : Ce paquet est temporaire pour des classes / interfaces qui devront avoir plus de déclinaisons.
|
note top of ecoparasite.unknown : Ce paquet est temporaire pour des classes / interfaces qui devront avoir plus de déclinaisons.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
nom.merlu;m.size (mm);number of Anisakis sp L3;m.d15N (<EFBFBD>);m.d13C (<EFBFBD>);m.C/N;m.MeHg (ng g-1 dw);m.IHg (ng g-1 dw);m.THg (ng g-1 dw);m.PCB 101 (ng g-1 dw);m.PCB 118 (ng g-1 dw);m.PCB 138 (ng g-1 dw);m.PCB 149 (ng g-1 dw);m.PCB 153 (ng g-1 dw);m.PCB 180 (ng g-1 dw);m.PCB 194 (ng g-1 dw);m.HHCB (ng g-1 dw);m.AHTN (ng g-1 dw);m.EHMC (ng g-1 dw);;a.d15N (<EFBFBD>);a.d13C (<EFBFBD>);a.CN;a.MeHg (ng g-1 dw);a.IHg (ng g-1 dw);a.THg (ng g-1 dw);a.PCB 101 (ng g-1 dw);a.PCB 118 (ng g-1 dw);a.PCB 138 (ng g-1 dw);a.PCB 149 (ng g-1 dw);a.PCB 153 (ng g-1 dw);a.PCB 180 (ng g-1 dw);a.PCB 194 (ng g-1 dw);a.HHCB (ng g-1 dw);a.AHTN (ng g-1 dw);a.OC (ng g-1 dw)
|
nom.merlu;m.size (mm);number of Anisakis sp L3;m.d15N (‰);m.d13C (‰);m.C/N;m.MeHg (ng g-1 dw);m.IHg (ng g-1 dw);m.THg (ng g-1 dw);m.PCB 101 (ng g-1 dw);m.PCB 118 (ng g-1 dw);m.PCB 138 (ng g-1 dw);m.PCB 149 (ng g-1 dw);m.PCB 153 (ng g-1 dw);m.PCB 180 (ng g-1 dw);m.PCB 194 (ng g-1 dw);m.HHCB (ng g-1 dw);m.AHTN (ng g-1 dw);m.EHMC (ng g-1 dw);;a.d15N (‰);a.d13C (‰);a.CN;a.MeHg (ng g-1 dw);a.IHg (ng g-1 dw);a.THg (ng g-1 dw);a.PCB 101 (ng g-1 dw);a.PCB 118 (ng g-1 dw);a.PCB 138 (ng g-1 dw);a.PCB 149 (ng g-1 dw);a.PCB 153 (ng g-1 dw);a.PCB 180 (ng g-1 dw);a.PCB 194 (ng g-1 dw);a.HHCB (ng g-1 dw);a.AHTN (ng g-1 dw);a.OC (ng g-1 dw)
|
||||||
150318 HKE01;425;237;13.36;-18.23;3.10;610.21;244.26;854.48;2.85;1.59;28.78;9.10;32.84;22.60;3.40;1.26;<LOQ;<LOQ;;10.84;-19.32;5.88;67.69;8.57;76.26;18.26;10.74;45.90;17.54;41.19;32.64;<LOQ;<LOQ;<LOQ;83.21
|
150318 HKE01;425;237;13.36;-18.23;3.10;610.21;244.26;854.48;2.85;1.59;28.78;9.10;32.84;22.60;3.40;1.26;<LOQ;<LOQ;;10.84;-19.32;5.88;67.69;8.57;76.26;18.26;10.74;45.90;17.54;41.19;32.64;<LOQ;<LOQ;<LOQ;83.21
|
||||||
150318 HKE08;527;276;13.44;-18.22;3.15;749.39;1110.64;1860.03;3.25;1.32;27.91;8.73;34.12;22.66;1.73;0.19;<LOQ;<LOQ;;11.57;-18.74;5.01;77.88;14.85;92.73;11.56;6.56;31.88;15.19;37.80;21.68;<LOQ;3.38;2.31;63.30
|
150318 HKE08;527;276;13.44;-18.22;3.15;749.39;1110.64;1860.03;3.25;1.32;27.91;8.73;34.12;22.66;1.73;0.19;<LOQ;<LOQ;;11.57;-18.74;5.01;77.88;14.85;92.73;11.56;6.56;31.88;15.19;37.80;21.68;<LOQ;3.38;2.31;63.30
|
||||||
150318 HKE09;540;454;13.53;-17.99;3.11;796.23;299.18;1095.40;3.74;3.39;25.72;9.04;32.81;13.87;2.80;1.09;0.11;<LOQ;;11.13;-18.69;5.23;86.01;16.39;102.40;10.74;9.06;63.45;22.81;73.25;47.00;<LOQ;1.96;<LOQ;36.78
|
150318 HKE09;540;454;13.53;-17.99;3.11;796.23;299.18;1095.40;3.74;3.39;25.72;9.04;32.81;13.87;2.80;1.09;0.11;<LOQ;;11.13;-18.69;5.23;86.01;16.39;102.40;10.74;9.06;63.45;22.81;73.25;47.00;<LOQ;1.96;<LOQ;36.78
|
||||||
|
|||||||
|
4
data/test.csv
Normal file
4
data/test.csv
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Sample_code;Station;Latitude;Longitude;Depth;d13C_raw;d13C_corr;d15N;C_N;StandardLength;TrophicLevel;Anisakis_abdominalcavity;Anisakis_Liver;Anisakis_gonads;Anisakis_stomach;NParasitesViscera;Anisakis_Muscle_Right;Anisakis_Muscle_Left;Aniskis_Muscle_total;NParasitesTotal
|
||||||
|
TRACTRA_S0575_A0439;S0575;48.8692264;-4.3976635;96.84;-20.09735065;-19.14374028;12.52361179;4.316778148;257;3.117572211;7;1;0;1;9;1;3;4;13
|
||||||
|
TRACTRA_S0575_A0440;S0575;48.8692264;-4.3976635;96.84;-20.02738845;-19.42703789;12.25444555;3.959950061;252;3.038405671;263;5;0;21;289;12;11;23;312
|
||||||
|
TRACTRA_S0575_A0441;S0575;48.8692264;-4.3976635;96.84;-19.82735569;-18.83090708;12.97020596;4.360049101;254;3.248923438;51;1;12;1;65;2;3;5;70
|
||||||
|
@@ -4,7 +4,26 @@ import ecoparasite.poisson.Poisson;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface définissant la fonction de Parsing des données
|
||||||
|
*/
|
||||||
public interface DataParsing {
|
public interface DataParsing {
|
||||||
|
|
||||||
public HashSet<Poisson> parse(RawData data);
|
/**
|
||||||
|
* Permet de parser un élément à partir d'un objet RawData.
|
||||||
|
* @param data l'objet RawData
|
||||||
|
* @param parseTypeId Permet d'indiquer le type de Parsing que l'on veut.
|
||||||
|
* @return Un HashSet de données T retourné.
|
||||||
|
* @param <T> Notre paramètre générique adaptable à plusieurs classes.
|
||||||
|
* @throws RawDataOverflow Si on dépasse la taille de l'objet RawData.
|
||||||
|
* @throws InvalidParsingException Si le type de parsing n'existe pas.
|
||||||
|
*/
|
||||||
|
public static <T> HashSet<T> parse(RawData data, int parseTypeId ) throws RawDataOverflow, InvalidParsingException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> HashSet<T> parse(RawData data) throws RawDataOverflow, InvalidParsingException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class InputFactory {
|
|||||||
|
|
||||||
final public static String DATA_MACKEREL = "Campagne/mackerel.97442.csv";
|
final public static String DATA_MACKEREL = "Campagne/mackerel.97442.csv";
|
||||||
final public static String DATA_MERLU = "Campagne/merlu2018_75164.csv";
|
final public static String DATA_MERLU = "Campagne/merlu2018_75164.csv";
|
||||||
|
final public static String DATA_PARASITES_PERU = "Combinés/ParasitesPeru2021.csv";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construit le chemin vers le fichier de données voulu.
|
* Construit le chemin vers le fichier de données voulu.
|
||||||
|
|||||||
37
src/ecoparasite/input/InvalidParsingException.java
Normal file
37
src/ecoparasite/input/InvalidParsingException.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package ecoparasite.input;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gère une exception lorsque qu'un type de parsing n'existe pas ou bien
|
||||||
|
* qu'une erreur est survenue durant le parsing d'une donnée.
|
||||||
|
*/
|
||||||
|
public class InvalidParsingException extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* L'ID du parsing voulant être réalisé.
|
||||||
|
*/
|
||||||
|
private int parsingId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* De quel classe provient ce parsing.
|
||||||
|
*/
|
||||||
|
private String parsingSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* @param parsingId ID du parsing
|
||||||
|
* @param parsingSource La classe d'où provient ce parsing.
|
||||||
|
*/
|
||||||
|
public InvalidParsingException(int parsingId, String parsingSource) {
|
||||||
|
this.parsingId = parsingId;
|
||||||
|
this.parsingSource = parsingSource;
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getParsingId() {
|
||||||
|
return parsingId;
|
||||||
|
}
|
||||||
|
public String getParsingSource() {
|
||||||
|
return parsingSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -99,7 +99,7 @@ public class RawData {
|
|||||||
* Permet d'obtenir tous les champs d'une entrée.
|
* Permet d'obtenir tous les champs d'une entrée.
|
||||||
* @param index Entrée que vous voulez obtenir, le minimum est l'entrée 1. Le maximum dépend du Dataframe.
|
* @param index Entrée que vous voulez obtenir, le minimum est l'entrée 1. Le maximum dépend du Dataframe.
|
||||||
* @return Une HashMap <colonne, valeur>.
|
* @return Une HashMap <colonne, valeur>.
|
||||||
* @throws RawDataOverflow Si vous avez dépasses le maximum d'entrées du DataFrame.
|
* @throws RawDataOverflow Si vous avez dépassé le maximum d'entrées du DataFrame.
|
||||||
*/
|
*/
|
||||||
public HashMap<String,String> getEntry(int index) throws RawDataOverflow {
|
public HashMap<String,String> getEntry(int index) throws RawDataOverflow {
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ public class RawData {
|
|||||||
HashMap<String,String> entry = new HashMap<>();
|
HashMap<String,String> entry = new HashMap<>();
|
||||||
|
|
||||||
for( ArrayList<String> row : data ){
|
for( ArrayList<String> row : data ){
|
||||||
if( index > row.size()){
|
if( index >= row.size()){
|
||||||
throw new RawDataOverflow( index, row.size() );
|
throw new RawDataOverflow( index, row.size() );
|
||||||
}
|
}
|
||||||
entry.put( row.getFirst(), row.get( index ) );
|
entry.put( row.getFirst(), row.get( index ) );
|
||||||
|
|||||||
@@ -1,26 +1,81 @@
|
|||||||
package ecoparasite.poisson;
|
package ecoparasite.poisson;
|
||||||
|
|
||||||
import ecoparasite.input.DataParsing;
|
import ecoparasite.input.DataParsing;
|
||||||
|
import ecoparasite.input.InvalidParsingException;
|
||||||
import ecoparasite.input.RawData;
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static java.lang.Double.valueOf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hérite de Poisson.
|
* Hérite de Poisson.
|
||||||
* Ajoute les fonctions de Parsing liés aux données collectées sur le Mackerel.
|
* Ajoute les fonctions de Parsing liés aux données collectées sur le Mackerel.
|
||||||
*/
|
*/
|
||||||
public class Mackerel extends Poisson implements DataParsing {
|
public class Mackerel extends Poisson implements DataParsing {
|
||||||
public Mackerel(String species, Double length, Double infestation) {
|
|
||||||
super(species, length, null, infestation);
|
/**
|
||||||
|
* Constructeur de Mackerel
|
||||||
|
* @param length
|
||||||
|
* @param infestation
|
||||||
|
*/
|
||||||
|
public Mackerel(String id, Double length, Double infestation) {
|
||||||
|
super(id, length, null, infestation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public HashSet<Poisson> parse(RawData data) {
|
* Implémentation de la fonction parse de DataParsing.
|
||||||
|
* Renvoie un tableau de poissons à partir d'un RawData.
|
||||||
|
*
|
||||||
|
* @param data Notre RawData
|
||||||
|
* @param parseTypeId L'ID du type de parsing, ignoré ici.
|
||||||
|
* @return Le tableau de poissons.
|
||||||
|
* @throws RawDataOverflow Si on a un dépassement de données dans notre RawData.
|
||||||
|
* @throws InvalidParsingException
|
||||||
|
*/
|
||||||
|
public static HashSet<Poisson> parse(RawData data, int parseTypeId) throws RawDataOverflow, InvalidParsingException {
|
||||||
|
return Mackerel.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implémentation de la fonction parse de Dataparsing
|
||||||
|
* @param data Notre RawData.
|
||||||
|
* @return tableau des poissons
|
||||||
|
* @throws RawDataOverflow Si on a un dépassement de données dans notre RawDataOverflow.
|
||||||
|
*/
|
||||||
|
public static HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||||
|
|
||||||
|
HashMap<String,String> temp = new HashMap<>();
|
||||||
|
|
||||||
HashSet<Poisson> fishSet;
|
HashSet<Poisson> fishSet;
|
||||||
fishSet = new HashSet<>();
|
fishSet = new HashSet<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < data.getData().getFirst().size(); i++) {
|
||||||
|
temp = data.getEntry(i);
|
||||||
|
Poisson newP = new Mackerel(temp.get("Sample_code"),valueOf(temp.get("StandardLength")),valueOf(temp.get("NParasitesViscera")));
|
||||||
|
newP.setFishParts( Mackerel.parsePartiePoisson(temp) );
|
||||||
|
fishSet.add(newP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return fishSet;
|
return fishSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static HashSet<PartiePoisson> parsePartiePoisson(HashMap<String,String> entry){
|
||||||
|
|
||||||
|
HashSet<PartiePoisson> response = new HashSet<>();
|
||||||
|
|
||||||
|
for( String k: entry.keySet() ){
|
||||||
|
if( k.contains( "Anisakis_" ) ){
|
||||||
|
String bodyPart = k.split( "Anisakis_" )[1];
|
||||||
|
Double value = valueOf(entry.get(k));
|
||||||
|
PartiePoisson p = new PartiePoisson(bodyPart, value);
|
||||||
|
response.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
package ecoparasite.poisson;
|
package ecoparasite.poisson;
|
||||||
|
|
||||||
import ecoparasite.input.DataParsing;
|
import ecoparasite.input.DataParsing;
|
||||||
|
import ecoparasite.input.InvalidParsingException;
|
||||||
import ecoparasite.input.RawData;
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static java.lang.Double.valueOf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hérite de Poisson.
|
* Hérite de Poisson.
|
||||||
* Ajoute les fonctions de Parsing liés aux données collectées sur le Merlu.
|
* Ajoute les fonctions de Parsing liés aux données collectées sur le Merlu.
|
||||||
@@ -16,21 +21,43 @@ public class Merlu extends Poisson implements DataParsing {
|
|||||||
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
||||||
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
||||||
*/
|
*/
|
||||||
public Merlu(Double length, Double infestation) {
|
public Merlu(String id, Double length, Double infestation) {
|
||||||
super("Merlu", length, null, infestation);
|
super(id, length, null, infestation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implémentation de la fonction parse de DataParsing.
|
||||||
|
* Renvoie un tableau de poissons à partir d'un RawData.
|
||||||
|
*
|
||||||
|
* @param data Notre RawData
|
||||||
|
* @param parseTypeId L'ID du type de parsing, ignoré ici.
|
||||||
|
* @return Le tableau de poissons.
|
||||||
|
* @throws RawDataOverflow Si on a un dépassement de données dans notre RawData.
|
||||||
|
*/
|
||||||
|
public static HashSet<Poisson> parse(RawData data, int parseTypeId) throws RawDataOverflow, InvalidParsingException {
|
||||||
|
return Mackerel.parse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implémentation de la fonction parse de Dataparsing
|
* Implémentation de la fonction parse de Dataparsing
|
||||||
* @param data
|
* @param data Notre RawData
|
||||||
* @return tableau des poissons
|
* @return tableau des poissons
|
||||||
|
* @throws RawDataOverflow Si on a un dépassement des données de notre objet RawData.
|
||||||
*/
|
*/
|
||||||
@Override
|
public static HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||||
public HashSet<Poisson> parse(RawData data) { //TODO
|
|
||||||
|
HashMap<String,String> temp = new HashMap<>();
|
||||||
|
|
||||||
HashSet<Poisson> fishSet;
|
HashSet<Poisson> fishSet;
|
||||||
fishSet = new HashSet<>();
|
fishSet = new HashSet<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < data.getData().getFirst().size(); i++) {
|
||||||
|
temp = data.getEntry(i);
|
||||||
|
Poisson newP = new Merlu(temp.get("nom.merlu"),valueOf(temp.get("m.size (mm)")),valueOf(temp.get("number of Anisakis sp L3")));
|
||||||
|
|
||||||
|
fishSet.add(newP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return fishSet;
|
return fishSet;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,61 @@
|
|||||||
package ecoparasite.poisson;
|
package ecoparasite.poisson;
|
||||||
|
|
||||||
public abstract class PartiePoisson {
|
/**
|
||||||
|
* Permet d'illustrer une partie d'un poisson.
|
||||||
|
*/
|
||||||
|
public class PartiePoisson {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nom de la partie du poisson.
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Le taux d'infestation de cette partie du poisson.
|
||||||
|
*/
|
||||||
|
private Double infestation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* Génère une partie complète.
|
||||||
|
*
|
||||||
|
* @param name Le nom de la partie.
|
||||||
|
* @param infestation Le taux d'infestation de la partie du poisson.
|
||||||
|
*/
|
||||||
|
public PartiePoisson(String name, Double infestation) {
|
||||||
|
this.name = name;
|
||||||
|
this.infestation = infestation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* Génère une infestation de null comme non communiqué.
|
||||||
|
*
|
||||||
|
* @param name Le nom de la partie.
|
||||||
|
*/
|
||||||
|
public PartiePoisson(String name){
|
||||||
|
this.name = name;
|
||||||
|
this.infestation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
GETTERS / SETTERS
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getInfestation() {
|
||||||
|
return infestation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInfestation(Double infestation) {
|
||||||
|
this.infestation = infestation;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.HashSet;
|
|||||||
*/
|
*/
|
||||||
public class Poisson{
|
public class Poisson{
|
||||||
|
|
||||||
private String specie;
|
private String id;
|
||||||
private Double length;
|
private Double length;
|
||||||
private Double weight;
|
private Double weight;
|
||||||
private Double infestation;
|
private Double infestation;
|
||||||
@@ -16,13 +16,13 @@ public class Poisson{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur de l'objet Poisson
|
* Constructeur de l'objet Poisson
|
||||||
* @param specie Une String representant l'espece du poisson
|
* @param id Une String representant l'espece du poisson
|
||||||
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
||||||
* @param weight Un Wrapper Double representant le poids du poisson
|
* @param weight Un Wrapper Double representant le poids du poisson
|
||||||
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
||||||
*/
|
*/
|
||||||
public Poisson(String specie, Double length, Double weight, Double infestation){
|
public Poisson(String id, Double length, Double weight, Double infestation){
|
||||||
this.specie = specie;
|
this.id = id;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.infestation = infestation;
|
this.infestation = infestation;
|
||||||
@@ -30,11 +30,11 @@ public class Poisson{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter de l'attribut specie
|
* Getter de l'attribut Id
|
||||||
* @return La string de l'attribut specie
|
* @return La string de l'attribut Id
|
||||||
*/
|
*/
|
||||||
public String getSpecie() {
|
public String getId() {
|
||||||
return specie;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,13 +61,29 @@ public class Poisson{
|
|||||||
return infestation;
|
return infestation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter de l'attribut des parties de poisson.
|
||||||
|
* @return Le HashSet des parties de poisson.
|
||||||
|
*/
|
||||||
|
public HashSet<PartiePoisson> getFishParts() {
|
||||||
|
return fishParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter de l'attribut des parties de poisson.
|
||||||
|
* @param fishParts Un hashset de parties de poisson.
|
||||||
|
*/
|
||||||
|
public void setFishParts(HashSet<PartiePoisson> fishParts) {
|
||||||
|
this.fishParts = fishParts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permet d'afficher les informations de notre poisson
|
* Permet d'afficher les informations de notre poisson
|
||||||
* @return La string contenant les informations
|
* @return La string contenant les informations
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
String result = "[ %5s : %4d mm, %4d g, %4d taux d'infestation ]";
|
String result = "[ %5s : %4f mm, %4f g, %4f taux d'infestation ]";
|
||||||
return String.format(result, this.getClass().getSimpleName(), this.getLength(), this.getWeight(), this.getInfestation());
|
return String.format(result, this.getClass().getSimpleName(), this.getLength(), this.getWeight(), this.getInfestation() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
118
src/ecoparasite/population/Population.java
Normal file
118
src/ecoparasite/population/Population.java
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
package ecoparasite.population;
|
||||||
|
|
||||||
|
import ecoparasite.input.DataParsing;
|
||||||
|
import ecoparasite.input.InvalidParsingException;
|
||||||
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de gérer une population selon les années.
|
||||||
|
*/
|
||||||
|
public class Population implements DataParsing {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Espèce de la population.
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Les informations de la population sur le total.
|
||||||
|
*/
|
||||||
|
private PopulationArgs total;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Les informations de la population par année.
|
||||||
|
* Clé : Année, Valeur : Informations de la population.
|
||||||
|
*/
|
||||||
|
private HashMap<Integer,PopulationArgs> perYear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* @param id Espèce
|
||||||
|
* @param total Les informations totales.
|
||||||
|
* @param perYear Les informations par année.
|
||||||
|
*/
|
||||||
|
public Population(String id, PopulationArgs total, HashMap<Integer,PopulationArgs> perYear) {
|
||||||
|
this.id = id;
|
||||||
|
this.total = total;
|
||||||
|
this.perYear = perYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* Pour les informations par année, crée une HashMap vide. Devra être rempli après coup.
|
||||||
|
* @param id Espèce de la population.
|
||||||
|
* @param total Les informations totales.
|
||||||
|
*/
|
||||||
|
public Population(String id, PopulationArgs total) {
|
||||||
|
this.id = id;
|
||||||
|
this.total = total;
|
||||||
|
this.perYear = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* Pour les informations du total, sont remplacés par null.
|
||||||
|
* Pour les informations par année, crée une HashMap vide. Devra être rempli après coup.
|
||||||
|
* @param id Espèce de la population.
|
||||||
|
*/
|
||||||
|
public Population(String id) {
|
||||||
|
this.id = id;
|
||||||
|
this.total = null;
|
||||||
|
this.perYear = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
GETTERS / SETTERS
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PopulationArgs getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Integer,PopulationArgs> getPerYear() {
|
||||||
|
return perYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(PopulationArgs total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPerYear(HashMap<Integer,PopulationArgs> perYear) {
|
||||||
|
this.perYear = perYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raccourci vers les méthodes de DataParsing.
|
||||||
|
* @param data Notre objet RawData.
|
||||||
|
* @param parseTypeId L'ID de parsing.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static HashSet<Population> parse(RawData data, int parseTypeId ) throws RawDataOverflow, InvalidParsingException {
|
||||||
|
switch (parseTypeId) {
|
||||||
|
case 1:
|
||||||
|
return PopulationParsing.parseParasitesPeru(data);
|
||||||
|
default:
|
||||||
|
throw new InvalidParsingException(parseTypeId, Population.class.getSimpleName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raccourci vers les méthodes de DataParsing.
|
||||||
|
* Va par défaut faire ceux des parasites du Perou.
|
||||||
|
*
|
||||||
|
* @param data Notre objet RawData.
|
||||||
|
* @return Notre tableau de populations.
|
||||||
|
*/
|
||||||
|
public static HashSet<Population> parse(RawData data){
|
||||||
|
return PopulationParsing.parseParasitesPeru(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
101
src/ecoparasite/population/PopulationArgInterval.java
Normal file
101
src/ecoparasite/population/PopulationArgInterval.java
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
package ecoparasite.population;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe qui permet de gérer un intervalle de données issues d'un CSV.
|
||||||
|
*
|
||||||
|
* Trois données : minimum, maximum et moyenne entre minimum et maximum.
|
||||||
|
*/
|
||||||
|
public class PopulationArgInterval {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valeur minimale.
|
||||||
|
*/
|
||||||
|
private Double min;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valeur maximale.
|
||||||
|
*/
|
||||||
|
private Double max;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moyenne entre la valeur minimale et maximale.
|
||||||
|
*/
|
||||||
|
private Double mean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur. La moyenne doit être précisée.
|
||||||
|
* @param min Valeur minimale
|
||||||
|
* @param max Valeur maximale
|
||||||
|
* @param mean Moyenne
|
||||||
|
*/
|
||||||
|
public PopulationArgInterval(Double min, Double max, Double mean) {
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
this.mean = mean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur. La moyenne est calculé automatiquement.
|
||||||
|
* @param min Valeur minimale
|
||||||
|
* @param max Valeur maximale.
|
||||||
|
*/
|
||||||
|
public PopulationArgInterval(Double min, Double max) {
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
this.mean = ( this.max + this.min ) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getMin() {
|
||||||
|
return this.min;
|
||||||
|
}
|
||||||
|
public Double getMax() {
|
||||||
|
return this.max;
|
||||||
|
}
|
||||||
|
public Double getMean() {
|
||||||
|
return this.mean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de transformer un intervalle en double.
|
||||||
|
* Si le minimum est égal au maximum, cette valeur est retourné.
|
||||||
|
* Sinon la moyenne est retourné.
|
||||||
|
*
|
||||||
|
* @return La valeur transformée en Double.
|
||||||
|
*/
|
||||||
|
public Double transformToDouble(){
|
||||||
|
if( this.min == this.max )
|
||||||
|
return this.min;
|
||||||
|
return this.mean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de transformer une String (Extraite d'un fichier CSV) et de la transformer en Intervalle.
|
||||||
|
* Gère les séparateurs +/- ainsi que l'entre deux. Sinon, elle sera juste convertie avec minimum = maximum.
|
||||||
|
*
|
||||||
|
* @param rawValue La valeur brute.
|
||||||
|
* @return La valeur en tant qu'intervalle.
|
||||||
|
*/
|
||||||
|
public static PopulationArgInterval fromString( String rawValue ){
|
||||||
|
|
||||||
|
if( rawValue.contains( "±" ) ){ // Plus ou moins.
|
||||||
|
|
||||||
|
String[] numbers = rawValue.split("±");
|
||||||
|
Double mean = Double.parseDouble(numbers[0].trim());
|
||||||
|
Double interval = Double.parseDouble(numbers[1].trim());
|
||||||
|
return new PopulationArgInterval(mean - interval, mean + interval, mean);
|
||||||
|
|
||||||
|
} else if( rawValue.contains( "-" ) ){ // Entre.
|
||||||
|
|
||||||
|
String[] numbers = rawValue.split("-");
|
||||||
|
Double min = Double.parseDouble(numbers[0].trim());
|
||||||
|
Double max = Double.parseDouble(numbers[1].trim());
|
||||||
|
return new PopulationArgInterval(min, max);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Double number = Double.parseDouble(rawValue);
|
||||||
|
return new PopulationArgInterval(number, number);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
174
src/ecoparasite/population/PopulationArgs.java
Normal file
174
src/ecoparasite/population/PopulationArgs.java
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
package ecoparasite.population;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de stocker les paramètres d'une population pour une année spécifique.
|
||||||
|
* Par convention, si on est sur le total, on mettra comme année 0.
|
||||||
|
*/
|
||||||
|
public class PopulationArgs {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Année de référence pour ces paramètres.
|
||||||
|
*/
|
||||||
|
private int year;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Le nombre d'individus analysés.
|
||||||
|
*/
|
||||||
|
private int number;
|
||||||
|
private PopulationArgInterval length;
|
||||||
|
private PopulationArgInterval width;
|
||||||
|
private PopulationArgInterval prevalence;
|
||||||
|
private PopulationArgInterval ic;
|
||||||
|
private Double intensity;
|
||||||
|
private Double abondance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* Toutes les données peuvent être préremplis dans ce constructeur sauf l'année.
|
||||||
|
* L'année sera par défaut à zéro.
|
||||||
|
*
|
||||||
|
* @param N
|
||||||
|
* @param length
|
||||||
|
* @param width
|
||||||
|
* @param prevalence
|
||||||
|
* @param ic
|
||||||
|
* @param intensity
|
||||||
|
* @param abondance
|
||||||
|
*/
|
||||||
|
public PopulationArgs(
|
||||||
|
int N,
|
||||||
|
PopulationArgInterval length,
|
||||||
|
PopulationArgInterval width,
|
||||||
|
PopulationArgInterval prevalence,
|
||||||
|
PopulationArgInterval ic,
|
||||||
|
Double intensity,
|
||||||
|
Double abondance
|
||||||
|
){
|
||||||
|
this.year = 0;
|
||||||
|
this.number = N;
|
||||||
|
this.length = length;
|
||||||
|
this.width = width;
|
||||||
|
this.prevalence = prevalence;
|
||||||
|
this.ic = ic;
|
||||||
|
this.intensity = intensity;
|
||||||
|
this.abondance = abondance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* Toutes les données ainsi que l'année peuvent être préremplis.
|
||||||
|
*
|
||||||
|
* @param year
|
||||||
|
* @param N
|
||||||
|
* @param length
|
||||||
|
* @param width
|
||||||
|
* @param prevalence
|
||||||
|
* @param ic
|
||||||
|
* @param intensity
|
||||||
|
* @param abondance
|
||||||
|
*/
|
||||||
|
public PopulationArgs(
|
||||||
|
int year,
|
||||||
|
int N,
|
||||||
|
PopulationArgInterval length,
|
||||||
|
PopulationArgInterval width,
|
||||||
|
PopulationArgInterval prevalence,
|
||||||
|
PopulationArgInterval ic,
|
||||||
|
Double intensity,
|
||||||
|
Double abondance
|
||||||
|
){
|
||||||
|
this.year = year;
|
||||||
|
this.number = N;
|
||||||
|
this.length = length;
|
||||||
|
this.width = width;
|
||||||
|
this.prevalence = prevalence;
|
||||||
|
this.ic = ic;
|
||||||
|
this.intensity = intensity;
|
||||||
|
this.abondance = abondance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* Permet de remplir tout d'abord l'année, les autres paramètres seront remplis par les setters.
|
||||||
|
*
|
||||||
|
* @param year
|
||||||
|
*/
|
||||||
|
public PopulationArgs(
|
||||||
|
int year
|
||||||
|
){
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur.
|
||||||
|
* Initialise l'objet avec une année par défaut (0).
|
||||||
|
*/
|
||||||
|
public PopulationArgs(){
|
||||||
|
this.year = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
GETTERS / SETTERS
|
||||||
|
*/
|
||||||
|
|
||||||
|
public int getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PopulationArgInterval getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PopulationArgInterval getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PopulationArgInterval getPrevalence() {
|
||||||
|
return prevalence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PopulationArgInterval getIc() {
|
||||||
|
return ic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getIntensity() {
|
||||||
|
return intensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getAbondance() {
|
||||||
|
return abondance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber(int number) {
|
||||||
|
this.number = number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(PopulationArgInterval length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(PopulationArgInterval width) {
|
||||||
|
this.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrevalence(PopulationArgInterval prevalence) {
|
||||||
|
this.prevalence = prevalence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIc(PopulationArgInterval ic) {
|
||||||
|
this.ic = ic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntensity(Double intensity) {
|
||||||
|
this.intensity = intensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbondance(Double abondance) {
|
||||||
|
this.abondance = abondance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
113
src/ecoparasite/population/PopulationParsing.java
Normal file
113
src/ecoparasite/population/PopulationParsing.java
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
package ecoparasite.population;
|
||||||
|
|
||||||
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de parser une population spécifique via les schémas fournis.
|
||||||
|
*/
|
||||||
|
public class PopulationParsing {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet, à partir d'un objet RawData, de parse les données tel que le fichier parasitesPeru est structuré.
|
||||||
|
*
|
||||||
|
* @param peruRawData
|
||||||
|
* @return Une liste des populations incluses.
|
||||||
|
*/
|
||||||
|
public static HashSet<Population> parseParasitesPeru(RawData peruRawData ){
|
||||||
|
|
||||||
|
HashMap<String,Population> response = new HashMap<>();
|
||||||
|
|
||||||
|
int index = 1;
|
||||||
|
try {
|
||||||
|
while(true){ // Tant que l'on ne fait pas de débordements d'entrées.
|
||||||
|
|
||||||
|
HashMap<String,String> fields = peruRawData.getEntry(index);
|
||||||
|
|
||||||
|
String espece = fields.get("Espèce");
|
||||||
|
String parametre = fields.get("Paramètre");
|
||||||
|
|
||||||
|
// Récupère la population si elle existe déjà.
|
||||||
|
Population population = null;
|
||||||
|
if( response.containsKey( espece ) ){
|
||||||
|
population = response.get(espece);
|
||||||
|
} else {
|
||||||
|
population = new Population(espece);
|
||||||
|
response.put(espece, population);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Traiter le total
|
||||||
|
if( fields.containsKey( "Total" ) ){
|
||||||
|
if( population.getTotal() == null ){
|
||||||
|
population.setTotal( new PopulationArgs() );
|
||||||
|
}
|
||||||
|
PopulationParsing.applyValueForParasitesPeru( population.getTotal(), parametre, fields.get("Total") );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Traiter les années.
|
||||||
|
for( String k: fields.keySet() ){
|
||||||
|
if( k.equals( "Total" ) || k.equals("Paramètre") || k.equals("Espèce") ) // Déjà traité. Pas des années.
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Integer year = Integer.parseInt(k);
|
||||||
|
|
||||||
|
PopulationArgs popArgsYear = null;
|
||||||
|
if( !population.getPerYear().containsKey(year) ){
|
||||||
|
popArgsYear = new PopulationArgs( year );
|
||||||
|
population.getPerYear().put(year, popArgsYear);
|
||||||
|
} else {
|
||||||
|
popArgsYear = population.getPerYear().get(year);
|
||||||
|
}
|
||||||
|
|
||||||
|
PopulationParsing.applyValueForParasitesPeru( popArgsYear, parametre, fields.get(k) );
|
||||||
|
}
|
||||||
|
|
||||||
|
response.put( espece, population );
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
} catch (RawDataOverflow e){ // Débordement, on a atteint la fin de l'objet RawData.
|
||||||
|
// Stop.
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HashSet<Population>( response.values() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet d'appliquer la valeur au paramètre respectif en se basant sur le nom de la colonne.
|
||||||
|
*
|
||||||
|
* @param populationArgs Les paramètres de la population actuelle.
|
||||||
|
* @param column Le nom de la colonne dans le fichier CSV
|
||||||
|
* @param value La valeur a affecter
|
||||||
|
*/
|
||||||
|
private static void applyValueForParasitesPeru( PopulationArgs populationArgs, String column, String value ){
|
||||||
|
switch( column ){
|
||||||
|
case "N":
|
||||||
|
populationArgs.setNumber(Integer.parseInt(value));
|
||||||
|
break;
|
||||||
|
case "Longueur moyenne ± SD (cm)":
|
||||||
|
populationArgs.setLength( PopulationArgInterval.fromString( value ) );
|
||||||
|
break;
|
||||||
|
case "Poids moyen ± SD (g)":
|
||||||
|
populationArgs.setWidth( PopulationArgInterval.fromString( value ) );
|
||||||
|
break;
|
||||||
|
case "Prévalence (%)":
|
||||||
|
populationArgs.setPrevalence( PopulationArgInterval.fromString( value ) );
|
||||||
|
break;
|
||||||
|
case "IC 95%":
|
||||||
|
populationArgs.setIc( PopulationArgInterval.fromString( value ) );
|
||||||
|
break;
|
||||||
|
case "Intensité moyenne (étendue)":
|
||||||
|
populationArgs.setIntensity( Double.parseDouble( value.split( " " )[0] ) );
|
||||||
|
break;
|
||||||
|
case "Abondance moyenne":
|
||||||
|
populationArgs.setAbondance( Double.parseDouble( value ) );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,21 +1,36 @@
|
|||||||
package ecoparasite.input;
|
package ecoparasite.input;
|
||||||
|
|
||||||
|
import static ecoparasite.input.InputFactory.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
|
|
||||||
|
import ecoparasite.input.InputFactory;
|
||||||
|
import ecoparasite.input.InputFileException;
|
||||||
|
import ecoparasite.input.RawData;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
class InputFactoryTest {
|
class InputFactoryTest {
|
||||||
|
|
||||||
// TODO : Test a être effectué par Sébastien.
|
@org.junit.jupiter.api.Test
|
||||||
@Test
|
void buildDataPath() {
|
||||||
void readFile() throws InputFileException, RawDataOverflow {
|
|
||||||
RawData r = InputFactory.readData( InputFactory.DATA_MACKEREL );
|
String d = "data/Campagne/mackerel.97442.csv";
|
||||||
System.out.println( r );
|
String e = "data/Campagne/merlu2018_75164.csv";
|
||||||
System.out.println( r.getColumnsNames() );
|
|
||||||
System.out.println( r.getDataFromColumn( "Sample_codE" ) );
|
assertArrayEquals(d.toCharArray(), InputFactory.buildDataPath("Campagne/mackerel.97442.csv").toCharArray());
|
||||||
System.out.println( r.getEntry( 2 ) );
|
assertArrayEquals(e.toCharArray(), InputFactory.buildDataPath("Campagne/merlu2018_75164.csv").toCharArray());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@org.junit.jupiter.api.Test
|
||||||
|
void readData() throws InputFileException {
|
||||||
|
RawData test = InputFactory.readData("test.csv");
|
||||||
|
|
||||||
|
System.out.println(test.getData());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@org.junit.jupiter.api.Test
|
||||||
|
void testReadData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
42
tests/ecoparasite/input/RawDataTest.java
Normal file
42
tests/ecoparasite/input/RawDataTest.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package ecoparasite.input;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
class RawDataTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getColumnsNames() throws InputFileException {
|
||||||
|
RawData test = InputFactory.readData("test.csv");
|
||||||
|
|
||||||
|
HashSet<String> d = new HashSet<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < test.getData().size(); i++){
|
||||||
|
d.add(test.getData().get(i).getFirst());
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(test.getColumnsNames());
|
||||||
|
System.out.println(d);
|
||||||
|
|
||||||
|
assertIterableEquals(test.getColumnsNames(),d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getDataFromColumn() throws InputFileException {
|
||||||
|
RawData test = InputFactory.readData("test.csv");
|
||||||
|
|
||||||
|
System.out.println(test.getDataFromColumn("Sample_code"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getEntry() throws InputFileException, RawDataOverflow {
|
||||||
|
RawData test = InputFactory.readData("test.csv");
|
||||||
|
|
||||||
|
System.out.println(test.getEntry(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
24
tests/ecoparasite/poisson/MackerelTest.java
Normal file
24
tests/ecoparasite/poisson/MackerelTest.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package ecoparasite.poisson;
|
||||||
|
|
||||||
|
import ecoparasite.input.InputFactory;
|
||||||
|
import ecoparasite.input.InputFileException;
|
||||||
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
class MackerelTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void parse() throws InputFileException, RawDataOverflow {
|
||||||
|
|
||||||
|
RawData test = InputFactory.readData( InputFactory.DATA_MACKEREL );
|
||||||
|
HashSet<Poisson> fishs = Mackerel.parse( test );
|
||||||
|
|
||||||
|
for( Poisson poisson : fishs){
|
||||||
|
System.out.println(poisson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
tests/ecoparasite/poisson/MerluTest.java
Normal file
26
tests/ecoparasite/poisson/MerluTest.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package ecoparasite.poisson;
|
||||||
|
|
||||||
|
import ecoparasite.input.InputFactory;
|
||||||
|
import ecoparasite.input.InputFileException;
|
||||||
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class MerluTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void parse() throws InputFileException, RawDataOverflow {
|
||||||
|
|
||||||
|
RawData test = InputFactory.readData( InputFactory.DATA_MERLU );
|
||||||
|
HashSet<Poisson> fishs = Merlu.parse( test );
|
||||||
|
|
||||||
|
for( Poisson poisson : fishs){
|
||||||
|
System.out.println(poisson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
23
tests/ecoparasite/population/PopulationParsingTest.java
Normal file
23
tests/ecoparasite/population/PopulationParsingTest.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package ecoparasite.population;
|
||||||
|
|
||||||
|
import ecoparasite.input.InputFactory;
|
||||||
|
import ecoparasite.input.InputFileException;
|
||||||
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class PopulationParsingTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void parseParasitesPeru() throws InputFileException, RawDataOverflow {
|
||||||
|
|
||||||
|
RawData parasitesPeru = InputFactory.readData( InputFactory.DATA_PARASITES_PERU, "," );
|
||||||
|
HashSet<Population> populations = Population.parse( parasitesPeru );
|
||||||
|
System.out.println( populations);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user