Skip to content

Commit

Permalink
fixed an issue with missing bonds
Browse files Browse the repository at this point in the history
  • Loading branch information
thsa committed Dec 4, 2024
1 parent 86c04bb commit 525205a
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 247 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/actelion/research/chem/Molecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3607,7 +3607,7 @@ public void setAtomCustomLabel(int atom, String label) {
label = null;
else {
int atomicNo = getAtomicNoFromLabel(label);
if ((atomicNo != 0 && label.equals(cAtomLabel[atomicNo]))
if ((atomicNo != 0 && atomicNo == mAtomicNo[atom])
|| label.equals("?")) {
setAtomicNo(atom, atomicNo);
label = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Copyright (c) 1997 - 2016
* Actelion Pharmaceuticals Ltd.
* Gewerbestrasse 16
* CH-4123 Allschwil, Switzerland
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Modest v. Korff, Thomas Sander
*/

package com.actelion.research.chem.io.pdb.converter;

import com.actelion.research.chem.*;
import com.actelion.research.chem.io.pdb.parser.AtomRecord;

import java.util.*;

public class AminoAcids {
private static final String[][] AA_TEMPLATES = {
{ "gGX`BDdwMULPGzILwXM[jD", "Alanine", "ala" },
{ "dctd@BE]ADf{UYjjihp`GzBfMvCS]Plw^OMtbK]hrwUj}tRfwnbXp", "Arginine", "arg" },
{ "diEL@BDDyInvZjZL`OtiL[lFfzaYn|^{iFLO]Hi`", "Asparagine", "asn" },
{ "diFB@BANEInvZjZLHA~eIc]`twTKMwcw]Hqa{iEL", "Aspartic Acid", "asp" },
{ "gNxhMV@aI[jihj@?SHF{ac]PinpP", "Cysteine", "Cys" },
{ "defB@BAAeInufjihr@?QdqnpZ[jEf{qyndQ{mFMO]hi`","Glutamic Acid", "glu" },
{ "deeL@BdDEInufjihp`GzLfMvCS]Plw^OMtbO]hqi{mEL", "Glutamine", "gln" },
{ "gJX`BDdvu@OtbYnpP", "Glycine", "gly" },
{ "dmwD@ByPQInvVUZjejL`OtyL[lFfzaYn|^{iFLO]Hii{mFLo]hi`", "Histidine", "his" },
{ "diFD@BADf{ejjdrU@_iRXwXMMuBw]xqn{oELO]Hq`", "Isoleucine", "ile" },
{ "diFD@BADf{Yjjhr@?RdqnpZ[jEf{q{ndTp}tcF@", "Leucine", "leu" },
{ "deeD@BdDR[mUjjjL`OtYL[lFfzaYn|^[iDV{QenkP", "Lysine", "lys" },
{ "diFD`JxPBDivzjihI@?RdAndX[oEF{QqnhR[lD", "Methionine", "met" },
{ "dcND@BADf{YU]Zj@@cHC}ASF{AinhV[oGnzQSCwRLZ^{QSKwZL[Vzm@", "Phenylalanine", "phe" },
{ "daFD@BADfyVyjjhr@?PdqnpZ[jEfzQyn|P", "Proline", "pro" },
{ "gNy`BDtf{ZjfHC}Lf[lFmuBv{q@", "Serine", "ser" },
{ "dazL@BAFR[nZjdrT`_hRXwXMMuBw]xqn{oEL", "Threonine", "thr" },
{ "foAP`@BZ@aInvYWejsfjiB@bFB@OttfF{AhwTKF{qywRJXW]Hqi]vbfUwZN[W]hqc]uZfmwUnYw]Di`", "Tryptophane", "trp" },
{ "dknL@BACR[me]]Zj@BHr@?RTqnpZ[jEf{q{ndTp}tcFgntTr}vcFunkS[hd", "Tyrosine", "tyr" },
{ "dazD@BADf{fjjL`OtIL[lFfza[n|Tw]wcF@", "Valine", "val" }
};

private static TreeMap<String,StereoMolecule> sShortLabelMap;

public static StereoMolecule getStructure(String label) {
return ensureAAMap().get(label.toLowerCase());
}

public static Molecule3D createResidue(String label, List<AtomRecord> atomRecordList) {
StereoMolecule mol = getStructure(label);
if (mol != null) {
Molecule3D aminoAcid = new Molecule3D(mol);
Map<String,AtomRecord> recordMap = new HashMap<>();
for(AtomRecord record : atomRecordList)
recordMap.put(record.getAtomName(), record);

for (int atom=0; atom<aminoAcid.getAllAtoms(); atom++) {
String atomName = mol.getAtomLabel(atom);
String customLabel = mol.getAtomCustomLabel(atom);
if (customLabel != null && customLabel.startsWith("]"))
atomName = atomName.concat(customLabel.substring(1));

AtomRecord record = recordMap.get(atomName);
if (record != null) {
Coordinates coords3d = new Coordinates(record.getX(), record.getY(), record.getZ());
aminoAcid.setAtomName(atom, record.getAtomName());
aminoAcid.setAtomAmino(atom, record.getResName());
aminoAcid.setAtomSequence(atom, record.getSerialId());
aminoAcid.setResSequence(atom, record.getResNum());
aminoAcid.setAtomAmino(atom, record.getResName());
aminoAcid.setAtomChainId(atom, record.getChainID());
aminoAcid.setAtomX(atom, coords3d.x);
aminoAcid.setAtomY(atom, coords3d.y);
aminoAcid.setAtomZ(atom, coords3d.z);
}
};

for (int atom=0; atom<aminoAcid.getAllAtoms(); atom++)
if (aminoAcid.getAtomName(atom) == null)
aminoAcid.markAtomForDeletion(atom);
aminoAcid.deleteMarkedAtomsAndBonds();

return aminoAcid;
}
return null;
}

private static TreeMap<String,StereoMolecule> ensureAAMap() {
if (sShortLabelMap == null) {
sShortLabelMap = new TreeMap<>();
for (String[] template : AA_TEMPLATES) {
StereoMolecule mol = new IDCodeParserWithoutCoordinateInvention().getCompactMolecule(template[0]);
mol.setName(template[1]);
sShortLabelMap.put(template[2], mol);
}
}
return sShortLabelMap;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@

public class ProteinSynthesizer {

private Molecule3D protein;
private int terminalC=-1;

public ProteinSynthesizer() {
}

private Molecule3D mProtein;
private int mTerminalC =-1;

/**
* an amino acid is added to the protein structure and a peptide coupling is performed,
Expand All @@ -27,42 +23,40 @@ public boolean addResidue(Molecule3D residue) {
newTerminalN = atom;
if(residue.getAtomicNo(atom)==6 && residue.getAtomCustomLabel(atom)==null)
newTerminalC = atom;

}
if(protein==null) { // first residue
protein = residue;
terminalC = newTerminalC;
if(mProtein ==null) { // first residue
mProtein = residue;
mTerminalC = newTerminalC;
coupled = true;
}
else if(newTerminalN>-1 && terminalC>-1) { //coupling should be performed
Coordinates coordsC = protein.getCoordinates(terminalC);
else if(newTerminalN>-1 && mTerminalC >-1) { //coupling should be performed
Coordinates coordsC = mProtein.getCoordinates(mTerminalC);
Coordinates coordsN = residue.getCoordinates(newTerminalN);
if(coordsC.distanceSquared(coordsN)<Residue.BOND_CUTOFF_SQ) {
boolean notFound = true;
for(int i=0;i<protein.getConnAtoms(terminalC) && notFound;i++) {
int a = protein.getConnAtom(terminalC, i);
int b = protein.getBond(terminalC, a);
if(protein.getAtomicNo(a)==8 && protein.getBondOrder(b)==1) {
for(int i = 0; i< mProtein.getConnAtoms(mTerminalC) && notFound; i++) {
int a = mProtein.getConnAtom(mTerminalC, i);
int b = mProtein.getBond(mTerminalC, a);
if(mProtein.getAtomicNo(a)==8 && mProtein.getBondOrder(b)==1) {
notFound=false;
toDelete = protein.getConnAtom(terminalC, i);
toDelete = mProtein.getConnAtom(mTerminalC, i);
}
}

if(toDelete>=0) {
protein.deleteAtom(toDelete);
int[] atomMap = protein.addMolecule(residue);
protein.addBond(terminalC, atomMap[newTerminalN], 1);
terminalC = protein.getAllAtoms()-(residue.getAllAtoms()-newTerminalC);
mProtein.deleteAtom(toDelete);
int[] atomMap = mProtein.addMolecule(residue);
mProtein.addBond(mTerminalC, atomMap[newTerminalN], 1);
mTerminalC = mProtein.getAllAtoms()-(residue.getAllAtoms()-newTerminalC);
coupled = true;
}
}
}
protein.ensureHelperArrays(Molecule.cHelperNeighbours);
mProtein.ensureHelperArrays(Molecule.cHelperNeighbours);
return coupled;
}

public Molecule3D retrieveProtein() {
return protein;
public Molecule3D getProtein() {
return mProtein;
}

}
Loading

0 comments on commit 525205a

Please sign in to comment.