Skip to content

Commit

Permalink
add conf keys to turn on/off data path retrieval for GO, Tax and Enzyme
Browse files Browse the repository at this point in the history
  • Loading branch information
pgdurand committed Jul 1, 2021
1 parent 96b4993 commit 9964596
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 15 deletions.
43 changes: 30 additions & 13 deletions src/bzh/plealog/dbmirror/annotator/SRAnnotatorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import bzh.plealog.dbmirror.lucenedico.DicoUtils;
import bzh.plealog.dbmirror.lucenedico.Dicos;
import bzh.plealog.dbmirror.util.Utils;
import bzh.plealog.dbmirror.util.conf.DBMSAbstractConfig;
import bzh.plealog.dbmirror.util.conf.DBMSConfigurator;
import bzh.plealog.dbmirror.util.xref.DBXrefInstancesManager;

public class SRAnnotatorUtils {
Expand Down Expand Up @@ -127,6 +129,15 @@ private static String collectAdditionalIds(SRClassification classif, SRClassific
return buf.toString();
}

private static boolean getDataPath(String confKey) {
DBMSConfigurator conf;
conf = DBMSAbstractConfig.getConfigurator();
if (conf == null) {
return false;
}
return "true".equalsIgnoreCase(conf.getProperty(confKey));
}

public static SRClassification prepareClassification(SROutput bo, DicoTermQuerySystem dico) {

// Extract Bio Classification (IPR, EC, GO and TAX) for all hits
Expand Down Expand Up @@ -159,11 +170,13 @@ public static SRClassification prepareClassification(SROutput bo, DicoTermQueryS
dTerm = dico.getTerm(Dicos.NCBI_TAXONOMY, id);
if (dTerm!=null) {
term.setDescription(dTerm.getDataField());
idpath = dico.getTaxPathIds(id, true, true);
if (idpath!=null) {
idpath = Utils.replaceAll(idpath, "n", "");
term.setPath(idpath);
collectAdditionalIds(classif, classif2, idpath, dico, Dicos.NCBI_TAXONOMY);
if (getDataPath(DBMSConfigurator.ANNOT_GET_TAX_PATH)) {
idpath = dico.getTaxPathIds(id, true, true);
if (idpath!=null) {
idpath = Utils.replaceAll(idpath, "n", "");
term.setPath(idpath);
collectAdditionalIds(classif, classif2, idpath, dico, Dicos.NCBI_TAXONOMY);
}
}
}
}
Expand All @@ -173,10 +186,12 @@ else if (id.startsWith(AnnotationDataModelConstants.ANNOTATION_CATEGORY.EC.name(
dTerm = dico.getTerm(Dicos.ENZYME, id);
if (dTerm!=null) {
term.setDescription(dTerm.getDataField());
idpath = dico.getEnzymePathIds(id, true);
if (idpath!=null) {
term.setPath(idpath);
collectAdditionalIds(classif, classif2, idpath, dico, Dicos.ENZYME);
if (getDataPath(DBMSConfigurator.ANNOT_GET_ENZ_PATH)) {
idpath = dico.getEnzymePathIds(id, true);
if (idpath!=null) {
term.setPath(idpath);
collectAdditionalIds(classif, classif2, idpath, dico, Dicos.ENZYME);
}
}
}
}
Expand All @@ -185,10 +200,12 @@ else if (id.startsWith(AnnotationDataModelConstants.ANNOTATION_CATEGORY.GO.name(
dTerm = dico.getTerm(Dicos.GENE_ONTOLOGY, id);
if (dTerm!=null) {
term.setDescription(DicoUtils.getSimpleGoString(dTerm));
gopaths = dico.getGoPathId(id);
if(!gopaths.isEmpty()) {
idpath = collectAdditionalIds(classif, classif2, gopaths, dico, Dicos.GENE_ONTOLOGY);
term.setPath(idpath);
if (getDataPath(DBMSConfigurator.ANNOT_GET_GO_PATH)) {
gopaths = dico.getGoPathId(id);
if(!gopaths.isEmpty()) {
idpath = collectAdditionalIds(classif, classif2, gopaths, dico, Dicos.GENE_ONTOLOGY);
term.setPath(idpath);
}
}
}
}
Expand Down
25 changes: 23 additions & 2 deletions src/bzh/plealog/dbmirror/util/conf/DBMSConfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ public class DBMSConfigurator {
public static final String ASPERA_KEY = "aspera.key.path";
public static final String ASPERA_BIN = "aspera.bin.path";

//introduced in BeeDeeM 4.8; get GO path during Annotator process. Default is false.
public static final String ANNOT_GET_GO_PATH = "annotator.get.go.path";
//introduced in BeeDeeM 4.8; get NCBI Tax path during Annotator process. Default is true.
public static final String ANNOT_GET_TAX_PATH = "annotator.get.tax.path";
//introduced in BeeDeeM 4.8; get Enzyme path during Annotator process. Default is true.
public static final String ANNOT_GET_ENZ_PATH = "annotator.get.enz.path";

public static enum LUCENE_FS_VALUES {FS_DEFAULT, FS_NIO, FS_SIMPLE};
public static enum LUCENE_LK_VALUES {LK_DEFAULT, LK_NATIVE, LK_SIMPLE};

Expand All @@ -75,7 +82,8 @@ public static enum LUCENE_LK_VALUES {LK_DEFAULT, LK_NATIVE, LK_SIMPLE};

private static final String[] KEYS ={MIRROR_PATH, MIRROR_PREPA_PATH, MIRROR_FILE,
LONG_FILE_NAME, FDB_PRG_NAME, FDB_PATH_NAME, UI_SHOW_PATH, COPY_WORKERS,
FASTA_VOLSIZE, LUCENE_FS, LUCENE_LOCK, ASPERA_KEY, ASPERA_BIN};
FASTA_VOLSIZE, LUCENE_FS, LUCENE_LOCK, ASPERA_KEY, ASPERA_BIN,
ANNOT_GET_GO_PATH, ANNOT_GET_TAX_PATH, ANNOT_GET_ENZ_PATH};

public DBMSConfigurator() {
try {
Expand Down Expand Up @@ -131,6 +139,7 @@ public void load(String path, boolean listenReload) throws IOException {
_pConfig = new PropertiesConfiguration(path);
_pathToFile = path;
cleanValues();
setDefaults();
} catch (Exception e) {
// this has been done for backward compatibility when replacing
// standard Properties by ConfigurationProperties
Expand Down Expand Up @@ -228,7 +237,19 @@ protected void cleanValues() {
_pConfig.setProperty(key, props.getProperty(key));
}
}


protected void setDefaults() {
if (_pConfig.getProperty(ANNOT_GET_GO_PATH)==null) {
_pConfig.setProperty(ANNOT_GET_GO_PATH, "false");
}
if (_pConfig.getProperty(ANNOT_GET_TAX_PATH)==null) {
_pConfig.setProperty(ANNOT_GET_TAX_PATH, "true");
}
if (_pConfig.getProperty(ANNOT_GET_ENZ_PATH)==null) {
_pConfig.setProperty(ANNOT_GET_ENZ_PATH, "true");
}
}

public void dumpContent(Log logger) {
for (String key : KEYS) {
if (_pConfig.containsKey(key) == false)
Expand Down

0 comments on commit 9964596

Please sign in to comment.