Skip to content
Snippets Groups Projects
Commit e522332a authored by langella's avatar langella
Browse files

ceinture and bretelle in case of collision

git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@280 b8ef2a07-7df7-436f-90b9-41648038564b
parent 2b658a4b
No related branches found
No related tags found
No related merge requests found
package fr.inra.pappso.xtandempipeline.grouping;
import org.apache.log4j.Logger;
public class HashProtein extends HashKey4Groups {
private static final Logger logger = Logger.getLogger(HashProtein.class);
private String accession;
private int hascode;
......@@ -22,4 +26,18 @@ public class HashProtein extends HashKey4Groups {
return this.hascode;
}
@Override
public boolean equals(Object toCompare) {
if (this.hashCode() == toCompare.hashCode()) {
// very good idea Benoit !
HashProtein toCompareProtein = (HashProtein) toCompare;
if (this.accession.equals(toCompareProtein.accession)) {
return true;
} else {
logger.debug("HashProtein COLLISION on " + accession
+ " compared to " + toCompareProtein.accession);
}
}
return false;
}
}
......@@ -18,10 +18,10 @@ public class HashSampleScan implements Comparable<HashSampleScan> {
this.msRun = msRun;
this.hascode = this.getHashCodeStr().hashCode();
}
@Override
protected void finalize() throws Throwable {
// logger.debug("finalize HashSampleScan");
// logger.debug("finalize HashSampleScan");
}
private String getHashCodeStr() {
......@@ -32,14 +32,14 @@ public class HashSampleScan implements Comparable<HashSampleScan> {
} else {
code = new String("-" + scan + "-" + msRun.getSampleName());
}
//logger.debug("hashcode " + code);
// logger.debug("hashcode " + code);
return code;
}
// public String getFingerPrint() {
// return getHashCodeStr();
// }
// public String getFingerPrint() {
// return getHashCodeStr();
// }
public int compareTo(HashSampleScan p) {
int j = this.msRun.getSampleName().compareTo(
p.getMsRun().getSampleName());
......@@ -49,6 +49,7 @@ public class HashSampleScan implements Comparable<HashSampleScan> {
return (i);
}
@Override
public String toString() {
return new String(scan + " " + msRun.getSampleName());
......@@ -57,8 +58,29 @@ public class HashSampleScan implements Comparable<HashSampleScan> {
@Override
public boolean equals(Object toCompare) {
if (this.hashCode() == toCompare.hashCode()) {
//logger.debug("equals on hashSampleScan "+this.toString());
return true;
// logger.debug("equals on hashSampleScan "+this.toString());
HashSampleScan sampleScanToCompare = (HashSampleScan) toCompare;
if (this.scan == sampleScanToCompare.scan) {
if (msRun == null) {
return true;
} else {
if (this.msRun.getSampleName().equals(
sampleScanToCompare.msRun.getSampleName())) {
return true;
} else {
logger.debug("HashSampleScan COLLISION on "
+ this.toString() + " compared to "
+ sampleScanToCompare.toString());
}
}
}
else {
logger.debug("HashSampleScan COLLISION on "
+ this.toString() + " compared to "
+ sampleScanToCompare.toString());
}
}
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment