Search in sources :

Example 1 with Proportion

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;
}
Also used : ArrayList(java.util.ArrayList) CompositionRelation(ambit2.base.relation.composition.CompositionRelation)

Example 2 with Proportion

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;
}
Also used : Proportion(ambit2.base.relation.composition.Proportion) StructureRecord(ambit2.base.data.StructureRecord) SubstanceRecord(ambit2.base.data.SubstanceRecord) BundleRoleFacet(ambit2.base.facet.BundleRoleFacet) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) CompositionRelation(ambit2.base.relation.composition.CompositionRelation)

Example 3 with Proportion

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;
}
Also used : Proportion(ambit2.base.relation.composition.Proportion) SubstanceRecord(ambit2.base.data.SubstanceRecord) CompositionRelation(ambit2.base.relation.composition.CompositionRelation)

Example 4 with Proportion

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);
}
Also used : Proportion(ambit2.base.relation.composition.Proportion) IStructureRecord(ambit2.base.interfaces.IStructureRecord) StructureRecord(ambit2.base.data.StructureRecord) UpdateSubstanceRelation(ambit2.db.substance.relation.UpdateSubstanceRelation) SubstanceRecord(ambit2.base.data.SubstanceRecord) CompositionRelation(ambit2.base.relation.composition.CompositionRelation)

Example 5 with Proportion

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;
}
Also used : ReadChemIdentifiersByComposition(ambit2.db.substance.ids.ReadChemIdentifiersByComposition) Proportion(ambit2.base.relation.composition.Proportion) IStructureRecord(ambit2.base.interfaces.IStructureRecord) StructureRecord(ambit2.base.data.StructureRecord) SubstanceRecord(ambit2.base.data.SubstanceRecord) CompositionRelation(ambit2.base.relation.composition.CompositionRelation)

Aggregations

CompositionRelation (ambit2.base.relation.composition.CompositionRelation)11 Proportion (ambit2.base.relation.composition.Proportion)10 StructureRecord (ambit2.base.data.StructureRecord)7 SubstanceRecord (ambit2.base.data.SubstanceRecord)7 IStructureRecord (ambit2.base.interfaces.IStructureRecord)7 ArrayList (java.util.ArrayList)4 UpdateSubstanceRelation (ambit2.db.substance.relation.UpdateSubstanceRelation)3 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)2 BundleRoleFacet (ambit2.base.facet.BundleRoleFacet)1 STRUC_TYPE (ambit2.base.interfaces.IStructureRecord.STRUC_TYPE)1 ReadChemIdentifiersByComposition (ambit2.db.substance.ids.ReadChemIdentifiersByComposition)1 MaterialAttributeValue (ambit2.export.isa.v1_0.objects.MaterialAttributeValue)1 SQLException (java.sql.SQLException)1