@Override public void setAttribute(Compound compound, String string){ compound.setName(string); } }
@Override public void setAttribute(Compound compound, String string){ compound.setInChI(string); } }
/** * Constructs DirectoryStorage that is backed by temporary directory. * The default location of temporatory directory is defined by the * java.io.tmpdir system property. */ public DirectoryStorage() throws IOException { this(FileUtil.createTempDirectory()); }
public void prepareModel(Model model) { Qdb qdb = model.getQdb(); Collection<Prediction> predictions = qdb.getPredictionRegistry().getByModel(model); for (Prediction p: predictions) { Set<String> ids = loadValues(p).keySet(); addCompounds(qdb.getCompoundRegistry().getAll(ids)); } loadParameters(Arrays.asList(model.getProperty())); loadParameters(predictions); try { Evaluator eval = EvaluatorFactory.getInstance().getEvaluator(model); eval.init(); try { loadParameters(eval.getDescriptors()); } finally { eval.destroy(); } } catch (Exception e) { throw new RuntimeException("Loading descriptors failed for: "+model.getId(), e); } }
public void prepareDataSet(Qdb qdb) { addCompounds(qdb.getCompoundRegistry()); loadParameters(qdb.getPropertyRegistry()); loadParameters(qdb.getDescriptorRegistry()); }
@Override public void mapValue(Compound compound, String string) throws IOException { string = filter(string); if(string == null){ return; } String id = getId(); Cargo<Compound> cargo = compound.getOrAddCargo(id); // Alternatively, could be kept in memory as a StringPayload cargo.storeString(string); }
private Map<String, String> loadValues(Parameter<?,?> p) { try { return p.getCargo(ValuesCargo.class).loadStringMap(); } catch (IOException e) { return new HashMap<String, String>(); } }
@Override public void mapValue(Compound compound, String string){ string = filter(string); if(string == null || string.trim().length() == 0){ return; } C parameter = getParameter(); ValueFormat<V> format = getFormat(); try { this.values.put(compound.getId(), format.parse(string)); } catch(RuntimeException re){ System.err.println("Cannot parse " + parameter.getId() + " value \"" + escape(string) + "\" for " + compound.getId()); throw re; } }
public Unit<?> loadUnit() throws IOException, QdbException { UnitFormat format = getUnitFormat(); try { return format.parse(loadString(), new ParsePosition(0)); } catch(IllegalArgumentException iae){ throw new QdbException(iae); } }
@Override public void setAttribute(Compound compound, String string){ compound.setCas(string); }
@Override public void setAttribute(Compound compound, String string){ compound.setDescription(string); } }
@Override public void setAttribute(Compound compound, String string){ compound.setId(string); }
@Override protected void close() throws IOException { super.close(); this.cache.clear(); }
@Override protected String valueName(){ return getContainer().getName(); }
protected Property getProperty(String id){ Property property = getQdb().getProperty(id); if(property == null){ throw new IllegalArgumentException("Property \'" + id + "\' not found"); } return property; }
protected Descriptor getDescriptor(String id){ Descriptor descriptor = getQdb().getDescriptor(id); if(descriptor == null){ throw new IllegalArgumentException("Descriptor \'" + id + "\' not found"); } return descriptor; }
@Override public void mapValue(Compound compound, String string){ string = filter(string); if(string == null){ return; } this.references.put(compound.getId(), string); }
@Override public void setAttribute(Compound compound, String string){ Set<String> labels = compound.getLabels(); if(string != null){ labels.addAll(parse(string)); } }
private boolean isHeader(String key, String value){ if(key.equalsIgnoreCase(keyName()) || value.equalsIgnoreCase(valueName())){ return true; } else if(key.equalsIgnoreCase("Id") || (key.length() > 2 && (key.substring(key.length() - 2)).equalsIgnoreCase("Id"))){ return true; } // End if Qdb qdb = getQdb(); if(qdb != null && (qdb.getCompound(key)) == null){ return true; } return false; }
protected String formatResult(final Result result, DecimalFormat format){ StringBuffer sb = new StringBuffer(); Property property = getProperty(); sb.append(property.getName()); sb.append(' ' ).append('=').append(' '); if(format == null){ format = getFormat(property); } sb.append(format(result.getValue(), format)); return sb.toString(); }