-
Notifications
You must be signed in to change notification settings - Fork 2
Scaffold‐graph‐vis basic usage
All functionality of this library can be found in the de.unijena.cheminf.scaffolds.GraphStreamUtility.java class. There are static methods for generating a GraphStream Graph object out of cdk-scaffold ScaffoldTree and ScaffoldNetwork objects, displaying these scaffold graphs in an application window, and generating images of the scaffold hierarchies.
Usage example:
Imports four molecules from SMILES strings, generates a Schuffenhauer tree of these molecules, displays the resulting tree with GraphStream, and screenshots it.
SmilesParser tmpParser = new SmilesParser(SilentChemObjectBuilder.getInstance());
ScaffoldGenerator tmpScaffoldGenerator = new ScaffoldGenerator();
IAtomContainer tmpMolecule = tmpParser.parseSmiles("C1CCC2C(C1)C3=CN=CN=C3S2"); //PubChem CID 141755869
IAtomContainer tmpMolecule1 = tmpParser.parseSmiles("C1CC2=C(C1)SC3=C2C(=NC=N3)Cl"); //PubChem CID 789817
IAtomContainer tmpMolecule2 = tmpParser.parseSmiles("CC1=C(SC=[N+]1CC2=CN=C(N=C2N)C)CCO.[Cl-]"); //PubChem CID 6042, Thiamine
IAtomContainer tmpMolecule3 = tmpParser.parseSmiles("COCCOC1=C(C=C2C(=C1)C(=NC=N2)NC3=CC=CC(=C3)C#C)OCCOC"); //PubChem CID 176870, Erlotinib
List tmpMoleculeList = new ArrayList<>();
tmpMoleculeList.add(tmpMolecule);
tmpMoleculeList.add(tmpMolecule1);
tmpMoleculeList.add(tmpMolecule2);
tmpMoleculeList.add(tmpMolecule3);
List tmpScaffoldTreeList = tmpScaffoldGenerator.generateSchuffenhauerForest(tmpMoleculeList);
//shortcut would be:
//GraphStreamUtility.displayWithGraphStream(tmpScaffoldTreeList.get(0));
//alternative with more options:
Graph tmpGraph = new SingleGraph("Pyrimidine-Scaffold-Tree");
GraphStreamUtility.generateGraphFromScaffoldNodeCollection(tmpScaffoldTreeList.get(0),
GraphStreamUtility.DEFAULT_ARE_NODES_LABELLED,
GraphStreamUtility.DEFAULT_CDK_DEPICTION_GENERATOR,
GraphStreamUtility.DEFAULT_GRAPH_STYLE_SHEET,
tmpGraph);
System.setProperty("org.graphstream.ui", GraphStreamUtility.DEFAULT_GRAPHSTREAM_UI);
tmpGraph.display();
//screenshot the graph in both ways available
GraphStreamUtility.screenshotGraph(tmpGraph, GraphStreamUtility.getGraphStreamDisplayFolder().getAbsolutePath() + File.separatorChar +
"Pyrimidine_ScaffoldTree_low.png");
GraphStreamUtility.screenshotGraphHighQuality(tmpGraph, GraphStreamUtility.getGraphStreamDisplayFolder().getAbsolutePath() + File.separatorChar +
"Pyrimidine_ScaffoldTree.png");
The application window display will look like this:
The low resolution screenshot file will look like this:

And the high resolution screenshot file will look like this:

PLEASE NOTE that it is better to execute the three functionalities (display, low res screenshot, and high res screenshot) SEPARATELY because GraphStream can have issues when running these things in parallel.