use of ambit2.base.relation.composition.Proportion in project ambit-mirror by ideaconsult.
the class SubstanceRecord method addStructureRelation.
public IStructureRelation addStructureRelation(String compositionUUID, IStructureRecord record, STRUCTURE_RELATION relation, Proportion value) {
if (relatedStructures == null)
relatedStructures = new ArrayList<CompositionRelation>();
CompositionRelation r = new CompositionRelation(this, record, value);
r.setCompositionUUID(compositionUUID);
r.setRelationType(relation);
relatedStructures.add(r);
return r;
}
use of ambit2.base.relation.composition.Proportion in project ambit-mirror by ideaconsult.
the class ReadSubstanceComposition method readCompositionRelation.
public static CompositionRelation readCompositionRelation(CompositionRelation record, ResultSet rs, SubstanceEndpointsBundle bundle) throws AmbitException {
if (record == null)
record = new CompositionRelation(new SubstanceRecord(), new StructureRecord(), new Proportion());
else
record.clear();
try {
try {
String uuid = I5Utils.getPrefixedUUID(rs.getString("cmp_prefix"), rs.getString("cmp_huuid"));
record.setCompositionUUID(uuid);
} catch (Exception xx) {
record.setCompositionUUID(null);
}
record.setName(rs.getString("compositionname"));
try {
record.setHidden(rs.getBoolean("hidden"));
} catch (Exception x) {
record.setHidden(false);
}
record.getFirstStructure().setIdsubstance(rs.getInt("idsubstance"));
record.getSecondStructure().setIdchemical(rs.getInt("idchemical"));
try {
record.getSecondStructure().setInchi(rs.getString("inchi"));
record.getSecondStructure().setSmiles(rs.getString("smiles"));
record.getSecondStructure().setInchiKey(rs.getString("inchikey"));
record.getSecondStructure().setFormula(rs.getString("formula"));
} catch (Exception x) {
x.printStackTrace();
}
record.setRelationType(STRUCTURE_RELATION.valueOf(rs.getString("relation")));
record.getRelation().setFunction(rs.getString("function"));
record.getRelation().setTypical(rs.getString("proportion_typical"));
record.getRelation().setTypical_unit(rs.getString("proportion_typical_unit"));
record.getRelation().setTypical_value(rs.getDouble("proportion_typical_value"));
record.getRelation().setReal_lower(rs.getString("proportion_real_lower"));
record.getRelation().setReal_upper(rs.getString("proportion_real_upper"));
record.getRelation().setReal_unit(rs.getString("proportion_real_unit"));
record.getRelation().setReal_lowervalue(rs.getDouble("proportion_real_lower_value"));
record.getRelation().setReal_uppervalue(rs.getDouble("proportion_real_upper_value"));
try {
record.getSecondStructure().clearFacets();
if (bundle != null && bundle.getID() > 0) {
BundleRoleFacet facet = new BundleRoleFacet(null);
facet.setCount(1);
facet.setTag(rs.getString("tag"));
facet.setRemarks(rs.getString("remarks"));
facet.setValue(bundle);
record.getSecondStructure().addFacet(facet);
}
} catch (Exception x) {
}
try {
String uuid = I5Utils.getPrefixedUUID(rs.getString("refstruc"), rs.getString("refstrucuuid"));
record.setRecordProperty(Property.getI5UUIDInstance(), uuid);
} catch (Exception xx) {
record.removeRecordProperty(Property.getI5UUIDInstance());
}
} catch (Exception x) {
x.printStackTrace();
}
return record;
}
use of ambit2.base.relation.composition.Proportion in project ambit-mirror by ideaconsult.
the class AddCompoundAsSubstanceToBundle method structure2substance.
public static SubstanceRecord structure2substance(IStructureRecord compound) {
SubstanceRecord record = new SubstanceRecord();
record.setIdchemical(compound.getIdchemical());
record.setSubstanceUUID("CHEM-" + UUID.nameUUIDFromBytes(Integer.toString(compound.getIdchemical()).getBytes()));
record.setOwnerName("STRUCTURE");
record.setOwnerUUID("CHEM-" + UUID.nameUUIDFromBytes(record.getOwnerName().getBytes()));
record.setContent(String.format("/compound/%d", compound.getIdchemical()));
record.setFormat("URI");
record.setSubstancetype("Monoconstituent");
Proportion proportion = new Proportion();
proportion.setTypical_value(100.0);
proportion.setTypical_unit("%");
proportion.setTypical("=");
proportion.setReal_lower("=");
proportion.setReal_lowervalue(100.0);
proportion.setReal_unit("%");
CompositionRelation relation = new CompositionRelation(record, compound, STRUCTURE_RELATION.HAS_STRUCTURE, proportion);
relation.setName(record.getContent());
relation.setCompositionUUID(record.getSubstanceUUID());
record.addStructureRelation(relation);
return record;
}
use of ambit2.base.relation.composition.Proportion in project ambit-mirror by ideaconsult.
the class SubstanceRelation_crud_test method createQueryNew.
protected IQueryUpdate<SubstanceRecord, IStructureRecord> createQueryNew() throws Exception {
SubstanceRecord c1 = new SubstanceRecord();
c1.setIdsubstance(1);
StructureRecord c2 = new StructureRecord();
c2.setIdchemical(7);
Proportion p = new Proportion();
p.setReal_lower(">=");
p.setReal_lowervalue(5.0);
p.setReal_upper("<=");
p.setReal_unit("%");
p.setReal_uppervalue(15.0);
p.setTypical_value(10.0);
p.setTypical("c.a.");
p.setTypical_unit("%");
p.setFunction("test");
CompositionRelation r = new CompositionRelation(c1, c2, STRUCTURE_RELATION.HAS_ADDITIVE, p);
r.setCompositionUUID(String.format("L-%s", UUID.randomUUID().toString()));
return new UpdateSubstanceRelation(r);
}
use of ambit2.base.relation.composition.Proportion in project ambit-mirror by ideaconsult.
the class ReadChemIdentifiersByCompositionTest method createQuery.
@Override
protected ReadChemIdentifiersByComposition createQuery() throws Exception {
ReadChemIdentifiersByComposition q = new ReadChemIdentifiersByComposition();
SubstanceRecord r = new SubstanceRecord(1);
CompositionRelation cr = new CompositionRelation(r, new StructureRecord(11, 100215, null, null), new Proportion());
r.addStructureRelation(cr);
q.setFieldname(r);
return q;
}
Aggregations