20package denoptim.graph;
22import java.util.HashMap;
23import java.util.LinkedHashMap;
26import java.util.regex.Pattern;
28import javax.vecmath.Point3d;
30import org.openscience.cdk.interfaces.IAtom;
32import denoptim.constants.DENOPTIMConstants;
33import denoptim.exception.DENOPTIMException;
34import denoptim.graph.Edge.BondType;
35import denoptim.utils.GeneralUtils;
109 this(
owner, -1,
null,
null);
183 this.atomPositionNumber = atomPosNum;
205 this.atomPositionNumber = (int) features[0];
206 this.apClass = (
APClass) features[1];
207 this.dirVec = (Point3d) features[2];
224 Object[] features =
new Object[3];
227 String[] parts = str.split(
231 features[0] = Integer.parseInt(parts[0])-1;
233 String[] details = parts[1].split(
235 switch (details.length)
240 features[1] =
APClass.
make(details[0],Integer.parseInt(
249 features[1] =
APClass.
make(details[0],Integer.parseInt(
252 String[] coord = details[2].split(
254 switch (coord.length)
258 features[1] =
APClass.
make(details[0],Integer.parseInt(
259 details[1]),
BondType.valueOf(details[2]));
264 features[1] =
APClass.
make(details[0],Integer.parseInt(
266 features[2] =
new Point3d(
267 Double.parseDouble(coord[0]),
268 Double.parseDouble(coord[1]),
269 Double.parseDouble(coord[2]));
279 Integer.parseInt(details[1]),
282 String[] coord = details[3].split(
285 if (coord.length == 3)
287 features[2] =
new Point3d(Double.parseDouble(coord[0]),
288 Double.parseDouble(coord[1]),
289 Double.parseDouble(coord[2]));
296 +
"subclass, and coordinates");
298 }
catch (Throwable t) {
528 if (apProjOnTemplateSurface !=
null)
532 throw new IllegalStateException(
"Available AP inside a"
533 +
"template should have a projection on the "
534 +
"surface of the template, "
535 +
"but it has none. "
536 +
"Please, report this to the authors.");
569 return Integer.compare(this.
getID(), other.
getID());
583 final int BEFORE = -1;
614 if (thisVec.x < otherVec.x)
617 }
else if (thisVec.x > otherVec.x)
620 if (thisVec.y < otherVec.y)
624 }
else if (thisVec.y > otherVec.y)
627 if (thisVec.z < otherVec.z)
630 }
else if (thisVec.z > otherVec.z)
649 System.err.println(
"DENOPTIMAttachmentPoint.comparePropertiesTo "
650 +
"inconsistent with sameAs. Please report this bug.");
666 return sameAs(other,
new StringBuilder());
684 reason.append(
"Different source atom for APs ("
692 reason.append(
"Different index on list of APs ("
702 reason.append(
"Different APClass ("
757 if (!(key instanceof String) || !(value instanceof String))
759 throw new IllegalArgumentException(
"Unable to clone "
761 +
"property of attachment point (key: '" + key
762 +
"'). Implement deep cloning of property "
765 String keyStr = ((String) key) +
"";
766 String valueStr = ((String) value) +
"";
791 StringBuilder sb =
new StringBuilder();
814 return sb.toString();
843 Map<String,Object> pars =
new HashMap<String,Object>();
851 pars.put(
"dirVec.x",
dirVec.x);
852 pars.put(
"dirVec.y",
dirVec.y);
853 pars.put(
"dirVec.z",
dirVec.z);
856 return pars.toString();
869 Map<String,Object> pars =
new HashMap<String,Object>();
878 pars.put(
"dirVec.x",
dirVec.x);
879 pars.put(
"dirVec.y",
dirVec.y);
880 pars.put(
"dirVec.z",
dirVec.z);
883 return pars.toString();
1103 IAtom srcThis = ((
Fragment) deepOwnerT).getAtomHoldingAP(
1105 IAtom srcOther = ((
Fragment) deepOwnerO).getAtomHoldingAP(
1108 if (srcThis == srcOther)
1138 IAtom srcThis = ((
Fragment) deepOwnerT).getAtomHoldingAP(
1140 IAtom srcOther = ((
Fragment) deepOwnerO).getAtomHoldingAP(
1143 if (srcThis.getContainer() == srcOther.getContainer())
1145 if (srcThis.getContainer().getConnectedAtomsList(srcThis)
1146 .contains(srcOther))
1153 List<AttachmentPoint> apsOnSrcThis =
1154 ((
Fragment)deepOwnerT).getAPsFromAtom(srcThis);
1155 List<AttachmentPoint> apsOnSrcOther =
1156 ((
Fragment)deepOwnerT).getAPsFromAtom(srcOther);
1160 if (apOnSrcThis.isAvailableThroughout()
1161 || apOnSrcThis==deepThis)
1168 if (apOnSrcOther.isAvailableThroughout()
1169 || apOnSrcOther==deepOther)
1171 if (linkedAP==apOnSrcOther)
1236 LinkedHashMap<Integer, List<AttachmentPoint>> apsPerIndex)
1239 for (Integer ii : apsPerIndex.keySet())
1245 List<AttachmentPoint> apsOnAtm = apsPerIndex.get(ii);
1247 boolean firstCL =
true;
1248 for (
int i = 0; i<apsOnAtm.size(); i++)
1253 String stingAPP =
"";
1259 stingAPP = DENOPTIMConstants.SEPARATORAPPROPAPS
General set of constants used in DENOPTIM.
static final String SEPARATORAPPROPAAP
Separator between atom index and APClass in molecular property.
static final String SEPARATORAPPROPATMS
Separator between APs on different atoms in molecular property.
static final String SEPARATORAPPROPSCL
Separator between APClass and APSubClass and coordinates.
static final String SEPARATORAPPROPXYZ
Separator between coordinates.
APClass clone()
WARNING: this method does NOT clone! It just returns the reference to this.
static final BondType DEFAULTBT
Default bond type for all but APClasses of RCVs.
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
AttachmentPoint getLinkedAP()
Gets the attachment point (AP) that is connected to this AP via the edge user.
AttachmentPoint(Vertex owner)
Constructor for undefined DENOPTIMAttachmentPoint.
Map< Object, Object > properties
Map of customisable properties.
Object getProperty(Object description)
AttachmentPoint getEmbeddedAP()
For vertices that are templates this method returns the attachment point that is embedded in the temp...
void setAPClass(String apClass)
Set the Attachment Point class.
AttachmentPoint(Vertex owner, int atomPositionNumber)
Constructor.
Point3d dirVec
The direction vector representing the bond direction.
void setUser(Edge edge)
Sets the reference to the edge that is using this attachment point.
int comparePropertiesTo(AttachmentPoint other)
Compares this and given attachment point.
Vertex owner
The vertex to which this AP is attached to.
APClass getAPClass()
Returns the Attachment Point class.
Edge user
The edge that is using this AP, if any.
String toString()
Produces a string with the information included in this object.
int atomPositionNumber
The index of the source atom in the atom list of the fragment (0-based)
int cutId
Identifier of the cut operation that generated this AP.
boolean isClassEnabled()
Checks if this attachment point respects the APClass-based approach.
AttachmentPoint(Vertex owner, int atomPosNum, APClass apClass)
Constructor.
void setAtomPositionNumber(int atomPositionNumber)
Set the index of the source atom in the list of atoms of the fragment.
AttachmentPoint(Vertex owner, String str)
Construct an attachment point based on the formatted string representation.
void setDirectionVector(Point3d dirVec)
Sets the end of the 3D vector defining the direction of the AP in 3D.
int getID()
Returns a unique integer that is used to sort list of attachment points.
APClass apClass
The attachment point class.
void setOwner(Vertex owner)
Sets the reference to the vertex that owns this attachment point.
BondType getBondType()
Returns the bond type preferred by this attachment point as defined by the APClass,...
boolean isAvailable()
Check availability of this attachment point.
AttachmentPoint(Vertex owner, int atomPosNum, Point3d dirVec, APClass apClass)
Constructor.
int getAtomPositionNumberInMol()
The index of the source atom in the atom list of the entire molecule.
int getAtomPositionNumber()
The index of the source atom in the atom list of the fragment.
boolean isSrcInUserThroughout()
Checks the role of this AP in the user or in any user that might be external to the template embeddin...
static Object[] processSdfString(String str)
Parses the string format used to record one attachment point in SDF files.
void setAtomPositionNumberInMol(int atomPositionNumberInMol)
Set the index of the source atom in the list of atoms of the entire molecule.
int id
Index used to keep the order in a list of attachment points.
AttachmentPoint clone()
Returns a deep clone of this attachment point.
void setAPClass(APClass apClass)
Set the Attachment Point class.
void setID(int id)
Sets the unique integer that is used to sort list of attachment points.
boolean isAvailableThroughout()
Check availability of this attachment point throughout the graph level, i.e., check also across the i...
Point3d getDirectionVector()
Returns the end of the direction vector.
Edge getEdgeUserThroughout()
Gets the edge that is using this AP, or null if no edge is using this AP.
boolean hasConnectedSrcAtom(AttachmentPoint other)
Checks if this and another APs are rooted on atoms that are bonded in any way other than a possible c...
Map< Object, Object > getProperties()
boolean isSrcInUser()
Checks the role of this AP in the user.
boolean sameAs(AttachmentPoint other)
Compares the features of this and another attachment point and decides if the two are same.
AttachmentPoint(Vertex owner, int atomPositionNumber, Point3d dirVec)
Constructor.
boolean hasSameSrcAtom(AttachmentPoint other)
String getSingleAPStringSDF(boolean isFirst)
Prepare a string for writing this AP in a fragment SDF file.
static String getAPDefinitionsForSDF(LinkedHashMap< Integer, List< AttachmentPoint > > apsPerIndex)
Prepares the two strings that can be used to define AttachmentPoints in SDF files.
int atomPositionNumberInMol
The index of the source atom in the atom list of the entire molecule (0-based)
AttachmentPoint getLinkedAPThroughout()
Gets the attachment point (AP) that is connected to this AP via the edge user or in any edge user tha...
String getSingleAPStringSDF(boolean isFirst, int srcAtmID)
Prepare a string for writing this AP in a fragment SDF file.
int compareTo(AttachmentPoint other)
Compares this and another attachment points based on their unique identifier.
void setProperty(Object key, Object property)
Edge getEdgeUser()
Gets the edge that is using this AP, or null if no edge is using this AP.
String toStringNoId()
Produces a string with the information included in this object.
boolean sameAs(AttachmentPoint other, StringBuilder reason)
Compares the features of this and another attachment point and decides if the two are same.
Template templateJacket
Reference to the Template embedding this graph.
This class represents the edge between two vertices.
AttachmentPoint getSrcAPThroughout()
AttachmentPoint getTrgAP()
AttachmentPoint getSrcAP()
AttachmentPoint getTrgAPThroughout()
An empty vertex has the behaviors of a vertex, but has no molecular structure.
Class representing a continuously connected portion of chemical object holding attachment points.
AttachmentPoint getOuterAPFromInnerAP(AttachmentPoint innerAP)
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
int getIndexOfAP(AttachmentPoint ap)
Returns the position of the given AP in the list of APs of this vertex.
DGraph getGraphOwner()
Returns the graph this vertex belongs to or null.
static String getEnglishFormattedDecimal(String pattern, int decimals, double value)
Formats a decimal number using the given pattern but with English format as for separators.
Possible chemical bond types an edge can represent.