User dfeb81947d
		11-09-2012 15:23:50
	 
	
	
	Dear Support,
Using Jchem API how can I get the stochiometry of a fragment (salt or solvant) which is contained in JChem API's Molecule object?
I didn't find a method that access this property. For now I'm expanding fragments using Standardizer and counting all same frags, but since I found a way to draw it in Marvin Sketch (C F) I thought there should be an accessor for this data?
Please see attached file for an example
 
Thank you very much for your help.
Warm regards,
Jacques
	
	 
 
	
		ChemAxon a3d59b832c
		11-09-2012 15:55:57
	 
	
	
	Hi Jacques,
I have moved your question to the Structure representation forum. My colleagues will answer soon.
Best regards,
Szabolcs
	
	 
 
	
		ChemAxon 25dcd765a3
		12-09-2012 12:49:49
	 
	
	
	Hi Jacques,
How did you generate this file?
What I see is that you have a Data Sgroup which name "C F" and value 3. If I were you I would use "stoichiometry" as a name. This "C   F" is just strange fro me.
Anyway, you can get this data value with the following calls:
public static void main(String[] args) throws IOException {
    MolImporter mi = new MolImporter("salt_with_stoichiometry_example.mol");
    Molecule mol = mi.read();
    mi.close();
    DataSgroup[] dataSg = getDataSgroups(mol, "C    F");
    for (DataSgroup data : dataSg){
        int stoichometry = Integer.parseInt(data.getData());
        System.out.println(stoichometry);
    }
}
static DataSgroup[] getDataSgroups(Molecule mol, String name){
    Sgroup[] sg = mol.getSgroupArray();
    ArrayList<DataSgroup> datasgroups = new ArrayList<DataSgroup>();
    for (Sgroup sgroup : sg) {
        if (sgroup instanceof DataSgroup){
        DataSgroup dsg = (DataSgroup) sgroup;
        if (name.equals(dsg.getFieldName())){
            datasgroups.add(dsg);
        }
        }
    }
    DataSgroup[] datasgreturn = new DataSgroup[datasgroups.size()];
    return datasgroups.toArray(datasgreturn);
} 
I hope this helps
	
	 
 
	
		User dfeb81947d
		13-09-2012 08:49:27
	 
	
	
	Dear volfi,
 
Thank you very much, I got that file from an sdf that was given to me for analysis. I opened it with Marvin and export the structure to mofile. Actually the original molfile in SDFile is the same with the export.
I also think that this SGroup should be renamed "stoichiometry", but I don't have access to that field.
 
Thank you very much for the method, that is exactly what I was looking for.
 
Thank you so far
 
Kind Regards,
Jacques
	
	 
 
	
		ChemAxon d26931946c
		19-09-2012 10:54:25
	 
	
	
	Dear Jacques,
Please see my answer here.
 
Regards, 
Peter
	
	 
 
	
		User dfeb81947d
		19-09-2012 12:22:10
	 
	
	
	Thank you very much, I thought I deleted this post to create a new one more precise, with example and more details.
But thank you very much it answers my questions.
Kind regards
Jacques