From: <ha...@us...> - 2016-07-24 18:10:51
|
Revision: 21181 http://sourceforge.net/p/jmol/code/21181 Author: hansonr Date: 2016-07-24 18:10:47 +0000 (Sun, 24 Jul 2016) Log Message: ----------- Jmol.___JmolVersion="14.6.1_2016.07.24" bug fix: write x.pdb for multimodel file does not work. Modified Paths: -------------- branches/v14_6/Jmol/src/javajs/awt/Component.java branches/v14_6/Jmol/src/org/jmol/modelset/Text.java branches/v14_6/Jmol/src/org/jmol/viewer/Jmol.properties branches/v14_6/Jmol/src/org/jmol/viewer/PropertyManager.java trunk/Jmol/src/javajs/awt/Component.java trunk/Jmol/src/org/jmol/modelset/Text.java trunk/Jmol/src/org/jmol/util/Edge.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/PropertyManager.java Modified: branches/v14_6/Jmol/src/javajs/awt/Component.java =================================================================== --- branches/v14_6/Jmol/src/javajs/awt/Component.java 2016-07-13 19:52:37 UTC (rev 21180) +++ branches/v14_6/Jmol/src/javajs/awt/Component.java 2016-07-24 18:10:47 UTC (rev 21181) @@ -5,7 +5,7 @@ abstract public class Component { - protected boolean visible; + private boolean _visible; protected boolean enabled = true; protected String text; protected String name; @@ -99,11 +99,11 @@ } public boolean isVisible() { - return visible; + return _visible; } public void setVisible(boolean visible) { - this.visible = visible; + this._visible = visible; /** * @j2sNative * Modified: branches/v14_6/Jmol/src/org/jmol/modelset/Text.java =================================================================== --- branches/v14_6/Jmol/src/org/jmol/modelset/Text.java 2016-07-13 19:52:37 UTC (rev 21180) +++ branches/v14_6/Jmol/src/org/jmol/modelset/Text.java 2016-07-24 18:10:47 UTC (rev 21181) @@ -73,7 +73,6 @@ /** * @param vwr - * @j2sIgnoreSuperConstructor */ private Text(Viewer vwr) { this.vwr = vwr; Modified: branches/v14_6/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- branches/v14_6/Jmol/src/org/jmol/viewer/Jmol.properties 2016-07-13 19:52:37 UTC (rev 21180) +++ branches/v14_6/Jmol/src/org/jmol/viewer/Jmol.properties 2016-07-24 18:10:47 UTC (rev 21181) @@ -7,8 +7,12 @@ # see also http://chemapps.stolaf.edu/jmol/zip for daily updates -Jmol.___JmolVersion="14.6.1_2016.07.11" +Jmol.___JmolVersion="14.6.1_2016.07.24" +bug fix: write x.pdb for multimodel file does not work. + +JmolVersion="14.6.1_2016.07.11" + sychronized with Jmol 14.7 bug fix: Jmol SMILES not allowing for insertion-code search Modified: branches/v14_6/Jmol/src/org/jmol/viewer/PropertyManager.java =================================================================== --- branches/v14_6/Jmol/src/org/jmol/viewer/PropertyManager.java 2016-07-13 19:52:37 UTC (rev 21180) +++ branches/v14_6/Jmol/src/org/jmol/viewer/PropertyManager.java 2016-07-24 18:10:47 UTC (rev 21181) @@ -1946,7 +1946,8 @@ * @return PDB file data string */ @Override - public String getPdbAtomData(BS bs, OC out, boolean isPQR, boolean doTransform, boolean allTrajectories) { + public String getPdbAtomData(BS bs, OC out, boolean isPQR, + boolean doTransform, boolean allTrajectories) { if (vwr.ms.ac == 0 || bs.nextSetBit(0) < 0) return ""; if (out == null) { @@ -1957,9 +1958,6 @@ } Atom[] atoms = vwr.ms.at; Model[] models = vwr.ms.am; - int iModel = atoms[bs.nextSetBit(0)].mi; - int iModelLast = -1; - boolean isBiomodel = false; String occTemp = "%6.2Q%6.2b "; if (isPQR) { occTemp = "%8.4P%7.4V "; @@ -1975,25 +1973,50 @@ "\nREMARK 6 Total charge on this protein: " + charge + " e\nREMARK 6\n"); } - - + + int iModel = atoms[bs.nextSetBit(0)].mi; + int iModelLast = -1; int lastAtomIndex = bs.length() - 1; - boolean showModels = (iModel != atoms[lastAtomIndex].mi); + int lastModelIndex = atoms[lastAtomIndex].mi; + boolean showModels = (iModel != lastModelIndex); + BS bsModels = vwr.ms.getModelBS(bs, true); + int nModels = bsModels.cardinality(); Lst<String> lines = new Lst<String>(); boolean isMultipleBondPDB = models[iModel].isPdbWithMultipleBonds; + boolean uniqueAtomNumbers = false; + if (nModels > 1) { + Object conectArray = null; + for (int nFiles = 0, i = bsModels.nextSetBit(0); i >= 0; i = bsModels + .nextSetBit(i + 1)) { + Object a = vwr.ms.getModelAuxiliaryInfo(i).get("PDB_CONECT_bonds"); + if (a != conectArray || !vwr.ms.am[i].isBioModel) { + conectArray = a; + if (nFiles++ > 0) { + uniqueAtomNumbers = true; + break; + } + } + } + } LabelToken[] tokens; P3 ptTemp = new P3(); Object[] o = new Object[] { ptTemp }; Quat q = (doTransform ? vwr.tm.getRotationQ() : null); + Map<String, Integer> map = new Hashtable<String, Integer>(); + boolean isBiomodel = false; + int[] firstAtomIndexNew = (uniqueAtomNumbers ? new int[nModels] : null); + int modelPt = 0; for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { Atom a = atoms[i]; isBiomodel = models[a.mi].isBioModel; if (showModels && a.mi != iModelLast) { - if (iModelLast != -1) + if (iModelLast != -1) { + modelPt = fixPDBFormat(lines, map, out, firstAtomIndexNew, modelPt); out.append("ENDMDL\n"); - iModelLast = a.mi; + } + lines = new Lst<String>(); + iModel = iModelLast = a.mi; out.append("MODEL " + (iModelLast + 1) + "\n"); - lines = new Lst<String>(); } String sa = a.getAtomName(); boolean leftJustify = (a.getElementSymbol().length() == 2 @@ -2001,25 +2024,24 @@ boolean isHetero = a.isHetero(); if (!isBiomodel) tokens = (leftJustify ? LabelToken.compile(vwr, - "HETATM%5.-5i %-4.4a%1AUNK %1c 1%1E _XYZ_" + occTemp, - '\0', null) : LabelToken - .compile(vwr, - "HETATM%5.-5i %-3.3a%1AUNK %1c 1%1E _XYZ_" - + occTemp, '\0', null) + "HETATM%5.-5i %-4.4a%1AUNK %1c 1%1E _XYZ_" + occTemp, '\0', + null) : LabelToken.compile(vwr, + "HETATM%5.-5i %-3.3a%1AUNK %1c 1%1E _XYZ_" + occTemp, '\0', + null) ); else if (isHetero) tokens = (leftJustify ? LabelToken.compile(vwr, - "HETATM%5.-5i %-4.4a%1A%3.3n %1c%4.-4R%1E _XYZ_" - + occTemp, '\0', null) : LabelToken.compile(vwr, - "HETATM%5.-5i %-3.3a%1A%3.3n %1c%4.-4R%1E _XYZ_" - + occTemp, '\0', null)); + "HETATM%5.-5i %-4.4a%1A%3.3n %1c%4.-4R%1E _XYZ_" + occTemp, '\0', + null) : LabelToken.compile(vwr, + "HETATM%5.-5i %-3.3a%1A%3.3n %1c%4.-4R%1E _XYZ_" + occTemp, + '\0', null)); else tokens = (leftJustify ? LabelToken.compile(vwr, - "ATOM %5.-5i %-4.4a%1A%3.3n %1c%4.-4R%1E _XYZ_" - + occTemp, '\0', null) : LabelToken.compile(vwr, - "ATOM %5.-5i %-3.3a%1A%3.3n %1c%4.-4R%1E _XYZ_" - + occTemp, '\0', null)); + "ATOM %5.-5i %-4.4a%1A%3.3n %1c%4.-4R%1E _XYZ_" + occTemp, '\0', + null) : LabelToken.compile(vwr, + "ATOM %5.-5i %-3.3a%1A%3.3n %1c%4.-4R%1E _XYZ_" + occTemp, + '\0', null)); String XX = a.getElementSymbolIso(false).toUpperCase(); XX = pdbKey(a.group.getBioPolymerIndexInModel()) + pdbKey(a.group.groupIndex) @@ -2032,70 +2054,88 @@ XX = PT.rep(XX, "_XYZ_", xyz); lines.addLast(XX); } - Map<Integer, Integer> map = new Hashtable<Integer, Integer>(); - fixPDBFormat(lines, map, out); - if (showModels) { + fixPDBFormat(lines, map, out, firstAtomIndexNew, modelPt); + if (showModels) out.append("ENDMDL\n"); - } else { - for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { - Atom a = atoms[i]; - boolean isHetero = (!isBiomodel || a.isHetero()); - boolean isCysS = !isHetero && (a.getElementNumber() == 16); - if (isHetero || isMultipleBondPDB || isCysS) { - Bond[] bonds = a.bonds; - if (bonds != null) - for (int j = 0; j < bonds.length; j++) { - int iThis = a.getAtomNumber(); - Atom a2 = bonds[j].getOtherAtom(a); - if (!bs.get(a2.i)) - continue; - int n = bonds[j].getCovalentOrder(); - if (n == 1 - && (isMultipleBondPDB && !isHetero && !isCysS || isCysS - && a2.getElementNumber() != 16)) - continue; - int iOther = a2.getAtomNumber(); - switch (n) { - case 2: - case 3: - if (iOther < iThis) - continue; // only one entry in this case -- pseudo-PDB style - //$FALL-THROUGH$ - case 1: - out.append("CONECT").append( - PT.formatStringS("%5s", "s", "" + map.get(Integer.valueOf(iThis)))); - String s = PT.formatStringS("%5s", "s", "" + map.get(Integer.valueOf(iOther))); - for (int k = 0; k < n; k++) - out.append(s); - out.append("\n"); + + // now for CONECT records... + modelPt = -1; + iModelLast = -1; + isBiomodel = false; + for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { + Atom a = atoms[i]; + if (showModels && a.mi != iModelLast) { + iModelLast = a.mi; + isBiomodel = models[iModelLast].isBioModel; + modelPt++; + } + boolean isHetero = (!isBiomodel || a.isHetero()); + boolean isCysS = !isHetero && (a.getElementNumber() == 16); + if (isHetero || isMultipleBondPDB || isCysS) { + Bond[] bonds = a.bonds; + if (bonds != null) + for (int j = 0; j < bonds.length; j++) { + int iThis = a.getAtomNumber(); + Atom a2 = bonds[j].getOtherAtom(a); + if (!bs.get(a2.i)) + continue; + int n = bonds[j].getCovalentOrder(); + if (n == 1 + && (isMultipleBondPDB && !isHetero && !isCysS || isCysS + && a2.getElementNumber() != 16)) + continue; + int iOther = a2.getAtomNumber(); + switch (n) { + case 2: + case 3: + if (iOther < iThis) + continue; // only one entry in this case -- pseudo-PmapDB style + //$FALL-THROUGH$ + case 1: + Integer inew = map.get("" + modelPt + "." + + Integer.valueOf(iThis)); + Integer inew2 = map.get("" + modelPt + "." + + Integer.valueOf(iOther)); + if (inew == null || inew2 == null) break; - } + out.append("CONECT").append( + PT.formatStringS("%5s", "s", "" + inew)); + String s = PT.formatStringS("%5s", "s", "" + inew2); + for (int k = 0; k < n; k++) + out.append(s); + out.append("\n"); + break; } - } + } } } + return out.toString(); } private String pdbKey(int np) { - String xp = (np < 0 ? "!999" : " " + np); + String xp = (np < 0 ? "~999" : " " + np); return xp.substring(xp.length() - 4); } /** - * must re-order by resno and then renumber atoms - * and add TER records based on BioPolymers + * must re-order by resno and then renumber atoms and add TER records based on + * BioPolymers * - * note: 3hbt has a break between residues 39 and 51 with - * no TER record, but Jmol will put that in. + * note: 3hbt has a break between residues 39 and 51 with no TER record, but + * Jmol will put that in. * * @param lines * @param map - * @param out + * @param out + * @param modelPt + * @param firstAtomIndexNew + * @return new modelPt */ - private void fixPDBFormat(Lst<String> lines, Map<Integer, Integer> map, OC out) { - lines.addLast("!999!999XXXXXX99999999999999999999!99!"); - String[] alines = new String[lines.size()]; + private int fixPDBFormat(Lst<String> lines, Map<String, Integer> map, OC out, + int[] firstAtomIndexNew, int modelPt) { + lines.addLast("~999~999XXXXXX99999999999999999999~99~"); + String[] alines = new String[lines.size()]; lines.toArray(alines); Arrays.sort(alines); lines.clear(); @@ -2105,19 +2145,21 @@ String lastPoly = null; String lastLine = null; int n = lines.size(); + int newAtomNumber = 0; + int iBase = (firstAtomIndexNew == null ? 0 : firstAtomIndexNew[modelPt]); for (int i = 0; i < n; i++) { String s = lines.get(i); String poly = s.substring(0, 4); s = s.substring(8); boolean isTerm = false; - boolean isLast = (s.indexOf("!99!") >= 0); + boolean isLast = (s.indexOf("~99~") >= 0); if (!poly.equals(lastPoly) || isLast) { - if (lastPoly != null && !lastPoly.equals("!999")) { + if (lastPoly != null && !lastPoly.equals("~999")) { isTerm = true; //TER 458 ASN A 78C s = "TER " + lastLine.substring(6, 11) + " " + lastLine.substring(17, 27); - lines.add(i, poly + "!!!!" + s); + lines.add(i, poly + "~~~~" + s); n++; } lastPoly = poly; @@ -2125,12 +2167,19 @@ if (isLast && !isTerm) break; lastLine = s; + newAtomNumber = i + 1 + iBase; if (map != null && !isTerm) - map.put(Integer.valueOf(PT.parseInt(s.substring(6, 11))), Integer.valueOf(i + 1)); - String si = " " + (i + 1); + map.put( + "" + modelPt + "." + + Integer.valueOf(PT.parseInt(s.substring(6, 11))), + Integer.valueOf(newAtomNumber)); + String si = " " + newAtomNumber; out.append(s.substring(0, 6)).append(si.substring(si.length() - 5)) .append(s.substring(11)).append("\n"); } + if (firstAtomIndexNew != null && ++modelPt < firstAtomIndexNew.length) + firstAtomIndexNew[modelPt] = newAtomNumber; + return modelPt; } // Modified: trunk/Jmol/src/javajs/awt/Component.java =================================================================== --- trunk/Jmol/src/javajs/awt/Component.java 2016-07-13 19:52:37 UTC (rev 21180) +++ trunk/Jmol/src/javajs/awt/Component.java 2016-07-24 18:10:47 UTC (rev 21181) @@ -5,7 +5,7 @@ abstract public class Component { - protected boolean visible; + private boolean _visible; protected boolean enabled = true; protected String text; protected String name; @@ -99,11 +99,11 @@ } public boolean isVisible() { - return visible; + return _visible; } public void setVisible(boolean visible) { - this.visible = visible; + this._visible = visible; /** * @j2sNative * Modified: trunk/Jmol/src/org/jmol/modelset/Text.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Text.java 2016-07-13 19:52:37 UTC (rev 21180) +++ trunk/Jmol/src/org/jmol/modelset/Text.java 2016-07-24 18:10:47 UTC (rev 21181) @@ -73,7 +73,6 @@ /** * @param vwr - * @j2sIgnoreSuperConstructor */ private Text(Viewer vwr) { this.vwr = vwr; Modified: trunk/Jmol/src/org/jmol/util/Edge.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Edge.java 2016-07-13 19:52:37 UTC (rev 21180) +++ trunk/Jmol/src/org/jmol/util/Edge.java 2016-07-24 18:10:47 UTC (rev 21181) @@ -99,7 +99,7 @@ public final static int BOND_H_MINUS_4 = 8 << 11; public final static int BOND_H_NUCLEOTIDE = 9 << 11; - public final static int[] argbsHbondType = { + private final static int[] argbsHbondType = { 0xFFFF69B4, // 0 unused - pink 0xFFFFFF00, // 1 regular yellow 0xFFFFFF00, // 2 calc -- unspecified; yellow Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2016-07-13 19:52:37 UTC (rev 21180) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2016-07-24 18:10:47 UTC (rev 21181) @@ -47,8 +47,12 @@ -- sets the echo offset to a specific screen pixel offset -- TODO not saved in state -Jmol.___JmolVersion="14.7.1_2016.07.11" +Jmol.___JmolVersion="14.7.1_2016.07.24" +bug fix: write x.pdb for multimodel file does not work. + +JmolVersion="14.7.1_2016.07.11" + sychronized with Jmol 14.6 bug fix: Jmol SMILES not allowing for insertion-code search Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2016-07-13 19:52:37 UTC (rev 21180) +++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2016-07-24 18:10:47 UTC (rev 21181) @@ -1946,7 +1946,8 @@ * @return PDB file data string */ @Override - public String getPdbAtomData(BS bs, OC out, boolean isPQR, boolean doTransform, boolean allTrajectories) { + public String getPdbAtomData(BS bs, OC out, boolean isPQR, + boolean doTransform, boolean allTrajectories) { if (vwr.ms.ac == 0 || bs.nextSetBit(0) < 0) return ""; if (out == null) { @@ -1957,9 +1958,6 @@ } Atom[] atoms = vwr.ms.at; Model[] models = vwr.ms.am; - int iModel = atoms[bs.nextSetBit(0)].mi; - int iModelLast = -1; - boolean isBiomodel = false; String occTemp = "%6.2Q%6.2b "; if (isPQR) { occTemp = "%8.4P%7.4V "; @@ -1975,25 +1973,50 @@ "\nREMARK 6 Total charge on this protein: " + charge + " e\nREMARK 6\n"); } - - + + int iModel = atoms[bs.nextSetBit(0)].mi; + int iModelLast = -1; int lastAtomIndex = bs.length() - 1; - boolean showModels = (iModel != atoms[lastAtomIndex].mi); + int lastModelIndex = atoms[lastAtomIndex].mi; + boolean showModels = (iModel != lastModelIndex); + BS bsModels = vwr.ms.getModelBS(bs, true); + int nModels = bsModels.cardinality(); Lst<String> lines = new Lst<String>(); boolean isMultipleBondPDB = models[iModel].isPdbWithMultipleBonds; + boolean uniqueAtomNumbers = false; + if (nModels > 1) { + Object conectArray = null; + for (int nFiles = 0, i = bsModels.nextSetBit(0); i >= 0; i = bsModels + .nextSetBit(i + 1)) { + Object a = vwr.ms.getModelAuxiliaryInfo(i).get("PDB_CONECT_bonds"); + if (a != conectArray || !vwr.ms.am[i].isBioModel) { + conectArray = a; + if (nFiles++ > 0) { + uniqueAtomNumbers = true; + break; + } + } + } + } LabelToken[] tokens; P3 ptTemp = new P3(); Object[] o = new Object[] { ptTemp }; Quat q = (doTransform ? vwr.tm.getRotationQ() : null); + Map<String, Integer> map = new Hashtable<String, Integer>(); + boolean isBiomodel = false; + int[] firstAtomIndexNew = (uniqueAtomNumbers ? new int[nModels] : null); + int modelPt = 0; for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { Atom a = atoms[i]; isBiomodel = models[a.mi].isBioModel; if (showModels && a.mi != iModelLast) { - if (iModelLast != -1) + if (iModelLast != -1) { + modelPt = fixPDBFormat(lines, map, out, firstAtomIndexNew, modelPt); out.append("ENDMDL\n"); - iModelLast = a.mi; + } + lines = new Lst<String>(); + iModel = iModelLast = a.mi; out.append("MODEL " + (iModelLast + 1) + "\n"); - lines = new Lst<String>(); } String sa = a.getAtomName(); boolean leftJustify = (a.getElementSymbol().length() == 2 @@ -2001,25 +2024,24 @@ boolean isHetero = a.isHetero(); if (!isBiomodel) tokens = (leftJustify ? LabelToken.compile(vwr, - "HETATM%5.-5i %-4.4a%1AUNK %1c 1%1E _XYZ_" + occTemp, - '\0', null) : LabelToken - .compile(vwr, - "HETATM%5.-5i %-3.3a%1AUNK %1c 1%1E _XYZ_" - + occTemp, '\0', null) + "HETATM%5.-5i %-4.4a%1AUNK %1c 1%1E _XYZ_" + occTemp, '\0', + null) : LabelToken.compile(vwr, + "HETATM%5.-5i %-3.3a%1AUNK %1c 1%1E _XYZ_" + occTemp, '\0', + null) ); else if (isHetero) tokens = (leftJustify ? LabelToken.compile(vwr, - "HETATM%5.-5i %-4.4a%1A%3.3n %1c%4.-4R%1E _XYZ_" - + occTemp, '\0', null) : LabelToken.compile(vwr, - "HETATM%5.-5i %-3.3a%1A%3.3n %1c%4.-4R%1E _XYZ_" - + occTemp, '\0', null)); + "HETATM%5.-5i %-4.4a%1A%3.3n %1c%4.-4R%1E _XYZ_" + occTemp, '\0', + null) : LabelToken.compile(vwr, + "HETATM%5.-5i %-3.3a%1A%3.3n %1c%4.-4R%1E _XYZ_" + occTemp, + '\0', null)); else tokens = (leftJustify ? LabelToken.compile(vwr, - "ATOM %5.-5i %-4.4a%1A%3.3n %1c%4.-4R%1E _XYZ_" - + occTemp, '\0', null) : LabelToken.compile(vwr, - "ATOM %5.-5i %-3.3a%1A%3.3n %1c%4.-4R%1E _XYZ_" - + occTemp, '\0', null)); + "ATOM %5.-5i %-4.4a%1A%3.3n %1c%4.-4R%1E _XYZ_" + occTemp, '\0', + null) : LabelToken.compile(vwr, + "ATOM %5.-5i %-3.3a%1A%3.3n %1c%4.-4R%1E _XYZ_" + occTemp, + '\0', null)); String XX = a.getElementSymbolIso(false).toUpperCase(); XX = pdbKey(a.group.getBioPolymerIndexInModel()) + pdbKey(a.group.groupIndex) @@ -2032,70 +2054,88 @@ XX = PT.rep(XX, "_XYZ_", xyz); lines.addLast(XX); } - Map<Integer, Integer> map = new Hashtable<Integer, Integer>(); - fixPDBFormat(lines, map, out); - if (showModels) { + fixPDBFormat(lines, map, out, firstAtomIndexNew, modelPt); + if (showModels) out.append("ENDMDL\n"); - } else { - for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { - Atom a = atoms[i]; - boolean isHetero = (!isBiomodel || a.isHetero()); - boolean isCysS = !isHetero && (a.getElementNumber() == 16); - if (isHetero || isMultipleBondPDB || isCysS) { - Bond[] bonds = a.bonds; - if (bonds != null) - for (int j = 0; j < bonds.length; j++) { - int iThis = a.getAtomNumber(); - Atom a2 = bonds[j].getOtherAtom(a); - if (!bs.get(a2.i)) - continue; - int n = bonds[j].getCovalentOrder(); - if (n == 1 - && (isMultipleBondPDB && !isHetero && !isCysS || isCysS - && a2.getElementNumber() != 16)) - continue; - int iOther = a2.getAtomNumber(); - switch (n) { - case 2: - case 3: - if (iOther < iThis) - continue; // only one entry in this case -- pseudo-PDB style - //$FALL-THROUGH$ - case 1: - out.append("CONECT").append( - PT.formatStringS("%5s", "s", "" + map.get(Integer.valueOf(iThis)))); - String s = PT.formatStringS("%5s", "s", "" + map.get(Integer.valueOf(iOther))); - for (int k = 0; k < n; k++) - out.append(s); - out.append("\n"); + + // now for CONECT records... + modelPt = -1; + iModelLast = -1; + isBiomodel = false; + for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { + Atom a = atoms[i]; + if (showModels && a.mi != iModelLast) { + iModelLast = a.mi; + isBiomodel = models[iModelLast].isBioModel; + modelPt++; + } + boolean isHetero = (!isBiomodel || a.isHetero()); + boolean isCysS = !isHetero && (a.getElementNumber() == 16); + if (isHetero || isMultipleBondPDB || isCysS) { + Bond[] bonds = a.bonds; + if (bonds != null) + for (int j = 0; j < bonds.length; j++) { + int iThis = a.getAtomNumber(); + Atom a2 = bonds[j].getOtherAtom(a); + if (!bs.get(a2.i)) + continue; + int n = bonds[j].getCovalentOrder(); + if (n == 1 + && (isMultipleBondPDB && !isHetero && !isCysS || isCysS + && a2.getElementNumber() != 16)) + continue; + int iOther = a2.getAtomNumber(); + switch (n) { + case 2: + case 3: + if (iOther < iThis) + continue; // only one entry in this case -- pseudo-PmapDB style + //$FALL-THROUGH$ + case 1: + Integer inew = map.get("" + modelPt + "." + + Integer.valueOf(iThis)); + Integer inew2 = map.get("" + modelPt + "." + + Integer.valueOf(iOther)); + if (inew == null || inew2 == null) break; - } + out.append("CONECT").append( + PT.formatStringS("%5s", "s", "" + inew)); + String s = PT.formatStringS("%5s", "s", "" + inew2); + for (int k = 0; k < n; k++) + out.append(s); + out.append("\n"); + break; } - } + } } } + return out.toString(); } private String pdbKey(int np) { - String xp = (np < 0 ? "!999" : " " + np); + String xp = (np < 0 ? "~999" : " " + np); return xp.substring(xp.length() - 4); } /** - * must re-order by resno and then renumber atoms - * and add TER records based on BioPolymers + * must re-order by resno and then renumber atoms and add TER records based on + * BioPolymers * - * note: 3hbt has a break between residues 39 and 51 with - * no TER record, but Jmol will put that in. + * note: 3hbt has a break between residues 39 and 51 with no TER record, but + * Jmol will put that in. * * @param lines * @param map - * @param out + * @param out + * @param modelPt + * @param firstAtomIndexNew + * @return new modelPt */ - private void fixPDBFormat(Lst<String> lines, Map<Integer, Integer> map, OC out) { - lines.addLast("!999!999XXXXXX99999999999999999999!99!"); - String[] alines = new String[lines.size()]; + private int fixPDBFormat(Lst<String> lines, Map<String, Integer> map, OC out, + int[] firstAtomIndexNew, int modelPt) { + lines.addLast("~999~999XXXXXX99999999999999999999~99~"); + String[] alines = new String[lines.size()]; lines.toArray(alines); Arrays.sort(alines); lines.clear(); @@ -2105,19 +2145,21 @@ String lastPoly = null; String lastLine = null; int n = lines.size(); + int newAtomNumber = 0; + int iBase = (firstAtomIndexNew == null ? 0 : firstAtomIndexNew[modelPt]); for (int i = 0; i < n; i++) { String s = lines.get(i); String poly = s.substring(0, 4); s = s.substring(8); boolean isTerm = false; - boolean isLast = (s.indexOf("!99!") >= 0); + boolean isLast = (s.indexOf("~99~") >= 0); if (!poly.equals(lastPoly) || isLast) { - if (lastPoly != null && !lastPoly.equals("!999")) { + if (lastPoly != null && !lastPoly.equals("~999")) { isTerm = true; //TER 458 ASN A 78C s = "TER " + lastLine.substring(6, 11) + " " + lastLine.substring(17, 27); - lines.add(i, poly + "!!!!" + s); + lines.add(i, poly + "~~~~" + s); n++; } lastPoly = poly; @@ -2125,12 +2167,19 @@ if (isLast && !isTerm) break; lastLine = s; + newAtomNumber = i + 1 + iBase; if (map != null && !isTerm) - map.put(Integer.valueOf(PT.parseInt(s.substring(6, 11))), Integer.valueOf(i + 1)); - String si = " " + (i + 1); + map.put( + "" + modelPt + "." + + Integer.valueOf(PT.parseInt(s.substring(6, 11))), + Integer.valueOf(newAtomNumber)); + String si = " " + newAtomNumber; out.append(s.substring(0, 6)).append(si.substring(si.length() - 5)) .append(s.substring(11)).append("\n"); } + if (firstAtomIndexNew != null && ++modelPt < firstAtomIndexNew.length) + firstAtomIndexNew[modelPt] = newAtomNumber; + return modelPt; } // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |