enanomapper / data.enanomapper.net

Report issues or feature requests for eNanoMapper search page at
http://search.data.enanomapper.net
0 stars 2 forks source link

reading of SMILES from RDF does not work? #74

Closed egonw closed 7 years ago

egonw commented 7 years ago

Nina, I'm trying to get SMILES read in from the RDF (the roundtripping) and I think I mirror what the RDF exporter does, but I am not seeing the SMILES in the resulting JSON model. Below is the code that I'm using. Do you see something obviously wrong (with the sysout.println I confirmed the SMILES is being picked up by the SPARQL)?

        ResultSet rs = qe.execSelect();
        QuerySolution solution = rs.next(); // only pick the first. If we have more, the SPARQL is wrong
        StructureRecord structure = new StructureRecord();
        System.out.println("component: " + solution.get("component").toString());
        if (solution.contains("smiles")) {
            String smiles = solution.get("smiles").asLiteral().toString();
            System.out.println("SMILES: " + smiles);
            structure.setContent(smiles);
            structure.setFormat("INC");
            structure.setSmiles(structure.getContent());
        }
        Proportion p = new Proportion();
        p.setTypical_value(100.0);
        p.setTypical_unit("%");
        record.addStructureRelation(record.getSubstanceUUID(), structure, STRUCTURE_RELATION.HAS_CONSTITUENT, p);
egonw commented 7 years ago

@vedina I have the same kind of problem with the measured effects... not sure why they don't show up... not sure what I'm missing...

egonw commented 7 years ago

Solved. The .toJSON() method on the record does not serialize all info. The info was being properly read!