$darkmode
DENOPTIM
RingClosingAttractor.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.graph.rings;
20
21import java.util.HashMap;
22import java.util.HashSet;
23import java.util.Map;
24import java.util.Set;
25
26import org.openscience.cdk.interfaces.IAtom;
27import org.openscience.cdk.interfaces.IAtomContainer;
28
29import denoptim.constants.DENOPTIMConstants;
30import denoptim.graph.APClass;
31import denoptim.graph.Edge.BondType;
32import denoptim.graph.Ring;
33import denoptim.utils.MoleculeUtils;
34
35
46//TODO: consider making subclass of Vertex?
47
49{
53 final Map<String,Double> paramAR11 = new HashMap<String,Double>() {
57 private static final long serialVersionUID = 1L;
58
59 {
60 put("ATP", 1.0);
61 put("ATM", 1.0);
62 put("ATN", 1.0);
63 };
64 };
65
69 final Map<String,Double> paramBR11 = new HashMap<String,Double>() {
73 private static final long serialVersionUID = 1L;
74 {
75 put("ATP", 1.0);
76 put("ATM", 1.0);
77 put("ATN", 1.0);
78 };
79 };
80
84 final Map<String,Double> paramAR12 = new HashMap<String,Double>() {
88 private static final long serialVersionUID = 1L;
89 {
90 put("ATP", 5.0);
91 put("ATM", 5.0);
92 put("ATN", 5.0);
93 };
94 };
95
99 final Map<String,Double> paramBR12 = new HashMap<String,Double>() {
103 private static final long serialVersionUID = 1L;
104 {
105 put("ATP", 7.0);
106 put("ATM", 7.0);
107 put("ATN", 7.0);
108 };
109 };
110
114 private Double attA11 = 0.0;
115
119 private Double attB11 = 0.0;
120
124 private Double attA12 = 0.0;
125
129 private Double attB12 = 0.0;
130
134 private String attType = "none";
135
139 private IAtom atm;
140
144 private IAtom src;
145
150
156
162 private Ring ringUser;
163
167 private boolean used = false;
168
172 public static final HashMap<APClass,String> RCALABELPERAPCLASS =
173 new HashMap<APClass,String>(){
177 private static final long serialVersionUID = 1L;
178
179 {
180 try {
181 put(APClass.RCACLASSPLUS, "ATP");
182 put(APClass.RCACLASSMINUS, "ATM");
183 put(APClass.RCACLASSNEUTRAL, "ATN");
184 } catch (Throwable t)
185 {
186 //Will not happen
187 }
188 }};
189
193 public static final Set<APClass> RCAAPCLASSSET =
194 new HashSet<APClass>(){
198 private static final long serialVersionUID = 1L;
199
200 {
204 }};
205
212 public static final Map<APClass,APClass> RCAAPCMAP =
213 new HashMap<APClass,APClass>()
214 {
218 private static final long serialVersionUID = 3L;
219
220 {
224 };
225 };
226
233 public static final Map<String,String> RCATYPEMAP =
234 new HashMap<String,String>()
235 {
239 private static final long serialVersionUID = 3L;
240
241 {
248 };
249 };
250
251
252//-----------------------------------------------------------------------------
253
259 {
260 this.atm = null;
261 }
262
263//-----------------------------------------------------------------------------
264
279 public RingClosingAttractor(IAtom atm, IAtomContainer mol)
280 {
281 this.atm = atm;
282 for (String atyp : RingClosingAttractor.RCATYPEMAP.keySet())
283 {
284 if (MoleculeUtils.getSymbolOrLabel(atm).equals(atyp))
285 {
286 this.attType = atyp;
287 this.attA11 = paramAR11.get(atyp);
288 this.attA12 = paramAR12.get(atyp);
289 this.attB11 = paramBR11.get(atyp);
290 this.attB12 = paramBR12.get(atyp);
291 break;
292 }
293 }
294 // We can try to build RCAs from any atom, but only those atoms that
295 // really are RCAs do have the information we are extracting here
296 if (isAttractor())
297 {
298 //Well, any atom might have neighbors, but RCA only have 1. So
299 // the assumption is valid for RCAs.
300 this.src = mol.getConnectedAtomsList(atm).get(0);
301 // But, there are properties that can be found only in relation to
302 // actual RCAs (whether used to make a ring, or not)
303 this.apClass = (APClass) atm.getProperty(
305 this.bndTyp = (BondType) atm.getProperty(
307 this.ringUser = (Ring) atm.getProperty(
309 }
310 }
311
312//-----------------------------------------------------------------------------
313
320 public boolean isAttractor()
321 {
322 return (this.attType.equals("none")) ? false : true;
323 }
324
325//-----------------------------------------------------------------------------
326
333 public boolean isCompatible(RingClosingAttractor other)
334 {
335 return RingClosingAttractor.RCATYPEMAP.get(this.attType).equals(
336 other.attType);
337 }
338
339//-----------------------------------------------------------------------------
340
346 public String getType()
347 {
348 return attType;
349 }
350
351//-----------------------------------------------------------------------------
352
359 public IAtom getIAtom()
360 {
361 return atm;
362 }
363
364//-----------------------------------------------------------------------------
365
371 public void setIAtom(IAtom atm)
372 {
373 this.atm = atm;
374 }
375
376//-----------------------------------------------------------------------------
377
384 public IAtom getSrcAtom()
385 {
386 return src;
387 }
388
389//-----------------------------------------------------------------------------
390
398 {
399 return apClass;
400 }
401
402 //-----------------------------------------------------------------------------
403
410 {
411 return bndTyp;
412 }
413
414 //-----------------------------------------------------------------------------
415
423 {
424 return ringUser;
425 }
426
427//-----------------------------------------------------------------------------
428
434 public void setUsed()
435 {
436 this.used = true;
437 }
438
439//-----------------------------------------------------------------------------
440
447 public boolean isUsed()
448 {
449 return used;
450 }
451
452//-----------------------------------------------------------------------------
453
459 public Double getParamA11()
460 {
461 return attA11;
462 }
463
464//-----------------------------------------------------------------------------
465
471 public Double getParamB11()
472 {
473 return attB11;
474 }
475
476//-----------------------------------------------------------------------------
477
483 public Double getParamA12()
484 {
485 return attA12;
486 }
487
488//-----------------------------------------------------------------------------
489
495 public Double getParamB12()
496 {
497 return attB12;
498 }
499
500//-----------------------------------------------------------------------------
501
506 @Override public String toString()
507 {
508 String s = "RingClosingAttractor (Type:" + this.attType + " "
509 + "APClass:" + this.apClass + " "
510 + "Used:" + this.used + " "
511 + "Atm: " + MoleculeUtils.getSymbolOrLabel(this.atm)
512 + " SrcAtm: " + MoleculeUtils.getSymbolOrLabel(this.src)
513 + ")";
514 return s;
515 }
516
517//-----------------------------------------------------------------------------
518}
General set of constants used in DENOPTIM.
static final Object RCAPROPRINGUSER
Property of a IAtom representing a RingClosingAttractor.
static final Object RCAPROPCHORDBNDTYP
Property of a IAtom representing a RingClosingAttractor.
static final Object RCAPROPAPCTORCA
Property of a IAtom representing a RingClosingAttractor.
static final APClass RCACLASSPLUS
Conventional class of attachment points on ring-closing vertexes.
Definition: APClass.java:84
static final APClass RCACLASSMINUS
Conventional class of attachment points on ring-closing vertexes.
Definition: APClass.java:91
static final APClass RCACLASSNEUTRAL
Conventional class of attachment points on ring-closing vertexes.
Definition: APClass.java:98
This class represents the closure of a ring in a spanning tree.
Definition: Ring.java:40
The RingClosingAttractor represent the available valence/connection that allows to close a ring.
Double attB12
Parameter B for 1,2 interaction.
Ring getRingUser()
Get the reference to the graph representation of the ring this attractor is meant to close.
boolean isAttractor()
Checks whether the constructed RingClosingAttractor does corresponds to a RingClosingAttractor in the...
IAtom atm
Pseudo atom representing RingClosingAttractor in molecule.
static final HashMap< APClass, String > RCALABELPERAPCLASS
Conventional labels for attractor pseudoatom.
final Map< String, Double > paramAR12
Parameter A for points in 1,2 relationship.
boolean used
Flag: this RingClosingAttractor is used to close a ring.
static final Set< APClass > RCAAPCLASSSET
Recognized APClass for RingClosingAttractor.
IAtom getSrcAtom()
Get the atom in the parent fragment that holds the attachment point occupied by this RingClosingAttra...
boolean isCompatible(RingClosingAttractor other)
Evaluate compatibility between this RingClosingAttractor and another one.
final Map< String, Double > paramBR12
Parameter B for points in 1,2 relationship.
String getType()
Get the type of RingClosingAttractor.
void setIAtom(IAtom atm)
Change the reference to the atom in the molecular representation.
Double attB11
Parameter B for 1,1 interaction.
void setUsed()
Set this RingClosingAttractor to 'used'.
Double attA12
Parameter A for 1,2 interaction.
IAtom getIAtom()
Get the atom corresponding to this RingClosingAttractor in the molecular representation.
static final Map< APClass, APClass > RCAAPCMAP
Recognized APClasses on RingClosingAttractor and compatible types.
Double attA11
Parameter A for 1,1 interaction.
RingClosingAttractor()
Constructor for an empty RingClosingAttractor.
final Map< String, Double > paramAR11
Parameter A for points in 1,1 relationship.
APClass getApClass()
Get the class of the Attachment Point occupied (i.e., in the parent fragment) by this RingClosingAttr...
RingClosingAttractor(IAtom atm, IAtomContainer mol)
Constructor for a RingClosingAttractor corresponding to an atom in an IAtomContainer.
static final Map< String, String > RCATYPEMAP
Recognized types of RingClosingAttractor and compatible types.
BondType bndTyp
Type of ring-closing bond that this ring-closing attractor is there to create.
BondType getRCBondType()
Get the type of bond this attractor is meant to close.
APClass apClass
Class of the Attachment Point represented by this RCA.
IAtom src
Atom hosting the RingClosingAttractor.
Ring ringUser
Reference to the graph Ring that represent the intention to close a ring of vertices in DENOPTIM's gr...
boolean isUsed()
Check if this RingClosingAttractor has been used to close a ring and is not available any more.
final Map< String, Double > paramBR11
Parameter B for points in 1,1 relationship.
Utilities for molecule conversion.
static String getSymbolOrLabel(IAtom atm)
Gets either the elemental symbol (for standard atoms) of the label (for pseudo-atoms).
Possible chemical bond types an edge can represent.
Definition: Edge.java:303