Compare commits
3 Commits
31.03.26
...
9026c901ba
| Author | SHA1 | Date | |
|---|---|---|---|
| 9026c901ba | |||
| 19bf68c2aa | |||
| 6e4b3337fb |
@@ -4,6 +4,7 @@
|
|||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace ecoparasite {
|
|||||||
InputFactory o--> RawData
|
InputFactory o--> RawData
|
||||||
|
|
||||||
interface DataParsing {
|
interface DataParsing {
|
||||||
+ HashSet<T> parse()
|
+ HashSet<Poisson> parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
exception InputFileException {
|
exception InputFileException {
|
||||||
@@ -41,11 +41,6 @@ namespace ecoparasite {
|
|||||||
+ String getMessage()
|
+ String getMessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
exception InvalidParsingException {
|
|
||||||
- int parsingId
|
|
||||||
- String parsingClass
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ecoparasite.poissons {
|
namespace ecoparasite.poissons {
|
||||||
@@ -69,54 +64,12 @@ namespace ecoparasite {
|
|||||||
+ Mackerel()
|
+ Mackerel()
|
||||||
}
|
}
|
||||||
|
|
||||||
class PartiePoisson {
|
abstract 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.
|
||||||
|
|||||||
@@ -2,3 +2,8 @@ Sample_code;Station;Latitude;Longitude;Depth;d13C_raw;d13C_corr;d15N;C_N;Standar
|
|||||||
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_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_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
|
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
|
||||||
|
TRACTRA_S0575_A0442;S0575;48.8692264;-4.3976635;96.84;-19.37802102;-18.26777864;13.43393806;4.4749923;242;3.385315231;158;6;0;1;165;9;19;28;193
|
||||||
|
TRACTRA_S0575_A0443;S0575;48.8692264;-4.3976635;96.84;-18.20541518;-18.20541518;12.68793425;3.369189318;254;3.165902347;67;1;10;1;79;1;6;7;86
|
||||||
|
TRACTRA_S0575_A0444;S0575;48.8692264;-4.3976635;96.84;-20.21559661;-18.91007641;12.62442312;4.672242625;251;3.147222601;140;1;0;0;141;3;6;9;150
|
||||||
|
TRACTRA_S0575_A0888;S0575;48.8692264;-4.3976635;96.84;-20.21559661;-18.91007641;12.62442312;4.672242625;259;3.147222601;;;;;;;;;
|
||||||
|
TRACTRA_S0575_A0445;S0575;48.8692264;-4.3976635;96.84;-19.43517323;-19.13886211;11.25439721;3.65283952;258;2.744273805;281;5;0;3;289;1;8;9;298
|
||||||
|
35
src/ecoparasite/completion/Completion.java
Normal file
35
src/ecoparasite/completion/Completion.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package ecoparasite.completion;
|
||||||
|
|
||||||
|
import ecoparasite.poisson.Poisson;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class Completion {
|
||||||
|
|
||||||
|
public static HashSet<Poisson> completePoisson(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double mean = mean(tablePoisson);
|
||||||
|
|
||||||
|
for (Poisson p : tablePoisson) {
|
||||||
|
|
||||||
|
if ( p.getInfestation().isNaN() ) {
|
||||||
|
p.setInfestation(mean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tablePoisson;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double mean(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double mean = 0.0;
|
||||||
|
|
||||||
|
for (Poisson p : tablePoisson){
|
||||||
|
mean += p.getInfestation();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mean / tablePoisson.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,21 +9,7 @@ import java.util.HashSet;
|
|||||||
*/
|
*/
|
||||||
public interface DataParsing {
|
public interface DataParsing {
|
||||||
|
|
||||||
/**
|
public static HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||||
* 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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HashSet<T> parse(RawData data) throws RawDataOverflow, InvalidParsingException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
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épassé le maximum d'entrées du DataFrame.
|
* @throws RawDataOverflow Si vous avez dépasses 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 {
|
||||||
|
|
||||||
|
|||||||
63
src/ecoparasite/nettoyage/Nettoyage.java
Normal file
63
src/ecoparasite/nettoyage/Nettoyage.java
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package ecoparasite.nettoyage;
|
||||||
|
|
||||||
|
import ecoparasite.poisson.Poisson;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class Nettoyage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tablePoisson
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static HashSet<Poisson> nettoiePoisson(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double mean = mean(tablePoisson); //Moyenne
|
||||||
|
double ecart = ecartType(tablePoisson); // Ecart Type
|
||||||
|
|
||||||
|
double z = 0;
|
||||||
|
|
||||||
|
for (Poisson p : tablePoisson) {
|
||||||
|
z = ( p.getInfestation() - mean ) / ecart;
|
||||||
|
|
||||||
|
if ( z >= 3 ) {
|
||||||
|
p.setInfestation(mean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tablePoisson;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double mean(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double mean = 0.0;
|
||||||
|
|
||||||
|
for (Poisson p : tablePoisson){
|
||||||
|
mean += p.getInfestation();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mean / tablePoisson.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double variance(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double vari = 0.0;
|
||||||
|
double mean = mean(tablePoisson);
|
||||||
|
|
||||||
|
for (Poisson p : tablePoisson) {
|
||||||
|
vari += Math.pow( (p.getInfestation() - mean), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vari / tablePoisson.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double ecartType(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double vari = variance(tablePoisson);
|
||||||
|
|
||||||
|
return Math.sqrt(vari);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
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 ecoparasite.input.RawDataOverflow;
|
||||||
|
|
||||||
@@ -25,25 +24,10 @@ public class Mackerel extends Poisson implements DataParsing {
|
|||||||
super(id, 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.
|
|
||||||
* @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
|
* Implémentation de la fonction parse de Dataparsing
|
||||||
* @param data Notre RawData.
|
* @param data
|
||||||
* @return tableau des poissons
|
* @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 {
|
public static HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||||
|
|
||||||
@@ -55,27 +39,11 @@ public class Mackerel extends Poisson implements DataParsing {
|
|||||||
for (int i = 0; i < data.getData().getFirst().size(); i++) {
|
for (int i = 0; i < data.getData().getFirst().size(); i++) {
|
||||||
temp = data.getEntry(i);
|
temp = data.getEntry(i);
|
||||||
Poisson newP = new Mackerel(temp.get("Sample_code"),valueOf(temp.get("StandardLength")),valueOf(temp.get("NParasitesViscera")));
|
Poisson newP = new Mackerel(temp.get("Sample_code"),valueOf(temp.get("StandardLength")),valueOf(temp.get("NParasitesViscera")));
|
||||||
newP.setFishParts( Mackerel.parsePartiePoisson(temp) );
|
|
||||||
fishSet.add(newP);
|
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,7 +1,6 @@
|
|||||||
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 ecoparasite.input.RawDataOverflow;
|
||||||
|
|
||||||
@@ -25,24 +24,10 @@ public class Merlu extends Poisson implements DataParsing {
|
|||||||
super(id, 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 Notre RawData
|
* @param data
|
||||||
* @return tableau des poissons
|
* @return tableau des poissons
|
||||||
* @throws RawDataOverflow Si on a un dépassement des données de notre objet RawData.
|
|
||||||
*/
|
*/
|
||||||
public static HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
public static HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||||
|
|
||||||
|
|||||||
@@ -1,61 +1,4 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,22 +61,6 @@ 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
|
||||||
|
|||||||
@@ -1,74 +1,32 @@
|
|||||||
package ecoparasite.population;
|
package ecoparasite.population;
|
||||||
|
|
||||||
import ecoparasite.input.DataParsing;
|
import java.util.HashMap;
|
||||||
import ecoparasite.input.InvalidParsingException;
|
import java.util.HashSet;
|
||||||
import ecoparasite.input.RawData;
|
|
||||||
import ecoparasite.input.RawDataOverflow;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
public class Population {
|
||||||
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;
|
private String id;
|
||||||
|
|
||||||
/**
|
|
||||||
* Les informations de la population sur le total.
|
|
||||||
*/
|
|
||||||
private PopulationArgs 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;
|
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) {
|
public Population(String id, PopulationArgs total, HashMap<Integer,PopulationArgs> perYear) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
this.perYear = perYear;
|
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) {
|
public Population(String id, PopulationArgs total) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
this.perYear = new HashMap<>();
|
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) {
|
public Population(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.total = null;
|
this.total = null;
|
||||||
this.perYear = new HashMap<>();
|
this.perYear = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
GETTERS / SETTERS
|
|
||||||
*/
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -89,30 +47,4 @@ public class Population implements DataParsing {
|
|||||||
this.perYear = 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,44 +1,17 @@
|
|||||||
package ecoparasite.population;
|
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 {
|
public class PopulationArgInterval {
|
||||||
|
|
||||||
/**
|
|
||||||
* Valeur minimale.
|
|
||||||
*/
|
|
||||||
private Double min;
|
private Double min;
|
||||||
|
|
||||||
/**
|
|
||||||
* Valeur maximale.
|
|
||||||
*/
|
|
||||||
private Double max;
|
private Double max;
|
||||||
|
|
||||||
/**
|
|
||||||
* Moyenne entre la valeur minimale et maximale.
|
|
||||||
*/
|
|
||||||
private Double mean;
|
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) {
|
public PopulationArgInterval(Double min, Double max, Double mean) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.mean = mean;
|
this.mean = mean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructeur. La moyenne est calculé automatiquement.
|
|
||||||
* @param min Valeur minimale
|
|
||||||
* @param max Valeur maximale.
|
|
||||||
*/
|
|
||||||
public PopulationArgInterval(Double min, Double max) {
|
public PopulationArgInterval(Double min, Double max) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
@@ -55,26 +28,12 @@ public class PopulationArgInterval {
|
|||||||
return this.mean;
|
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(){
|
public Double transformToDouble(){
|
||||||
if( this.min == this.max )
|
if( this.min == this.max )
|
||||||
return this.min;
|
return this.min;
|
||||||
return this.mean;
|
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 ){
|
public static PopulationArgInterval fromString( String rawValue ){
|
||||||
|
|
||||||
if( rawValue.contains( "±" ) ){ // Plus ou moins.
|
if( rawValue.contains( "±" ) ){ // Plus ou moins.
|
||||||
|
|||||||
@@ -1,19 +1,9 @@
|
|||||||
package ecoparasite.population;
|
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 {
|
public class PopulationArgs {
|
||||||
|
|
||||||
/**
|
|
||||||
* Année de référence pour ces paramètres.
|
|
||||||
*/
|
|
||||||
private int year;
|
private int year;
|
||||||
|
|
||||||
/**
|
|
||||||
* Le nombre d'individus analysés.
|
|
||||||
*/
|
|
||||||
private int number;
|
private int number;
|
||||||
private PopulationArgInterval length;
|
private PopulationArgInterval length;
|
||||||
private PopulationArgInterval width;
|
private PopulationArgInterval width;
|
||||||
@@ -22,19 +12,6 @@ public class PopulationArgs {
|
|||||||
private Double intensity;
|
private Double intensity;
|
||||||
private Double abondance;
|
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(
|
public PopulationArgs(
|
||||||
int N,
|
int N,
|
||||||
PopulationArgInterval length,
|
PopulationArgInterval length,
|
||||||
@@ -54,19 +31,6 @@ public class PopulationArgs {
|
|||||||
this.abondance = abondance;
|
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(
|
public PopulationArgs(
|
||||||
int year,
|
int year,
|
||||||
int N,
|
int N,
|
||||||
@@ -87,30 +51,16 @@ public class PopulationArgs {
|
|||||||
this.abondance = abondance;
|
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(
|
public PopulationArgs(
|
||||||
int year
|
int year
|
||||||
){
|
){
|
||||||
this.year = year;
|
this.year = year;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructeur.
|
|
||||||
* Initialise l'objet avec une année par défaut (0).
|
|
||||||
*/
|
|
||||||
public PopulationArgs(){
|
public PopulationArgs(){
|
||||||
this.year = 0;
|
this.year = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
GETTERS / SETTERS
|
|
||||||
*/
|
|
||||||
|
|
||||||
public int getYear() {
|
public int getYear() {
|
||||||
return year;
|
return year;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,18 +6,9 @@ import ecoparasite.input.RawDataOverflow;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
/**
|
|
||||||
* Permet de parser une population spécifique via les schémas fournis.
|
|
||||||
*/
|
|
||||||
public class PopulationParsing {
|
public class PopulationParsing {
|
||||||
|
|
||||||
/**
|
public static HashMap<String,Population> parseParasitesPeru(RawData peruRawData ){
|
||||||
* 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<>();
|
HashMap<String,Population> response = new HashMap<>();
|
||||||
|
|
||||||
@@ -28,9 +19,9 @@ public class PopulationParsing {
|
|||||||
HashMap<String,String> fields = peruRawData.getEntry(index);
|
HashMap<String,String> fields = peruRawData.getEntry(index);
|
||||||
|
|
||||||
String espece = fields.get("Espèce");
|
String espece = fields.get("Espèce");
|
||||||
|
System.out.println(espece);
|
||||||
String parametre = fields.get("Paramètre");
|
String parametre = fields.get("Paramètre");
|
||||||
|
|
||||||
// Récupère la population si elle existe déjà.
|
|
||||||
Population population = null;
|
Population population = null;
|
||||||
if( response.containsKey( espece ) ){
|
if( response.containsKey( espece ) ){
|
||||||
population = response.get(espece);
|
population = response.get(espece);
|
||||||
@@ -68,20 +59,13 @@ public class PopulationParsing {
|
|||||||
response.put( espece, population );
|
response.put( espece, population );
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
} catch (RawDataOverflow e){ // Débordement, on a atteint la fin de l'objet RawData.
|
} catch (RawDataOverflow e){
|
||||||
// Stop.
|
// Stop.
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HashSet<Population>( response.values() );
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 ){
|
private static void applyValueForParasitesPeru( PopulationArgs populationArgs, String column, String value ){
|
||||||
switch( column ){
|
switch( column ){
|
||||||
case "N":
|
case "N":
|
||||||
|
|||||||
28
tests/ecoparasite/completion/CompletionTest.java
Normal file
28
tests/ecoparasite/completion/CompletionTest.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package ecoparasite.completion;
|
||||||
|
|
||||||
|
import ecoparasite.input.InputFactory;
|
||||||
|
import ecoparasite.input.InputFileException;
|
||||||
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
import ecoparasite.poisson.Mackerel;
|
||||||
|
import ecoparasite.poisson.Poisson;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class CompletionTest {
|
||||||
|
|
||||||
|
@org.junit.jupiter.api.Test
|
||||||
|
void completePoisson() throws InputFileException, RawDataOverflow {
|
||||||
|
|
||||||
|
RawData test = InputFactory.readData("test.csv");
|
||||||
|
|
||||||
|
HashSet<Poisson> testp = Mackerel.parse(test);
|
||||||
|
|
||||||
|
testp = Completion.completePoisson(testp);
|
||||||
|
|
||||||
|
System.out.println(testp);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import ecoparasite.input.RawData;
|
|||||||
import ecoparasite.input.RawDataOverflow;
|
import ecoparasite.input.RawDataOverflow;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
@@ -16,8 +16,7 @@ class PopulationParsingTest {
|
|||||||
void parseParasitesPeru() throws InputFileException, RawDataOverflow {
|
void parseParasitesPeru() throws InputFileException, RawDataOverflow {
|
||||||
|
|
||||||
RawData parasitesPeru = InputFactory.readData( InputFactory.DATA_PARASITES_PERU, "," );
|
RawData parasitesPeru = InputFactory.readData( InputFactory.DATA_PARASITES_PERU, "," );
|
||||||
HashSet<Population> populations = Population.parse( parasitesPeru );
|
HashMap<String,Population> populations = PopulationParsing.parseParasitesPeru( parasitesPeru );
|
||||||
System.out.println( populations);
|
System.out.println( populations);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user