com.actelion.research.chem.conf.ConformerSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
package com.actelion.research.chem.conf;
import com.actelion.research.chem.Canonizer;
import com.actelion.research.chem.IDCodeParserWithoutCoordinateInvention;
import com.actelion.research.chem.StereoMolecule;
import java.util.Iterator;
import java.util.TreeSet;
public class ConformerSet extends TreeSet {
public ConformerSet() {
this(null);
}
public ConformerSet(String s) {
super();
if (s != null) {
String[] confString = s.split(" ");
if (confString.length >= 2) {
IDCodeParserWithoutCoordinateInvention parser = new IDCodeParserWithoutCoordinateInvention();
StereoMolecule mol = parser.getCompactMolecule(confString[0], confString[1]);
Conformer firstConformer = new Conformer(mol);
add(firstConformer);
for(int i=2; itreeSet.add(c));
return treeSet;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (!isEmpty()) {
Iterator iterator = iterator();
StereoMolecule mol = iterator.next().toMolecule();
Canonizer can = new Canonizer(mol, Canonizer.COORDS_ARE_3D);
sb.append(can.getIDCode());
sb.append(" ");
sb.append(can.getEncodedCoordinates(true));
while (iterator.hasNext()) {
can.invalidateCoordinates();
iterator.next().toMolecule(mol);
sb.append(" ");
sb.append(can.getEncodedCoordinates(true));
}
}
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy