Network Action Set

Inputting a Molecular Graph

This section contains PROC CAS code.

Note: For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.

This example shows how to input a molecular graph by specifying a Simplified Molecular Input Line Entry System (SMILES) string in the readGraph or loadGraph action.

The following statements read in a SMILES string, specify adding hydrogen atoms to the molecular graph, and output the resulting links and nodes data tables. These statements do not run any algorithms, but you can use the resulting output as input data for subsequent network actions.

proc cas;
   loadactionset "network";
   action network.readGraph result=r status=s /
      smiles    = {smilesStr = "Cc1nc(c[nH]1)N(=O)=O", addHydrogens=true}
      outNodes  = {name = "NodeSetOut", replace=true}
      outLinks  = {name = "LinkSetOut", replace=true};
   run;
   print r.ProblemSummary; run;
   action table.fetch / table = "NodeSetOut"; run;
   action table.fetch / table = "LinkSetOut"; run;
quit;

The problem summary output from this action is shown in Output 28.18.1.

Output 28.18.1: Problem Summary

Problem Summary
Number of Nodes14
Number of Links14
Graph DirectionUndirected


The output data table NodeSetOut, shown in Output 28.18.2, now contains the nodes of the molecular graph and the node attributes that are associated with each atom.

Output 28.18.2: Nodes Data Table of a Molecular Graph

Selected Rows from Table NODESETOUT
_Index_nodeweightatomic_numatomic_symbchiral_taghybridizationformal_chargeexplicit_hsaromatic
1012.0116CCHI_UNSPECIFIEDSP3000
2112.0116CCHI_UNSPECIFIEDSP2001
3214.0077NCHI_UNSPECIFIEDSP2001
4312.0116CCHI_UNSPECIFIEDSP2001
5412.0116CCHI_UNSPECIFIEDSP2001
6514.0077NCHI_UNSPECIFIEDSP2001
7614.0077NCHI_UNSPECIFIEDSP2100
8715.9998OCHI_UNSPECIFIEDSP2-100
9815.9998OCHI_UNSPECIFIEDSP2000
1091.0081HCHI_UNSPECIFIEDUNSPECIFIED000
11101.0081HCHI_UNSPECIFIEDUNSPECIFIED000
12111.0081HCHI_UNSPECIFIEDUNSPECIFIED000
13121.0081HCHI_UNSPECIFIEDUNSPECIFIED000
14131.0081HCHI_UNSPECIFIEDUNSPECIFIED000


The output data table LinkSetOut, shown in Output 28.18.3, contains the links of the molecular graph and the link attributes that are associated with each bond.

Output 28.18.3: Links Data Table of a Molecular Graph

Selected Rows from Table LINKSETOUT
_Index_fromtobond_type
101SINGLE
209SINGLE
3010SINGLE
4011SINGLE
512AROMATIC
651AROMATIC
723AROMATIC
834AROMATIC
936SINGLE
1045AROMATIC
11412SINGLE
12513SINGLE
1367SINGLE
1468DOUBLE


The molecular graph, shown in Figure 21, uses conventional colors to differentiate chemical elements and edge styles to differentiate bond types.

Figure 21: Molecular Graph

Molecular Graph


You can also load a molecular graph by using the loadGraph action. The following statements demonstrate an alternative way to specify the molecular graph, by providing a SMILES string itself as input:

proc cas;
   loadactionset "network";
   action network.loadGraph result=rl status=s /
      smiles       = "c1ccccc1"
      outGraphList = {name = "OutGraphList", replace=true};
   run;
   action table.fetch / table = "OutGraphList"; run;
quit;

The graph identifier and several other pieces of summary information about the in-memory graph are now contained in the output data table OutGraphList, as shown in Output 28.18.4.

Output 28.18.4: Summary Information about the In-Memory Molecular Graph

Selected Rows from Table OUTGRAPHLIST
_Index_graphcreateTimeloadeddirectionnodeslinksmultiLinksselfLinksstandardizedLabels
1027FEB2026:14:15:021Undirected66001


Inputting a Molecular Graph

This section contains Lua code for the analysis in the CASL version of this example, which contains details about the results.

For more information about coding in Lua, see Getting Started with SAS Viya for Lua and SAS Viya: System Programming Guide.

The following statements read in a SMILES string, specify adding hydrogen atoms to the molecular graph, and output the resulting links and nodes data tables. These statements do not run any algorithms, but you can use the resulting output as input data for subsequent network actions.

s:network_readGraph{
   smiles    = {smilesStr = "Cc1nc(c[nH]1)N(=O)=O", addHydrogens=true},
   outNodes  = {name = "NodeSetOut", replace=true},
   outLinks  = {name = "LinkSetOut", replace=true}}

You can also specify a SMILES string as input to the loadGraph action as shown in the following statements:

 s:network_loadGraph{
       smiles       = "c1ccccc1",
       outGraphList = {name = "OutGraphList", replace=true}}

Inputting a Molecular Graph

This section contains Python code for the analysis in the CASL version of this example, which contains details about the results.

For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.

The following statements read in a SMILES string, specify adding hydrogen atoms to the molecular graph, and output the resulting links and nodes data tables. These statements do not run any algorithms, but you can use the resulting output as input data for subsequent network actions.

s.network.readGraph(
    smiles    = {smilesStr:"Cc1nc(c[nH]1)N(=O)=O", addHydrogens:True},
    outNodes  = {"name":"NodeSetOut", "replace":True},
    outLinks  = {"name":"LinkSetOut", "replace":True})

You can also specify a SMILES string as input to the loadGraph action as shown in the following statements:

 s.network.loadGraph(
       smiles       = "c1ccccc1",
       outGraphList = {"name":"OutGraphList", "replace":True})

Inputting a Molecular Graph

This example is not available for the R programming language.

Last updated: March 12, 2026