use of de.ipbhalle.metfraglib.settings.Settings in project MetFragRelaunched by ipb-halle.
the class CheckPreProcessingSmartsFilter_Test method setUp.
@Before
public void setUp() {
// init candidate objects
toTestCandidates[0] = new PrecursorCandidate("InChI=1S/C12H19NO5S2/c1-12(2,3)18-11(14)13-9(8-17-20(4,15)16)10-6-5-7-19-10/h5-7,9H,8H2,1-4H3,(H,13,14)/t9-/m0/s1", "13877939");
toTestCandidates[0].setProperty(VariableNames.INCHI_KEY_1_NAME, "LGXPPQPBQCFQPU");
toTestCandidates[1] = new PrecursorCandidate("InChI=1S/C12H19NO5S2/c1-13(19(2,14)15)12-8-6-11(7-9-12)5-4-10-18-20(3,16)17/h6-9H,4-5,10H2,1-3H3", "59122053");
toTestCandidates[1].setProperty(VariableNames.INCHI_KEY_1_NAME, "CNMCSJSREOGBCU");
toTestCandidates[2] = new PrecursorCandidate("InChI=1S/C12H19NO5S2/c1-19(14,15)13-12-8-6-11(7-9-12)5-3-4-10-18-20(2,16)17/h6-9,13H,3-5,10H2,1-2H3", "54525898");
toTestCandidates[2].setProperty(VariableNames.INCHI_KEY_1_NAME, "YTBWCCSOEYFHGQ");
toTestCandidates[3] = new PrecursorCandidate("InChI=1S/C15H12O5/c16-9-3-1-8(2-4-9)13-7-12(19)15-11(18)5-10(17)6-14(15)20-13/h1-6,13,16-18H,7H2", "932");
toTestCandidates[3].setProperty(VariableNames.INCHI_KEY_1_NAME, "FTVWIRXFELQLPI");
this.settings = new Settings();
}
use of de.ipbhalle.metfraglib.settings.Settings in project MetFragRelaunched by ipb-halle.
the class CheckPreProcessingSuspectListFilter_Test method setUp.
@Before
public void setUp() {
// init candidate objects
toTestCandidates[0] = new PrecursorCandidate("InChI=1S/C12H19NO5S2/c1-12(2,3)18-11(14)13-9(8-17-20(4,15)16)10-6-5-7-19-10/h5-7,9H,8H2,1-4H3,(H,13,14)/t9-/m0/s1", "13877939");
toTestCandidates[0].setProperty(VariableNames.INCHI_KEY_1_NAME, "LGXPPQPBQCFQPU");
toTestCandidates[1] = new PrecursorCandidate("InChI=1S/C12H19NO5S2/c1-13(19(2,14)15)12-8-6-11(7-9-12)5-4-10-18-20(3,16)17/h6-9H,4-5,10H2,1-3H3", "59122053");
toTestCandidates[1].setProperty(VariableNames.INCHI_KEY_1_NAME, "CNMCSJSREOGBCU");
toTestCandidates[2] = new PrecursorCandidate("InChI=1S/C12H19NO5S2/c1-19(14,15)13-12-8-6-11(7-9-12)5-3-4-10-18-20(2,16)17/h6-9,13H,3-5,10H2,1-2H3", "54525898");
toTestCandidates[2].setProperty(VariableNames.INCHI_KEY_1_NAME, "YTBWCCSOEYFHGQ");
toTestCandidates[3] = new PrecursorCandidate("InChI=1S/C15H12O5/c16-9-3-1-8(2-4-9)13-7-12(19)15-11(18)5-10(17)6-14(15)20-13/h1-6,13,16-18H,7H2", "932");
toTestCandidates[3].setProperty(VariableNames.INCHI_KEY_1_NAME, "FTVWIRXFELQLPI");
this.settings = new Settings();
this.candidateFilter = new PreProcessingCandidateSuspectListFilter(this.inChIKeys, "test", settings, false);
}
use of de.ipbhalle.metfraglib.settings.Settings in project MetFragRelaunched by ipb-halle.
the class CombinedMetFragProcess method initExternalProperties.
/**
* @param path
* @param candidateList
* @return
*/
private boolean initExternalProperties(String path, CandidateList candidateList, String[] propertyValuesToScore) {
Settings settings = new Settings();
settings.set(VariableNames.LOCAL_DATABASE_PATH_NAME, path);
LocalPropertyFileDatabase propertyDatabase = new LocalPropertyFileDatabase(settings);
java.util.ArrayList<String> externalInChIKeys = new java.util.ArrayList<String>();
java.util.ArrayList<String> externalPropertiesDefined = new java.util.ArrayList<String>();
java.util.ArrayList<String> ids = null;
try {
ids = propertyDatabase.getCandidateIdentifiers();
} catch (Exception e) {
this.logger.error("Error: Problems reading ExternalPropertyFile: " + path);
return false;
}
CandidateList externalCandidates = propertyDatabase.getCandidateByIdentifier(ids);
for (int i = 0; i < externalCandidates.getNumberElements(); i++) {
ICandidate externalCandidate = externalCandidates.getElement(i);
if (!externalCandidate.getProperties().containsKey(VariableNames.INCHI_KEY_1_NAME) || externalCandidate.getProperty(VariableNames.INCHI_KEY_1_NAME) == null) {
this.logger.error("Error: InChIKey1 field not defined for all candidate in ExternalPropertyFile: " + path);
return false;
}
String externalInChIKey1 = (String) externalCandidate.getProperty(VariableNames.INCHI_KEY_1_NAME);
if (externalInChIKeys.contains(externalInChIKey1)) {
this.logger.error("Error: InChIKey1 " + externalInChIKey1 + " defined more than once in ExternalPropertyFile: " + path);
return false;
} else
externalInChIKeys.add(externalInChIKey1);
// try to set external values
for (int j = 0; j < candidateList.getNumberElements(); j++) {
ICandidate candidate = candidateList.getElement(j);
String candidateInChIKey1 = (String) candidate.getProperty(VariableNames.INCHI_KEY_1_NAME);
if (externalInChIKey1.equals(candidateInChIKey1)) {
java.util.Enumeration<?> externalKeys = externalCandidate.getProperties().keys();
while (externalKeys.hasMoreElements()) {
String currentKey = (String) externalKeys.nextElement();
for (int k = 0; k < propertyValuesToScore.length; k++) {
if (propertyValuesToScore[k].equals(currentKey)) {
if (!externalPropertiesDefined.contains(currentKey))
externalPropertiesDefined.add(currentKey);
Double value = null;
try {
value = (Double) externalCandidate.getProperty(currentKey);
} catch (Exception e1) {
try {
value = Double.parseDouble((String) externalCandidate.getProperty(currentKey));
} catch (Exception e2) {
this.logger.error("Error: Invalid value for candidate " + externalInChIKey1 + " for column " + currentKey + " in ExternalPropertyFile: " + path);
return false;
}
}
candidate.setProperty(currentKey, value);
}
}
}
}
}
}
// set property to zero (neutral element) in case not defined
for (int i = 0; i < candidateList.getNumberElements(); i++) {
ICandidate candidate = candidateList.getElement(i);
for (int j = 0; j < externalPropertiesDefined.size(); j++) {
if (!candidate.getProperties().containsKey(externalPropertiesDefined.get(j)) || candidate.getProperty(externalPropertiesDefined.get(j)) == null) {
candidate.setProperty(externalPropertiesDefined.get(j), 0.0);
}
}
}
return true;
}
use of de.ipbhalle.metfraglib.settings.Settings in project MetFragRelaunched by ipb-halle.
the class HDTopDownFragmenterAssignerScorer method initialise.
@Override
public void initialise() throws AtomTypeNotKnownFromInputListException, Exception {
/*
* initialise candidate
*/
this.candidates[0].setProperty(VariableNames.HD_NUMBER_EXCHANGED_HYDROGENS, this.settings.get(VariableNames.HD_NUMBER_EXCHANGED_HYDROGENS));
this.candidateWrapper = new HDPrecursorCandidateWrapper(this.candidates[0]);
this.candidateWrapper.initialisePrecursorCandidate();
/*
* initialise fragmenter
*/
this.fragmenter = (AbstractTopDownFragmenter) Class.forName((String) settings.get(VariableNames.METFRAG_FRAGMENTER_TYPE_NAME)).getConstructor(Settings.class).newInstance(settings);
/*
* initialise score
*/
String[] score_types = (String[]) this.settings.get(VariableNames.METFRAG_SCORE_TYPES_NAME);
// init scores and add hd scores
IScore[] scores = new IScore[score_types.length];
for (int i = 0; i < score_types.length; i++) {
logger.debug("\t\tinitialising " + score_types[i]);
scores[i] = (IScore) Class.forName(ClassNames.getClassNameOfScore(score_types[i])).getConstructor(Settings.class).newInstance(this.settings);
}
// add hd fragmenter score
this.scoreCollection = new ScoreCollection(scores);
Object writer = this.settings.get(VariableNames.METFRAG_CANDIDATE_WRITER_NAME);
if (writer != null) {
String[] writers = (String[]) writer;
for (int i = 0; i < writers.length; i++) {
if (writers[i].equals("ExtendedHDCSV")) {
this.extendedWriter = true;
break;
}
}
}
}
use of de.ipbhalle.metfraglib.settings.Settings in project MetFragRelaunched by ipb-halle.
the class LocalPropertyFileDatabase method main.
public static void main(String[] args) throws Exception {
Settings settings = new Settings();
settings.set(VariableNames.LOCAL_DATABASE_PATH_NAME, "/home/cruttkie/Documents/PhD/MetFrag/debugs/emma/msready/v2.0.16-msready/Eawag_rt_inchi.csv");
// settings.set(VariableNames.LOCAL_DATABASE_PATH_NAME, "/tmp/test2.sdf");
LocalPropertyFileDatabase db = new LocalPropertyFileDatabase(settings);
System.out.println(db.getCandidateIdentifiers().size());
}
Aggregations