Skip to content

Commit

Permalink
fix testing of numder of sequences/entries
Browse files Browse the repository at this point in the history
  • Loading branch information
pgdurand committed Mar 17, 2022
1 parent c1db962 commit 7b6c6c4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
Binary file removed jar/biojava.jar
Binary file not shown.
48 changes: 39 additions & 9 deletions src/test/unit/DefaultLoaderMonitorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
Expand Down Expand Up @@ -79,6 +80,7 @@
import bzh.plealog.dbmirror.util.descriptor.DescriptorEntry;
import bzh.plealog.dbmirror.util.descriptor.IdxDescriptor;
import bzh.plealog.dbmirror.util.runner.DBMSUniqueSeqIdDetector;
import bzh.plealog.dbmirror.util.runner.DBStampProperties;
import bzh.plealog.dbmirror.util.sequence.TaxonMatcherHelper;
import bzh.plealog.dbmirror.util.xref.DBXrefInstancesManager;

Expand Down Expand Up @@ -266,28 +268,56 @@ private static int getNbSequences(String repositoryName,
fail("Unable to load the db descriptor");
}

//First, try to get nb sequences with ".num" file
String ext = "_fdb.num";
if (_dbConf.getTypeCode().equals("d")) {
ext = ".num";
}

String fastaVolumePath = FilenameUtils.concat(_dbConf.getLocalTmpFolder(),
_dbConf.getName() + ext);
if (!new File(fastaVolumePath).exists()) {
boolean foundNumFile = false;
if (new File(fastaVolumePath).exists()) {
foundNumFile = true;
}
else {
// try in prod
fastaVolumePath = FilenameUtils.concat(_dbConf.getLocalProdFolder(),
_dbConf.getName() + ext);
if (new File(fastaVolumePath).exists()) {
foundNumFile = true;
}
}
String line;
try {
line = Utils.readFirstLine(new File(fastaVolumePath));
return new Integer(line).intValue();
} catch (Exception e) {
fail("Unable to read the file containing the number of sequences : "
+ e.getMessage());
if (foundNumFile) {
String line;
try {
line = Utils.readFirstLine(new File(fastaVolumePath));
return new Integer(line).intValue();
} catch (Exception e) {
fail("Unable to read the file containing the number of sequences : " +
fastaVolumePath + ": " + e.getMessage());
}
return -1;
}

//Otherwise, try to get nb sequences from time.txt file
fastaVolumePath = _dbConf.getLocalTmpFolder();
if (!new File(fastaVolumePath).exists()) {
// try in prod
fastaVolumePath = _dbConf.getLocalProdFolder();
if (!new File(fastaVolumePath).exists()) {
fail("Unable to read the file containing the number of sequences/entries : "
+ fastaVolumePath);
}
}
Properties props = DBStampProperties.readDBStamp(fastaVolumePath);

int nbseqs = Integer.valueOf(props.getProperty(DBStampProperties.NB_SEQUENCES));
if (nbseqs<0) {
nbseqs = Integer.valueOf(props.getProperty(DBStampProperties.NB_ENTRIES));
}

return -1;
return nbseqs;
}

private int getSequenceSizeInIndex(String repositoryName,
Expand Down

0 comments on commit 7b6c6c4

Please sign in to comment.