Search in sources :

Example 1 with AtomColorer

use of io.imgs.coloration.ColoredAtomGenerator.AtomColorer in project Smiles2Monomers by yoann-dufresne.

the class PictureCoverageGenerator method createPNG.

public ColorsMap createPNG(Coverage coverage, File outfile) {
    ColorsMap coverageColors = new ColorsMap();
    AtomColorer ac = this.cag.getColorer();
    IMolecule mol = coverage.getMolecule(false);
    List<Color> colors = ColorsGenerator.HsbColorsGeneration(coverage.nbMatchesForCoverage());
    int i = 0;
    for (Match match : coverage.getUsedMatches()) {
        Residue res = match.getResidue();
        List<Color> matchesColor = coverageColors.containsKey(res) ? coverageColors.get(res) : new ArrayList<Color>();
        for (int idx : match.getAtoms()) {
            if (!"H".equals(coverage.getMolecule(true).getAtom(idx).getSymbol()))
                ac.setColor(mol.getAtom(idx), colors.get(i));
        }
        matchesColor.add(colors.get(i));
        coverageColors.put(res, matchesColor);
        i++;
    }
    this.createPNG(mol, outfile);
    ac.resetColors();
    return coverageColors;
}
Also used : IMolecule(org.openscience.cdk.interfaces.IMolecule) Residue(model.Residue) Color(java.awt.Color) AtomColorer(io.imgs.coloration.ColoredAtomGenerator.AtomColorer) Match(algorithms.utils.Match)

Aggregations

Match (algorithms.utils.Match)1 AtomColorer (io.imgs.coloration.ColoredAtomGenerator.AtomColorer)1 Color (java.awt.Color)1 Residue (model.Residue)1 IMolecule (org.openscience.cdk.interfaces.IMolecule)1