initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
Jmol.___JmolDate="$Date: 2018-02-07 23:40:37 -0600 (Wed, 07 Feb 2018) $"
|
||||
Jmol.___fullJmolProperties="src/org/jmol/viewer/Jmol.properties"
|
||||
Jmol.___JmolVersion="14.29.4"
|
||||
@@ -0,0 +1,210 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.aflow");
|
||||
Clazz.load (["J.adapter.readers.xtal.VaspPoscarReader", "java.util.Hashtable"], "J.adapter.readers.aflow.AFLOWReader", ["java.lang.Float", "java.util.Arrays", "JU.BS", "$.Lst", "$.PT", "$.SB", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.aabb = null;
|
||||
this.readPRE = false;
|
||||
this.fracB = NaN;
|
||||
this.compositions = null;
|
||||
this.getComposition = false;
|
||||
this.listKey = null;
|
||||
this.listKeyCase = null;
|
||||
this.fileModelNumber = 0;
|
||||
this.havePRE = false;
|
||||
this.titleMsg = null;
|
||||
this.keyMap = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.aflow, "AFLOWReader", J.adapter.readers.xtal.VaspPoscarReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.keyMap = new java.util.Hashtable ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.readPRE = this.checkFilterKey ("PRE");
|
||||
var s;
|
||||
s = this.getFilter ("CA=");
|
||||
if (s != null) this.fracB = (1 - this.parseFloatStr (s));
|
||||
s = this.getFilter ("CB=");
|
||||
if (s != null) this.fracB = this.parseFloatStr (s);
|
||||
s = this.getFilter ("LIST=");
|
||||
this.listKey = (s == null ? "HF" : s);
|
||||
this.listKeyCase = this.listKey;
|
||||
this.getComposition = !Float.isNaN (this.fracB);
|
||||
this.discardLinesUntilStartsWith ("[");
|
||||
this.aabb = this.line.substring (1, this.line.indexOf ("]"));
|
||||
var pt = (JU.PT.isUpperCase (this.aabb.charAt (1)) ? 1 : 2);
|
||||
this.defaultLabels = Clazz.newArray (-1, [this.aabb.substring (0, pt), this.aabb.substring (pt)]);
|
||||
while (this.rd ().indexOf ("] REFERENCE:") >= 0) this.appendLoadNote (this.line);
|
||||
|
||||
this.compositions = new java.util.Hashtable ();
|
||||
this.quiet = true;
|
||||
this.asc.bsAtoms = new JU.BS ();
|
||||
this.addJmolScript ("unitcell off;axes off;");
|
||||
this.havePRE = (this.line.indexOf ("Structure PRE") >= 0);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (!this.havePRE) this.discardLinesUntilContains ("Structure PRE");
|
||||
this.havePRE = false;
|
||||
if (this.line == null) return false;
|
||||
this.continuing = new Boolean (this.continuing & this.readPrePost ()).valueOf ();
|
||||
return this.continuing;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPrePost",
|
||||
function () {
|
||||
this.fileModelNumber++;
|
||||
this.titleMsg = "#" + (this.modelNumber + 1) + (this.getComposition ? "," + this.fileModelNumber + ", Cb=" + this.fracB : "");
|
||||
this.elementLabel = null;
|
||||
var n0 = this.asc.bsAtoms.cardinality ();
|
||||
if (this.readPRE) {
|
||||
this.readStructure (this.titleMsg);
|
||||
} else {
|
||||
this.readElementLabelsOnly ();
|
||||
this.discardLinesUntilContains ("Structure POST");
|
||||
this.readStructure (this.titleMsg);
|
||||
}if (this.getData ()) {
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
} else {
|
||||
this.asc.bsAtoms.clearBits (this.asc.getLastAtomSetAtomIndex (), this.asc.ac);
|
||||
this.doCheckUnitCell = false;
|
||||
}this.finalizeModel ();
|
||||
if (n0 != this.asc.bsAtoms.cardinality ()) JU.Logger.info ("AFLOW: file#, saved#, atoms: " + this.fileModelNumber + " " + this.modelNumber + " " + (this.asc.bsAtoms.cardinality () - n0));
|
||||
return !this.haveModel || this.modelNumber != this.desiredModelNumber;
|
||||
});
|
||||
Clazz.defineMethod (c$, "finalizeModel",
|
||||
function () {
|
||||
var n = this.asc.ac;
|
||||
var nremoved = 0;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
var nnow = 0;
|
||||
for (var i = i0; i < n; i++) {
|
||||
if (!this.asc.bsAtoms.get (i)) {
|
||||
nremoved++;
|
||||
this.asc.ac--;
|
||||
this.asc.atoms[i] = null;
|
||||
continue;
|
||||
}if (nremoved > 0) {
|
||||
this.asc.atoms[this.asc.atoms[i].index = i - nremoved] = this.asc.atoms[i];
|
||||
this.asc.atoms[i] = null;
|
||||
}nnow++;
|
||||
}
|
||||
this.asc.atomSetAtomCounts[this.asc.iSet] = nnow;
|
||||
if (nnow == 0) {
|
||||
this.asc.iSet--;
|
||||
this.asc.atomSetCount--;
|
||||
} else {
|
||||
this.asc.bsAtoms.setBits (i0, i0 + nnow);
|
||||
}});
|
||||
Clazz.defineMethod (c$, "readElementLabelsOnly",
|
||||
function () {
|
||||
this.readLines (5);
|
||||
this.rdline ();
|
||||
var n = this.getTokens ().length;
|
||||
this.elementLabel = new Array (n);
|
||||
this.rdline ();
|
||||
this.line = "";
|
||||
var s = null;
|
||||
var last = null;
|
||||
for (var i = 0; i < n; i++) {
|
||||
while (s == null || s.equals (last)) {
|
||||
this.rdline ();
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length != 4 || (s = this.elementLabel[i] = this.getElement (tokens[3])) == null) {
|
||||
i = n + 1;
|
||||
break;
|
||||
}}
|
||||
last = s;
|
||||
}
|
||||
if (s == null) this.elementLabel = this.defaultLabels;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getData",
|
||||
function () {
|
||||
this.discardLinesUntilContains ("- DATA -");
|
||||
var htAFLOW = new java.util.Hashtable ();
|
||||
htAFLOW.put ("fileModelNumber", Integer.$valueOf (this.fileModelNumber));
|
||||
htAFLOW.put ("modelNumber", Integer.$valueOf (this.modelNumber + 1));
|
||||
htAFLOW.put ("AaBb", this.aabb);
|
||||
var pt = 0;
|
||||
var sb = new JU.SB ();
|
||||
var listVal = 3.4028235E38;
|
||||
var strcb = "?";
|
||||
var listValStr = null;
|
||||
var cb = 0;
|
||||
while (this.rdline () != null && (pt = this.line.indexOf (" # ")) >= 0) {
|
||||
var key = this.line.substring (pt + 3).trim ();
|
||||
var val = this.line.substring (0, pt).trim ();
|
||||
sb.append (key).append ("=").append (val).append (" | ");
|
||||
if (key.toUpperCase ().startsWith (this.listKey)) {
|
||||
this.listKey = key.toUpperCase ();
|
||||
this.listKeyCase = key;
|
||||
listValStr = val;
|
||||
listVal = this.parseFloatStr (val);
|
||||
}if (key.equals ("Ca")) {
|
||||
var ca = this.parseFloatStr (val);
|
||||
if (this.getComposition && Math.abs ((1 - ca) - this.fracB) > 0.01) return false;
|
||||
} else if (key.equals ("Cb")) {
|
||||
cb = this.parseFloatStr (strcb = val);
|
||||
if (this.getComposition && Math.abs (cb - this.fracB) > 0.01) return false;
|
||||
} else if (key.equals ("Hf_atom [eV] (VASP)")) {
|
||||
var e = this.parseFloatStr (val);
|
||||
this.asc.setAtomSetEnergy (val, e);
|
||||
}}
|
||||
this.asc.setAtomSetName (this.titleMsg + (this.getComposition ? "" : " Cb=" + cb) + " " + this.listKey + "=" + listValStr);
|
||||
var count_min = this.compositions.get (strcb);
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return false;
|
||||
if (count_min == null) this.compositions.put (strcb, count_min = Clazz.newFloatArray (-1, [0, 3.4028235E38, 0]));
|
||||
count_min[0]++;
|
||||
if (listVal < count_min[1]) {
|
||||
count_min[1] = listVal;
|
||||
count_min[2] = this.fileModelNumber;
|
||||
}while (this.line.indexOf ("- URL -") < 0) this.rdline ();
|
||||
|
||||
sb.append ("URL=" + this.rdline () + "|");
|
||||
while (this.line.indexOf ("aurl=") < 0) this.rdline ();
|
||||
|
||||
sb.append (this.line);
|
||||
var pairs = JU.PT.split (sb.toString (), " | ");
|
||||
for (var i = pairs.length; --i >= 0; ) {
|
||||
var kv = pairs[i].$plit ("=");
|
||||
if (kv.length < 2) continue;
|
||||
var f = this.parseFloatStr (kv[1]);
|
||||
var o = Float.isNaN (f) ? kv[1] : Float.$valueOf (f);
|
||||
htAFLOW.put (kv[0], o);
|
||||
var kvclean = this.cleanKey (kv[0]);
|
||||
if (kvclean !== kv[0]) htAFLOW.put (kvclean, o);
|
||||
}
|
||||
this.asc.setCurrentModelInfo ("aflowInfo", htAFLOW);
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "cleanKey",
|
||||
function (key) {
|
||||
var kclean = this.keyMap.get (key);
|
||||
if (kclean != null) return kclean;
|
||||
var chars = key.toCharArray ();
|
||||
for (var i = chars.length; --i >= 0; ) if (!JU.PT.isLetterOrDigit (chars[i])) chars[i] = '_';
|
||||
|
||||
this.keyMap.put (key, kclean = JU.PT.trim (JU.PT.rep ( String.instantialize (chars), "__", "_"), "_"));
|
||||
return kclean;
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.alignUnitCells ();
|
||||
this.listCompositions ();
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "listCompositions",
|
||||
function () {
|
||||
var list = new JU.Lst ();
|
||||
for (var e, $e = this.compositions.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) {
|
||||
var count_min = e.getValue ();
|
||||
list.addLast (e.getKey () + "\t" + (Clazz.floatToInt (count_min[0])) + "\t" + Clazz.floatToInt (count_min[2]) + "\t" + this.listKeyCase + "\t" + count_min[1]);
|
||||
}
|
||||
var a = new Array (list.size ());
|
||||
list.toArray (a);
|
||||
java.util.Arrays.sort (a);
|
||||
for (var i = 0, n = a.length; i < n; i++) this.appendLoadNote (this.aabb + "\t" + a[i]);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "alignUnitCells",
|
||||
function () {
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,198 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.cif");
|
||||
Clazz.load (["JU.CifDataParser"], "J.adapter.readers.cif.Cif2DataParser", ["java.lang.Float", "java.util.Hashtable", "JU.Lst", "$.PT"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.cif, "Cif2DataParser", JU.CifDataParser);
|
||||
Clazz.overrideMethod (c$, "getVersion",
|
||||
function () {
|
||||
return 2;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "toUnicode",
|
||||
function (data) {
|
||||
return data;
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "isQuote",
|
||||
function (ch) {
|
||||
switch (ch) {
|
||||
case '\1':
|
||||
case '\'':
|
||||
case '\"':
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case ';':
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "getQuotedStringOrObject",
|
||||
function (ch) {
|
||||
return this.processQuotedString ();
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "preprocessString",
|
||||
function () {
|
||||
this.line = (this.ich == 0 ? this.str : this.str.substring (this.ich));
|
||||
return this.setString (this.processSemiString ());
|
||||
});
|
||||
Clazz.defineMethod (c$, "processQuotedString",
|
||||
function () {
|
||||
var str = null;
|
||||
var quoteChar = this.str.charAt (this.ich);
|
||||
var tripleChar = null;
|
||||
try {
|
||||
switch (quoteChar) {
|
||||
case '\1':
|
||||
str = this.str.substring (1, (this.ich = this.str.indexOf ("\1", this.ich + 1)));
|
||||
this.ich++;
|
||||
break;
|
||||
case '[':
|
||||
return this.readList ();
|
||||
case ']':
|
||||
this.ich++;
|
||||
return "]";
|
||||
case '{':
|
||||
return this.readTable ();
|
||||
case '}':
|
||||
this.ich++;
|
||||
return "}";
|
||||
case '\'':
|
||||
case '"':
|
||||
if (this.str.indexOf ("'''") == this.ich) tripleChar = "'''";
|
||||
else if (this.str.indexOf ("\"\"\"") == this.ich) tripleChar = "\"\"\"";
|
||||
var nchar = (tripleChar == null ? 1 : 3);
|
||||
var pt = this.ich + nchar;
|
||||
var pt1 = 0;
|
||||
while ((pt1 = (tripleChar == null ? this.str.indexOf (quoteChar, pt) : this.str.indexOf (tripleChar, pt))) < 0) {
|
||||
if (this.readLine () == null) break;
|
||||
this.str += this.line;
|
||||
}
|
||||
this.ich = pt1 + nchar;
|
||||
this.cch = this.str.length;
|
||||
str = this.str.substring (pt, pt1);
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
System.out.println ("exception in Cif2DataParser ; " + e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return (this.cterm == '\0' || this.asObject ? str : JU.PT.esc (str));
|
||||
});
|
||||
Clazz.defineMethod (c$, "processSemiString",
|
||||
function () {
|
||||
var pt1;
|
||||
var pt2;
|
||||
var str = this.preprocessSemiString ();
|
||||
if (str.indexOf (';') != 1 && (pt1 = str.indexOf ('\\')) > 1 && ((pt2 = str.indexOf ('\n')) > pt1 || pt2 < 0)) {
|
||||
var prefix = str.substring (1, pt1);
|
||||
str = JU.PT.rep (str, "\n" + prefix, "\n");
|
||||
str = "\1" + str.substring (str.charAt (pt1 + 1) == '\\' ? pt1 + 1 : pt2 < 0 ? str.length - 1 : pt2 + 1);
|
||||
}this.ich = 0;
|
||||
return this.fixLineFolding (str);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readList",
|
||||
function () {
|
||||
this.ich++;
|
||||
var cterm0 = this.cterm;
|
||||
this.cterm = ']';
|
||||
var ns = this.nullString;
|
||||
this.nullString = null;
|
||||
var lst = (this.asObject ? new JU.Lst () : null);
|
||||
var n = 0;
|
||||
var str = "";
|
||||
while (true) {
|
||||
var value = (this.asObject ? this.getNextTokenObject () : this.getNextToken ());
|
||||
if (value == null || value.equals ("]")) break;
|
||||
if (this.asObject) {
|
||||
lst.addLast (value);
|
||||
} else {
|
||||
if (n++ > 0) str += ",";
|
||||
str += value;
|
||||
}}
|
||||
this.cterm = cterm0;
|
||||
this.nullString = ns;
|
||||
return (this.asObject ? lst : "[" + str + "]");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readTable",
|
||||
function () {
|
||||
this.ich++;
|
||||
var cterm0 = this.cterm;
|
||||
this.cterm = '}';
|
||||
var ns = this.nullString;
|
||||
this.nullString = null;
|
||||
var map = (this.asObject ? new java.util.Hashtable () : null);
|
||||
var n = 0;
|
||||
var str = "";
|
||||
while (true) {
|
||||
var key = this.getNextToken ();
|
||||
if (key == null || key.equals ("}")) break;
|
||||
while (this.isSpaceOrColon (this.ich)) this.ich++;
|
||||
|
||||
if (this.asObject) {
|
||||
map.put (key, this.getNextTokenObject ());
|
||||
} else {
|
||||
if (n++ > 0) str += ",";
|
||||
str += key + " : " + this.getNextToken ();
|
||||
}}
|
||||
this.cterm = cterm0;
|
||||
this.nullString = ns;
|
||||
return (this.asObject ? map : "{" + str + "}");
|
||||
});
|
||||
Clazz.defineMethod (c$, "isSpaceOrColon",
|
||||
function (ich) {
|
||||
if (ich < this.cch) switch (this.line.charAt (ich)) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case ':':
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}, "~N");
|
||||
Clazz.overrideMethod (c$, "unquoted",
|
||||
function (s) {
|
||||
if (this.cterm == '\0' && !this.asObject) return s;
|
||||
var n = s.length;
|
||||
if (n > 0) {
|
||||
var c = s.charAt (0);
|
||||
if (JU.PT.isDigit (c) || c == '-' || c == '.' && n > 1) {
|
||||
var pt = s.indexOf ('(');
|
||||
var isFloat = (s.indexOf (".") >= 0);
|
||||
if (n > 1 && pt > 0 && s.indexOf (')', pt + 1) == n - 1) s = s.substring (0, pt);
|
||||
try {
|
||||
if (isFloat) {
|
||||
var f = Float.parseFloat (s);
|
||||
if (this.asObject) return Float.$valueOf (f);
|
||||
s = "" + f;
|
||||
if (s.indexOf (".") < 0 && s.indexOf ("E") < 0) s += ".0";
|
||||
return s;
|
||||
}var i = Integer.parseInt (s);
|
||||
return (this.asObject ? Integer.$valueOf (i) : "" + i);
|
||||
} catch (e) {
|
||||
}
|
||||
}}return (this.asObject ? s : JU.PT.esc (s));
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "fixLineFolding",
|
||||
function (str) {
|
||||
if (str.indexOf ('\\') < 0) return str;
|
||||
var n = str.length;
|
||||
if (str.endsWith ("\\\1")) str = str.substring (0, n - 1) + "\n\1";
|
||||
var pt = 0;
|
||||
while ((pt = str.indexOf ('\\', pt + 1)) >= 0) {
|
||||
var eol = str.indexOf ('\n', pt);
|
||||
if (eol < 0) break;
|
||||
for (var i = eol; --i > pt; ) {
|
||||
var ch = str.charAt (i);
|
||||
if (!JU.PT.isWhitespace (ch)) {
|
||||
if (ch == '\\') {
|
||||
pt = i;
|
||||
break;
|
||||
}pt = eol;
|
||||
break;
|
||||
}}
|
||||
if (pt < eol) str = str.substring (0, pt) + str.substring (eol + 1);
|
||||
}
|
||||
return str;
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.cif");
|
||||
Clazz.load (["J.adapter.readers.cif.CifReader"], "J.adapter.readers.cif.Cif2Reader", ["J.adapter.readers.cif.Cif2DataParser"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.cif, "Cif2Reader", J.adapter.readers.cif.CifReader);
|
||||
Clazz.overrideMethod (c$, "getCifDataParser",
|
||||
function () {
|
||||
return new J.adapter.readers.cif.Cif2DataParser ().set (this, null, this.debugging);
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,709 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.cif");
|
||||
Clazz.load (["J.adapter.readers.cif.CifReader"], "J.adapter.readers.cif.MMCifReader", ["java.lang.Boolean", "java.util.Hashtable", "JU.BS", "$.Lst", "$.M4", "$.P3", "$.PT", "$.SB", "J.adapter.smarter.Atom", "$.Structure", "J.c.STR", "JU.BSUtil", "$.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.isBiomolecule = false;
|
||||
this.byChain = false;
|
||||
this.bySymop = false;
|
||||
this.chainAtomMap = null;
|
||||
this.chainAtomCounts = null;
|
||||
this.vBiomolecules = null;
|
||||
this.htBiomts = null;
|
||||
this.htSites = null;
|
||||
this.htHetero = null;
|
||||
this.htBondMap = null;
|
||||
this.assemblyIdAtoms = null;
|
||||
this.thisChain = -1;
|
||||
this.modelIndex = 0;
|
||||
this.chainSum = null;
|
||||
this.chainAtomCount = null;
|
||||
this.isLigandBondBug = false;
|
||||
this.mident = null;
|
||||
this.requiresSorting = false;
|
||||
this.structConnMap = null;
|
||||
this.structConnList = "";
|
||||
this.doSetBonds = false;
|
||||
this.modelStrings = "";
|
||||
this.done = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.cif, "MMCifReader", J.adapter.readers.cif.CifReader);
|
||||
Clazz.overrideMethod (c$, "initSubclass",
|
||||
function () {
|
||||
this.setIsPDB ();
|
||||
this.mident = JU.M4.newM4 (null);
|
||||
this.isMMCIF = true;
|
||||
if (this.isDSSP1) this.asc.setInfo ("isDSSP1", Boolean.TRUE);
|
||||
if (this.htParams.containsKey ("isMutate")) this.asc.setInfo ("isMutate", Boolean.TRUE);
|
||||
this.doSetBonds = this.checkFilterKey ("ADDBONDS");
|
||||
this.byChain = this.checkFilterKey ("BYCHAIN");
|
||||
if (this.checkFilterKey ("BIOMOLECULE")) this.filter = JU.PT.rep (this.filter, "BIOMOLECULE", "ASSEMBLY");
|
||||
this.isBiomolecule = this.checkFilterKey ("ASSEMBLY");
|
||||
if (this.isBiomolecule) {
|
||||
this.filter = this.filter.$replace (':', ' ');
|
||||
this.bySymop = this.checkFilterKey ("BYSYMOP");
|
||||
}this.isCourseGrained = this.byChain || this.bySymop;
|
||||
if (this.isCourseGrained) {
|
||||
this.chainAtomMap = new java.util.Hashtable ();
|
||||
this.chainAtomCounts = new java.util.Hashtable ();
|
||||
}this.isLigandBondBug = (this.stateScriptVersionInt >= 140204 && this.stateScriptVersionInt <= 140208 || this.stateScriptVersionInt >= 140304 && this.stateScriptVersionInt <= 140308);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processSubclassEntry",
|
||||
function () {
|
||||
if (this.key0.startsWith ("_pdbx_struct_assembly_gen.") || this.key0.startsWith ("_struct_conn.") || this.key0.startsWith ("_struct_ref_seq_dif.") || this.key0.startsWith ("_struct_conf.") || this.key0.startsWith ("_struct_sheet_range.")) this.processSubclassLoopBlock ();
|
||||
else if (this.key.equals ("_rna3d")) {
|
||||
this.addedData = this.data;
|
||||
this.addedDataKey = this.key;
|
||||
} else if (this.key.equals ("_dssr")) {
|
||||
this.dssr = this.vwr.parseJSONMap (this.reader.readLine ());
|
||||
this.reader.readLine ();
|
||||
}});
|
||||
Clazz.overrideMethod (c$, "processSubclassLoopBlock",
|
||||
function () {
|
||||
if (this.key0.startsWith ("_struct_ncs_oper.")) return this.processStructOperListBlock (true);
|
||||
if (this.key0.startsWith ("_pdbx_struct_oper_list.")) return this.processStructOperListBlock (false);
|
||||
if (this.key0.startsWith ("_pdbx_struct_assembly_gen.")) return this.processAssemblyGenBlock ();
|
||||
if (this.key0.startsWith ("_struct_ref_seq_dif.")) return this.processSequence ();
|
||||
if (this.isCourseGrained) return false;
|
||||
if (this.key0.startsWith ("_struct_site_gen.")) return this.processStructSiteBlock ();
|
||||
if (this.key0.startsWith ("_chem_comp.")) return this.processChemCompLoopBlock ();
|
||||
if (this.key0.startsWith ("_struct_conf.")) return this.processStructConfLoopBlock ();
|
||||
if (this.key0.startsWith ("_struct_sheet_range.")) return this.processStructSheetRangeLoopBlock ();
|
||||
if (this.isLigandBondBug) return false;
|
||||
if (this.key0.startsWith ("_chem_comp_bond.")) return this.processCompBondLoopBlock ();
|
||||
if (this.key0.startsWith ("_struct_conn.")) return this.processStructConnLoopBlock ();
|
||||
return false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "sortAssemblyModels",
|
||||
function () {
|
||||
var natoms = this.asc.ac;
|
||||
var lastSet = -1;
|
||||
var atoms = this.asc.atoms;
|
||||
var newAtoms = new Array (natoms);
|
||||
var ids = JU.PT.split ("," + this.modelStrings + ",", ",,");
|
||||
var bsAtomsNew = (this.asc.bsAtoms == null ? null : JU.BS.newN (this.asc.bsAtoms.size ()));
|
||||
for (var im = 1, n = 0; im < ids.length; im++) {
|
||||
var sModel = ids[im];
|
||||
var modelIndex = -1;
|
||||
for (var is = 0; is < this.asc.atomSetCount; is++) {
|
||||
var ia0 = this.asc.getAtomSetAtomIndex (is);
|
||||
var ia1 = ia0 + this.asc.getAtomSetAtomCount (is);
|
||||
var am = "" + this.modelMap.get ("_" + is);
|
||||
if (am.equals (sModel)) {
|
||||
if (modelIndex < 0 && (modelIndex = is) > lastSet) lastSet = is;
|
||||
for (var i = ia0; i < ia1; i++) {
|
||||
if (bsAtomsNew == null || this.asc.bsAtoms.get (i)) {
|
||||
if (bsAtomsNew != null) bsAtomsNew.set (n);
|
||||
atoms[i].atomSetIndex = modelIndex;
|
||||
newAtoms[n++] = atoms[i];
|
||||
}}
|
||||
}}
|
||||
}
|
||||
this.asc.atoms = newAtoms;
|
||||
this.asc.bsAtoms = bsAtomsNew;
|
||||
if (++lastSet < this.asc.atomSetCount) this.asc.atomSetCount = lastSet;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclass",
|
||||
function () {
|
||||
if (this.byChain && !this.isBiomolecule) for (var id, $id = this.chainAtomMap.keySet ().iterator (); $id.hasNext () && ((id = $id.next ()) || true);) this.createParticle (id);
|
||||
|
||||
var haveBiomolecule = (this.isBiomolecule && this.vBiomolecules != null && this.vBiomolecules.size () > 0);
|
||||
if (!this.isCourseGrained && this.asc.ac == this.nAtoms) {
|
||||
this.asc.removeCurrentAtomSet ();
|
||||
} else {
|
||||
if ((this.dssr != null || this.validation != null || this.addedData != null) && !this.isCourseGrained && !this.requiresSorting) {
|
||||
var vs = (this.getInterface ("J.adapter.readers.cif.MMCifValidationParser")).set (this);
|
||||
var note = null;
|
||||
if (this.addedData == null) {
|
||||
if (this.validation != null || this.dssr != null) note = vs.finalizeValidations (this.vwr, this.modelMap);
|
||||
} else if (this.addedDataKey.equals ("_rna3d")) {
|
||||
note = vs.finalizeRna3d (this.modelMap);
|
||||
}if (note != null) this.appendLoadNote (note);
|
||||
}this.setHetero ();
|
||||
if (this.doSetBonds) this.setBonds ();
|
||||
}if (this.asc.ac == 0 && !this.isCourseGrained) return false;
|
||||
var spaceGroup = this.sgName;
|
||||
if (this.htSites != null) this.addSites (this.htSites);
|
||||
if (haveBiomolecule) {
|
||||
this.asc.setCurrentModelInfo ("biomolecules", this.vBiomolecules);
|
||||
this.setBiomolecules ();
|
||||
if (this.thisBiomolecule != null) {
|
||||
if (this.iHaveFractionalCoordinates) this.fractionalizeCoordinates (false);
|
||||
this.asc.getXSymmetry ().applySymmetryBio (this.thisBiomolecule, this.applySymmetryToBonds, this.filter);
|
||||
this.asc.xtalSymmetry = null;
|
||||
}this.doCheckUnitCell = new Boolean (this.doCheckUnitCell & (this.iHaveUnitCell && this.doApplySymmetry)).valueOf ();
|
||||
if (this.doCheckUnitCell) {
|
||||
this.ignoreFileSpaceGroupName = true;
|
||||
this.sgName = spaceGroup;
|
||||
this.fractionalizeCoordinates (true);
|
||||
this.asc.setCurrentModelInfo ("biosymmetry", null);
|
||||
this.asc.setCurrentModelInfo ("biosymmetryCount", null);
|
||||
this.asc.checkSpecial = false;
|
||||
if (this.byChain) return true;
|
||||
}}if (this.latticeCells != null && this.latticeCells[0] != 0) this.addJmolScript ("unitcell;axes on;axes unitcell;");
|
||||
if (this.requiresSorting) this.sortAssemblyModels ();
|
||||
return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkSubclassSymmetry",
|
||||
function () {
|
||||
this.asc.checkSpecial = false;
|
||||
var modelIndex = this.asc.iSet;
|
||||
this.asc.setCurrentModelInfo ("PDB_CONECT_firstAtom_count_max", Clazz.newIntArray (-1, [this.asc.getAtomSetAtomIndex (modelIndex), this.asc.getAtomSetAtomCount (modelIndex), this.maxSerial]));
|
||||
return false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setBonds",
|
||||
function () {
|
||||
if (this.htBondMap == null) return;
|
||||
var bsAtoms = this.asc.bsAtoms;
|
||||
if (bsAtoms == null) bsAtoms = JU.BSUtil.newBitSet2 (0, this.asc.ac);
|
||||
var atoms = this.asc.atoms;
|
||||
var seqid = -1;
|
||||
var comp = null;
|
||||
var map = null;
|
||||
for (var i = bsAtoms.nextSetBit (0); i >= 0; i = bsAtoms.nextSetBit (i + 1)) {
|
||||
var a = atoms[i];
|
||||
var pt = (a.vib == null ? a.sequenceNumber : a.vib.x);
|
||||
if (pt != seqid) {
|
||||
seqid = pt;
|
||||
if (comp != null) this.processBonds (this.htBondMap.get (comp), map, false);
|
||||
map = new java.util.Hashtable ();
|
||||
comp = atoms[i].group3;
|
||||
if (!this.htBondMap.containsKey (comp)) {
|
||||
comp = null;
|
||||
continue;
|
||||
}}if (comp == null) continue;
|
||||
map.put (a.atomName, Integer.$valueOf (a.index));
|
||||
}
|
||||
if (comp != null) this.processBonds (this.htBondMap.get (comp), map, false);
|
||||
if (this.structConnMap != null) {
|
||||
map = new java.util.Hashtable ();
|
||||
seqid = -1;
|
||||
comp = null;
|
||||
for (var i = bsAtoms.nextSetBit (0); i >= 0; i = bsAtoms.nextSetBit (i + 1)) {
|
||||
var a = atoms[i];
|
||||
var pt = (a.vib == null ? a.sequenceNumber : a.vib.x);
|
||||
if (pt != seqid) {
|
||||
seqid = pt;
|
||||
var ckey = a.chainID + a.group3 + seqid;
|
||||
if (this.structConnList.indexOf (ckey) < 0) {
|
||||
comp = null;
|
||||
continue;
|
||||
}comp = ckey;
|
||||
}if (comp == null) continue;
|
||||
map.put (comp + a.atomName + a.altLoc, Integer.$valueOf (a.index));
|
||||
}
|
||||
this.processBonds (this.structConnMap, map, true);
|
||||
}this.appendLoadNote (this.asc.bondCount + " bonds added");
|
||||
});
|
||||
Clazz.defineMethod (c$, "processBonds",
|
||||
function (cmap, map, isStructConn) {
|
||||
var i1;
|
||||
var i2;
|
||||
for (var i = 0, n = cmap.size (); i < n; i++) {
|
||||
var o = cmap.get (i);
|
||||
if ((i1 = map.get (o[0])) == null || (i2 = map.get (o[1])) == null) continue;
|
||||
if (this.debugging) JU.Logger.debug ((isStructConn ? "_struct_conn" : "_comp_bond") + " adding bond " + i1 + " " + i2 + " order=" + o[2]);
|
||||
this.asc.addNewBondWithOrder (i1.intValue (), i2.intValue (), (o[2]).intValue ());
|
||||
}
|
||||
}, "JU.Lst,java.util.Map,~B");
|
||||
Clazz.defineMethod (c$, "processSequence",
|
||||
function () {
|
||||
this.parseLoopParameters (J.adapter.readers.cif.MMCifReader.structRefFields);
|
||||
var g1;
|
||||
var g3;
|
||||
while (this.parser.getData ()) {
|
||||
if (this.isNull (g1 = this.getField (1).toLowerCase ()) || g1.length != 1 || this.isNull (g3 = this.getField (0))) continue;
|
||||
if (this.htGroup1 == null) this.asc.setInfo ("htGroup1", this.htGroup1 = new java.util.Hashtable ());
|
||||
this.htGroup1.put (g3, g1);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processAssemblyGenBlock",
|
||||
function () {
|
||||
this.parseLoopParameters (J.adapter.readers.cif.MMCifReader.assemblyFields);
|
||||
while (this.parser.getData ()) {
|
||||
var assem = new Array (3);
|
||||
var count = 0;
|
||||
var p;
|
||||
var n = this.parser.getColumnCount ();
|
||||
for (var i = 0; i < n; ++i) {
|
||||
switch (p = this.fieldProperty (i)) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
count++;
|
||||
assem[p] = this.field;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count == 3) this.addAssembly (assem);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "addAssembly",
|
||||
function (assem) {
|
||||
var id = assem[0];
|
||||
var list = assem[2];
|
||||
var operators = assem[1];
|
||||
var name = "biomolecule " + id;
|
||||
JU.Logger.info (name + " operators " + operators + " ASYM_IDs " + list);
|
||||
this.appendLoadNote ("found " + name + ": " + list);
|
||||
if (this.vBiomolecules == null) this.vBiomolecules = new JU.Lst ();
|
||||
var info = null;
|
||||
for (var i = this.vBiomolecules.size (); --i >= 0; ) if (this.vBiomolecules.get (i).get ("name").equals (name)) {
|
||||
info = this.vBiomolecules.get (i);
|
||||
break;
|
||||
}
|
||||
if (info == null) {
|
||||
info = new java.util.Hashtable ();
|
||||
info.put ("name", name);
|
||||
var iMolecule = this.parseIntStr (id);
|
||||
info.put ("molecule", iMolecule == -2147483648 ? id : Integer.$valueOf (iMolecule));
|
||||
info.put ("biomts", new JU.Lst ());
|
||||
info.put ("chains", new JU.Lst ());
|
||||
info.put ("assemblies", new JU.Lst ());
|
||||
info.put ("operators", new JU.Lst ());
|
||||
this.vBiomolecules.addLast (info);
|
||||
}(info.get ("assemblies")).addLast ("$" + list.$replace (',', '$'));
|
||||
(info.get ("operators")).addLast (this.decodeAssemblyOperators (operators));
|
||||
this.checkFilterAssembly (id, info);
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "checkFilterAssembly",
|
||||
function (id, info) {
|
||||
if (this.checkFilterKey ("ASSEMBLY " + id + ";") || this.checkFilterKey ("ASSEMBLY=" + id + ";")) this.thisBiomolecule = info;
|
||||
}, "~S,java.util.Map");
|
||||
Clazz.defineMethod (c$, "decodeAssemblyOperators",
|
||||
function (ops) {
|
||||
var pt = ops.indexOf (")(");
|
||||
if (pt >= 0) return this.crossBinary (this.decodeAssemblyOperators (ops.substring (0, pt + 1)), this.decodeAssemblyOperators (ops.substring (pt + 1)));
|
||||
if (ops.startsWith ("(")) {
|
||||
if (ops.indexOf ("-") >= 0) ops = JU.BS.unescape ("({" + ops.substring (1, ops.length - 1).$replace ('-', ':').$replace (',', ' ') + "})").toJSON ();
|
||||
ops = JU.PT.rep (ops, " ", "");
|
||||
ops = ops.substring (1, ops.length - 1);
|
||||
}return ops;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "crossBinary",
|
||||
function (ops1, ops2) {
|
||||
var sb = new JU.SB ();
|
||||
var opsLeft = JU.PT.split (ops1, ",");
|
||||
var opsRight = JU.PT.split (ops2, ",");
|
||||
for (var i = 0; i < opsLeft.length; i++) for (var j = 0; j < opsRight.length; j++) sb.append (",").append (opsLeft[i]).append ("|").append (opsRight[j]);
|
||||
|
||||
|
||||
return sb.toString ().substring (1);
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "processStructOperListBlock",
|
||||
function (isNCS) {
|
||||
this.parseLoopParametersFor ((isNCS ? "_struct_ncs_oper" : "_pdbx_struct_oper_list"), isNCS ? J.adapter.readers.cif.MMCifReader.ncsoperFields : J.adapter.readers.cif.MMCifReader.operFields);
|
||||
var m = Clazz.newFloatArray (16, 0);
|
||||
m[15] = 1;
|
||||
while (this.parser.getData ()) {
|
||||
var count = 0;
|
||||
var id = null;
|
||||
var xyz = null;
|
||||
var n = this.parser.getColumnCount ();
|
||||
for (var i = 0; i < n; ++i) {
|
||||
var p = this.fieldProperty (i);
|
||||
switch (p) {
|
||||
case -1:
|
||||
break;
|
||||
case 12:
|
||||
id = this.field;
|
||||
break;
|
||||
case 13:
|
||||
xyz = this.field;
|
||||
break;
|
||||
default:
|
||||
m[p] = this.parseFloatStr (this.field);
|
||||
++count;
|
||||
}
|
||||
}
|
||||
if (id != null && (count == 12 || xyz != null && this.symmetry != null)) {
|
||||
JU.Logger.info ((isNCS ? "noncrystallographic symmetry operator " : "assembly operator ") + id + " " + xyz);
|
||||
var m4 = new JU.M4 ();
|
||||
if (count != 12) {
|
||||
this.symmetry.getMatrixFromString (xyz, m, false, 0);
|
||||
m[3] *= this.symmetry.getUnitCellInfoType (0) / 12;
|
||||
m[7] *= this.symmetry.getUnitCellInfoType (1) / 12;
|
||||
m[11] *= this.symmetry.getUnitCellInfoType (2) / 12;
|
||||
}m4.setA (m);
|
||||
this.addMatrix (id, m4, isNCS);
|
||||
}}
|
||||
return true;
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "addMatrix",
|
||||
function (id, m4, isNCS) {
|
||||
if (isNCS) {
|
||||
if (m4.equals (this.mident)) return;
|
||||
m4.m33 = 0;
|
||||
if (this.lstNCS == null) this.lstNCS = new JU.Lst ();
|
||||
this.lstNCS.addLast (m4);
|
||||
} else {
|
||||
if (this.htBiomts == null) this.htBiomts = new java.util.Hashtable ();
|
||||
this.htBiomts.put (id, m4);
|
||||
}}, "~S,JU.M4,~B");
|
||||
Clazz.defineMethod (c$, "processChemCompLoopBlock",
|
||||
function () {
|
||||
this.parseLoopParameters (J.adapter.readers.cif.MMCifReader.chemCompFields);
|
||||
var groupName;
|
||||
var hetName;
|
||||
while (this.parser.getData ()) if (!this.isNull (groupName = this.getField (0)) && !this.isNull (hetName = this.getField (1))) this.addHetero (groupName, hetName, true, true);
|
||||
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "addHetero",
|
||||
function (groupName, hetName, doCheck, addNote) {
|
||||
if (doCheck && !this.vwr.getJBR ().isHetero (groupName)) return;
|
||||
if (this.htHetero == null) this.htHetero = new java.util.Hashtable ();
|
||||
if (doCheck && this.htHetero.containsKey (groupName)) return;
|
||||
this.htHetero.put (groupName, hetName);
|
||||
if (addNote) this.appendLoadNote (groupName + " = " + hetName);
|
||||
}, "~S,~S,~B,~B");
|
||||
Clazz.defineMethod (c$, "processStructConfLoopBlock",
|
||||
function () {
|
||||
if (this.ignoreStructure) {
|
||||
this.parser.skipLoop (false);
|
||||
return false;
|
||||
}this.parseLoopParametersFor ("_struct_conf", J.adapter.readers.cif.MMCifReader.structConfFields);
|
||||
if (!this.checkAllFieldsPresent (J.adapter.readers.cif.MMCifReader.structConfFields, -1, true)) {
|
||||
this.parser.skipLoop (true);
|
||||
return false;
|
||||
}while (this.parser.getData ()) {
|
||||
var structure = new J.adapter.smarter.Structure (-1, J.c.STR.HELIX, J.c.STR.HELIX, null, 0, 0, null);
|
||||
var type = this.getField (0);
|
||||
if (type.startsWith ("TURN")) structure.structureType = structure.substructureType = J.c.STR.TURN;
|
||||
else if (!type.startsWith ("HELX")) structure.structureType = structure.substructureType = J.c.STR.NONE;
|
||||
else structure.substructureType = J.adapter.smarter.Structure.getHelixType (this.parseIntStr (this.getField (9)));
|
||||
structure.serialID = this.parseIntStr (this.getField (8));
|
||||
structure.structureID = this.getField (7);
|
||||
this.addStructure (structure);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "addStructure",
|
||||
function (structure) {
|
||||
structure.startChainID = this.vwr.getChainID (structure.startChainStr = this.getField (1), true);
|
||||
structure.startSequenceNumber = this.parseIntStr (this.getField (2));
|
||||
structure.startInsertionCode = this.getField (3).charAt (0);
|
||||
structure.endChainID = this.vwr.getChainID (structure.endChainStr = this.getField (4), true);
|
||||
structure.endSequenceNumber = this.parseIntStr (this.getField (5));
|
||||
structure.endInsertionCode = this.getField (6).charAt (0);
|
||||
this.asc.addStructure (structure);
|
||||
}, "J.adapter.smarter.Structure");
|
||||
Clazz.defineMethod (c$, "processStructSheetRangeLoopBlock",
|
||||
function () {
|
||||
if (this.ignoreStructure) {
|
||||
this.parser.skipLoop (false);
|
||||
return false;
|
||||
}this.parseLoopParametersFor ("_struct_sheet_range", J.adapter.readers.cif.MMCifReader.structSheetRangeFields);
|
||||
if (!this.checkAllFieldsPresent (J.adapter.readers.cif.MMCifReader.structSheetRangeFields, -1, true)) {
|
||||
this.parser.skipLoop (true);
|
||||
return false;
|
||||
}while (this.parser.getData ()) this.addStructure ( new J.adapter.smarter.Structure (-1, J.c.STR.SHEET, J.c.STR.SHEET, this.getField (0), this.parseIntStr (this.getField (7)), 1, null));
|
||||
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processStructSiteBlock",
|
||||
function () {
|
||||
this.parseLoopParametersFor ("_struct_site_gen", J.adapter.readers.cif.MMCifReader.structSiteFields);
|
||||
var htSite = null;
|
||||
this.htSites = new java.util.Hashtable ();
|
||||
var seqNum;
|
||||
var resID;
|
||||
while (this.parser.getData ()) {
|
||||
if (this.isNull (seqNum = this.getField (3)) || this.isNull (resID = this.getField (1))) continue;
|
||||
var siteID = this.getField (0);
|
||||
htSite = this.htSites.get (siteID);
|
||||
if (htSite == null) {
|
||||
htSite = new java.util.Hashtable ();
|
||||
htSite.put ("groups", "");
|
||||
this.htSites.put (siteID, htSite);
|
||||
}var insCode = this.getField (4);
|
||||
var chainID = this.getField (2);
|
||||
var group = "[" + resID + "]" + seqNum + (this.isNull (insCode) ? "" : "^" + insCode) + (this.isNull (chainID) ? "" : ":" + chainID);
|
||||
var groups = htSite.get ("groups");
|
||||
groups += (groups.length == 0 ? "" : ",") + group;
|
||||
htSite.put ("groups", groups);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setBiomolecules",
|
||||
function () {
|
||||
if (this.assemblyIdAtoms == null && this.chainAtomCounts == null) return;
|
||||
var bsAll = new JU.BS ();
|
||||
for (var i = this.vBiomolecules.size (); --i >= 0; ) {
|
||||
var biomolecule = this.vBiomolecules.get (i);
|
||||
this.setBiomolecule (biomolecule, (biomolecule === this.thisBiomolecule ? bsAll : null));
|
||||
}
|
||||
if (this.isBiomolecule && bsAll.cardinality () < this.asc.ac) {
|
||||
if (this.asc.bsAtoms != null) this.asc.bsAtoms.and (bsAll);
|
||||
else if (!this.isCourseGrained) this.asc.bsAtoms = bsAll;
|
||||
}});
|
||||
Clazz.defineMethod (c$, "setBiomolecule",
|
||||
function (biomolecule, bsAll) {
|
||||
var biomtchains = biomolecule.get ("chains");
|
||||
var biomts = biomolecule.get ("biomts");
|
||||
var operators = biomolecule.get ("operators");
|
||||
var assemblies = biomolecule.get ("assemblies");
|
||||
var sum = new JU.P3 ();
|
||||
var count = 0;
|
||||
var bsAtoms = new JU.BS ();
|
||||
var nAtomsTotal = 0;
|
||||
var isBioCourse = (this.isBiomolecule && this.isCourseGrained);
|
||||
for (var i = operators.size (); --i >= 0; ) {
|
||||
var ops = JU.PT.split (operators.get (i), ",");
|
||||
var ids = JU.PT.split (assemblies.get (i), "$");
|
||||
var chainlist = "";
|
||||
var nAtoms = 0;
|
||||
for (var j = 1; j < ids.length; j++) {
|
||||
var id = ids[j];
|
||||
chainlist += ":" + id + ";";
|
||||
if (this.assemblyIdAtoms != null) {
|
||||
biomolecule.put ("asemblyIdAtoms", this.assemblyIdAtoms);
|
||||
var bs = this.assemblyIdAtoms.get (id);
|
||||
if (bs != null) {
|
||||
bsAtoms.or (bs);
|
||||
if (bsAll != null) bsAll.or (bs);
|
||||
nAtoms += bs.cardinality ();
|
||||
}} else if (isBioCourse) {
|
||||
var asum = this.chainAtomMap.get (id);
|
||||
if (asum != null) {
|
||||
if (this.bySymop) {
|
||||
sum.add (asum);
|
||||
count += this.chainAtomCounts.get (id)[0];
|
||||
} else {
|
||||
this.createParticle (id);
|
||||
nAtoms++;
|
||||
}}}}
|
||||
if (!this.isBiomolecule) continue;
|
||||
for (var j = 0; j < ops.length; j++) {
|
||||
var m = this.getOpMatrix (ops[j]);
|
||||
if (m == null) return 0;
|
||||
if (m.equals (this.mident)) {
|
||||
biomts.add (0, this.mident);
|
||||
biomtchains.add (0, chainlist);
|
||||
} else {
|
||||
biomts.addLast (m);
|
||||
biomtchains.addLast (chainlist);
|
||||
}}
|
||||
if (this.bySymop && bsAll != null) {
|
||||
nAtoms = 1;
|
||||
var a1 = new J.adapter.smarter.Atom ();
|
||||
a1.setT (sum);
|
||||
a1.scale (1 / count);
|
||||
a1.radius = 16;
|
||||
this.asc.addAtom (a1);
|
||||
}nAtoms *= ops.length;
|
||||
nAtomsTotal += nAtoms;
|
||||
}
|
||||
biomolecule.put ("atomCount", Integer.$valueOf (nAtomsTotal));
|
||||
return nAtomsTotal;
|
||||
}, "java.util.Map,JU.BS");
|
||||
Clazz.defineMethod (c$, "createParticle",
|
||||
function (id) {
|
||||
var asum = this.chainAtomMap.get (id);
|
||||
var c = this.chainAtomCounts.get (id)[0];
|
||||
var a = new J.adapter.smarter.Atom ();
|
||||
a.setT (asum);
|
||||
a.scale (1 / c);
|
||||
a.elementSymbol = "Pt";
|
||||
this.setChainID (a, id);
|
||||
a.radius = 16;
|
||||
this.asc.addAtom (a);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getOpMatrix",
|
||||
function (ops) {
|
||||
if (this.htBiomts == null) return JU.M4.newM4 (null);
|
||||
var pt = ops.indexOf ("|");
|
||||
if (pt >= 0) {
|
||||
var m = JU.M4.newM4 (this.htBiomts.get (ops.substring (0, pt)));
|
||||
m.mul (this.htBiomts.get (ops.substring (pt + 1)));
|
||||
return m;
|
||||
}return this.htBiomts.get (ops);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "processStructConnLoopBlock",
|
||||
function () {
|
||||
this.parseLoopParametersFor ("_struct_conn", J.adapter.readers.cif.MMCifReader.structConnFields);
|
||||
while (this.parser.getData ()) {
|
||||
var sym1 = this.getField (5);
|
||||
var sym2 = this.getField (11);
|
||||
if (!sym1.equals (sym2) || !this.isNull (sym1) && !sym1.equals ("1_555")) continue;
|
||||
var type = this.getField (12);
|
||||
if (!type.startsWith ("covale") && !type.equals ("disulf") && !type.equals ("metalc")) continue;
|
||||
if (this.htBondMap == null) this.htBondMap = new java.util.Hashtable ();
|
||||
var key1 = this.vwr.getChainID (this.getField (0), true) + this.getField (2) + this.parseFloatStr (this.getField (1)) + this.getField (3) + this.getField (4);
|
||||
var key2 = this.vwr.getChainID (this.getField (6), true) + this.getField (8) + this.parseFloatStr (this.getField (7)) + this.getField (9) + this.getField (10);
|
||||
var order = this.getBondOrder (this.getField (13));
|
||||
if (this.structConnMap == null) this.structConnMap = new JU.Lst ();
|
||||
this.structConnMap.addLast ( Clazz.newArray (-1, [key1, key2, Integer.$valueOf (order)]));
|
||||
if (this.structConnList.indexOf (key1) < 0) this.structConnList += key1;
|
||||
if (this.structConnList.indexOf (key2) < 0) this.structConnList += key2;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processCompBondLoopBlock",
|
||||
function () {
|
||||
this.doSetBonds = true;
|
||||
this.parseLoopParametersFor ("_chem_comp_bond", J.adapter.readers.cif.MMCifReader.chemCompBondFields);
|
||||
while (this.parser.getData ()) {
|
||||
var comp = this.getField (0);
|
||||
var atom1 = this.getField (1);
|
||||
var atom2 = this.getField (2);
|
||||
var order = this.getBondOrder (this.getField (3));
|
||||
if ((this.getField (4).charAt (0) == 'Y')) switch (order) {
|
||||
case 1:
|
||||
order = 513;
|
||||
break;
|
||||
case 2:
|
||||
order = 514;
|
||||
break;
|
||||
}
|
||||
if (this.isLigand) {
|
||||
this.asc.addNewBondWithOrderA (this.asc.getAtomFromName (atom1), this.asc.getAtomFromName (atom2), order);
|
||||
} else if (this.haveHAtoms || this.htHetero != null && this.htHetero.containsKey (comp)) {
|
||||
if (this.htBondMap == null) this.htBondMap = new java.util.Hashtable ();
|
||||
var cmap = this.htBondMap.get (comp);
|
||||
if (cmap == null) this.htBondMap.put (comp, cmap = new JU.Lst ());
|
||||
cmap.addLast ( Clazz.newArray (-1, [atom1, atom2, Integer.$valueOf (this.haveHAtoms ? order : 1)]));
|
||||
}}
|
||||
return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processSubclassAtom",
|
||||
function (atom, assemblyId, strChain) {
|
||||
if (this.isBiomolecule) {
|
||||
if (this.isCourseGrained) {
|
||||
var sum = this.chainAtomMap.get (assemblyId);
|
||||
if (sum == null) {
|
||||
this.chainAtomMap.put (assemblyId, sum = new JU.P3 ());
|
||||
this.chainAtomCounts.put (assemblyId, Clazz.newIntArray (1, 0));
|
||||
}this.chainAtomCounts.get (assemblyId)[0]++;
|
||||
sum.add (atom);
|
||||
return false;
|
||||
}} else if (this.byChain) {
|
||||
if (this.thisChain != atom.chainID) {
|
||||
this.thisChain = atom.chainID;
|
||||
this.chainSum = this.chainAtomMap.get (strChain);
|
||||
if (this.chainSum == null) {
|
||||
this.chainAtomMap.put (strChain, this.chainSum = new JU.P3 ());
|
||||
this.chainAtomCounts.put (strChain, this.chainAtomCount = Clazz.newIntArray (1, 0));
|
||||
}}this.chainSum.add (atom);
|
||||
this.chainAtomCount[0]++;
|
||||
return false;
|
||||
}if (assemblyId != null) {
|
||||
if (this.assemblyIdAtoms == null) this.assemblyIdAtoms = new java.util.Hashtable ();
|
||||
var bs = this.assemblyIdAtoms.get (assemblyId);
|
||||
if (bs == null) this.assemblyIdAtoms.put (assemblyId, bs = new JU.BS ());
|
||||
bs.set (this.ac);
|
||||
}return true;
|
||||
}, "J.adapter.smarter.Atom,~S,~S");
|
||||
Clazz.overrideMethod (c$, "checkPDBModelField",
|
||||
function (modelField, currentModelNo) {
|
||||
this.fieldProperty (modelField);
|
||||
var modelNo = this.parseIntStr (this.field);
|
||||
return (modelNo == currentModelNo ? modelNo : this.incrementModel (modelNo));
|
||||
}, "~N,~N");
|
||||
Clazz.defineMethod (c$, "incrementModel",
|
||||
function (modelNo) {
|
||||
var isAssembly = (this.thisDataSetName != null && this.thisDataSetName.indexOf ("-assembly-") >= 0);
|
||||
if (isAssembly) {
|
||||
this.useFileModelNumbers = true;
|
||||
var key = "," + modelNo + ",";
|
||||
if (this.modelStrings.indexOf (key) >= 0) {
|
||||
this.requiresSorting = true;
|
||||
} else {
|
||||
this.modelStrings += key;
|
||||
}}if (this.iHaveDesiredModel && this.asc.atomSetCount > 0 && !isAssembly) {
|
||||
this.done = true;
|
||||
if (this.parser != null) {
|
||||
this.parser.skipLoop (false);
|
||||
this.skipping = false;
|
||||
}this.continuing = true;
|
||||
return -2147483648;
|
||||
}var modelNumberToUse = (this.useFileModelNumbers ? modelNo : ++this.modelIndex);
|
||||
this.setHetero ();
|
||||
this.newModel (modelNumberToUse);
|
||||
if (!this.skipping) {
|
||||
this.nextAtomSet ();
|
||||
if (this.modelMap == null || this.asc.ac == 0) this.modelMap = new java.util.Hashtable ();
|
||||
this.modelMap.put ("" + modelNo, Integer.$valueOf (Math.max (0, this.asc.iSet)));
|
||||
this.modelMap.put ("_" + Math.max (0, this.asc.iSet), Integer.$valueOf (modelNo));
|
||||
}return modelNo;
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "setHetero",
|
||||
function () {
|
||||
if (this.htHetero != null) {
|
||||
this.asc.setCurrentModelInfo ("hetNames", this.htHetero);
|
||||
this.asc.setInfo ("hetNames", this.htHetero);
|
||||
}});
|
||||
Clazz.defineStatics (c$,
|
||||
"OPER_ID", 12,
|
||||
"OPER_XYZ", 13,
|
||||
"FAMILY_NCS_CAT", "_struct_ncs_oper.",
|
||||
"FAMILY_NCS", "_struct_ncs_oper",
|
||||
"ncsoperFields", Clazz.newArray (-1, ["*_matrix[1][1]", "*_matrix[1][2]", "*_matrix[1][3]", "*_vector[1]", "*_matrix[2][1]", "*_matrix[2][2]", "*_matrix[2][3]", "*_vector[2]", "*_matrix[3][1]", "*_matrix[3][2]", "*_matrix[3][3]", "*_vector[3]", "*_id", "*_symmetry_operation"]),
|
||||
"FAMILY_OPER_CAT", "_pdbx_struct_oper_list.",
|
||||
"FAMILY_OPER", "_pdbx_struct_oper_list",
|
||||
"operFields", Clazz.newArray (-1, ["*_matrix[1][1]", "*_matrix[1][2]", "*_matrix[1][3]", "*_vector[1]", "*_matrix[2][1]", "*_matrix[2][2]", "*_matrix[2][3]", "*_vector[2]", "*_matrix[3][1]", "*_matrix[3][2]", "*_matrix[3][3]", "*_vector[3]", "*_id", "*_symmetry_operation"]),
|
||||
"ASSEM_ID", 0,
|
||||
"ASSEM_OPERS", 1,
|
||||
"ASSEM_LIST", 2,
|
||||
"FAMILY_ASSEM_CAT", "_pdbx_struct_assembly_gen.",
|
||||
"assemblyFields", Clazz.newArray (-1, ["_pdbx_struct_assembly_gen_assembly_id", "_pdbx_struct_assembly_gen_oper_expression", "_pdbx_struct_assembly_gen_asym_id_list"]),
|
||||
"FAMILY_SEQUENCEDIF_CAT", "_struct_ref_seq_dif.",
|
||||
"STRUCT_REF_G3", 0,
|
||||
"STRUCT_REF_G1", 1,
|
||||
"structRefFields", Clazz.newArray (-1, ["_struct_ref_seq_dif_mon_id", "_struct_ref_seq_dif_db_mon_id"]),
|
||||
"CHEM_COMP_ID", 0,
|
||||
"CHEM_COMP_NAME", 1,
|
||||
"FAMILY_CHEMCOMP_CAT", "_chem_comp.",
|
||||
"chemCompFields", Clazz.newArray (-1, ["_chem_comp_id", "_chem_comp_name"]),
|
||||
"CONF_TYPE_ID", 0,
|
||||
"BEG_ASYM_ID", 1,
|
||||
"BEG_SEQ_ID", 2,
|
||||
"BEG_INS_CODE", 3,
|
||||
"END_ASYM_ID", 4,
|
||||
"END_SEQ_ID", 5,
|
||||
"END_INS_CODE", 6,
|
||||
"STRUCT_ID", 7,
|
||||
"SERIAL_NO", 8,
|
||||
"HELIX_CLASS", 9,
|
||||
"FAMILY_STRUCTCONF_CAT", "_struct_conf.",
|
||||
"FAMILY_STRUCTCONF", "_struct_conf",
|
||||
"structConfFields", Clazz.newArray (-1, ["*_conf_type_id", "*_beg_auth_asym_id", "*_beg_auth_seq_id", "*_pdbx_beg_pdb_ins_code", "*_end_auth_asym_id", "*_end_auth_seq_id", "*_pdbx_end_pdb_ins_code", "*_id", "*_pdbx_pdb_helix_id", "*_pdbx_pdb_helix_class"]),
|
||||
"SHEET_ID", 0,
|
||||
"STRAND_ID", 7,
|
||||
"FAMILY_SHEET_CAT", "_struct_sheet_range.",
|
||||
"FAMILY_SHEET", "_struct_sheet_range",
|
||||
"structSheetRangeFields", Clazz.newArray (-1, ["*_sheet_id", "*_beg_auth_asym_id", "*_beg_auth_seq_id", "*_pdbx_beg_pdb_ins_code", "*_end_auth_asym_id", "*_end_auth_seq_id", "*_pdbx_end_pdb_ins_code", "*_id"]),
|
||||
"SITE_ID", 0,
|
||||
"SITE_COMP_ID", 1,
|
||||
"SITE_ASYM_ID", 2,
|
||||
"SITE_SEQ_ID", 3,
|
||||
"SITE_INS_CODE", 4,
|
||||
"FAMILY_STRUCSITE_CAT", "_struct_site_gen.",
|
||||
"FAMILY_STRUCSITE", "_struct_site_gen",
|
||||
"structSiteFields", Clazz.newArray (-1, ["*_site_id", "*_auth_comp_id", "*_auth_asym_id", "*_auth_seq_id", "*_label_alt_id"]),
|
||||
"STRUCT_CONN_ASYM1", 0,
|
||||
"STRUCT_CONN_SEQ1", 1,
|
||||
"STRUCT_CONN_COMP1", 2,
|
||||
"STRUCT_CONN_ATOM1", 3,
|
||||
"STRUCT_CONN_ALT1", 4,
|
||||
"STRUCT_CONN_SYMM1", 5,
|
||||
"STRUCT_CONN_ASYM2", 6,
|
||||
"STRUCT_CONN_SEQ2", 7,
|
||||
"STRUCT_CONN_COMP2", 8,
|
||||
"STRUCT_CONN_ATOM2", 9,
|
||||
"STRUCT_CONN_ALT2", 10,
|
||||
"STRUCT_CONN_SYMM2", 11,
|
||||
"STRUCT_CONN_TYPE", 12,
|
||||
"STRUCT_CONN_ORDER", 13,
|
||||
"FAMILY_STRUCTCONN_CAT", "_struct_conn.",
|
||||
"FAMILY_STRUCTCONN", "_struct_conn",
|
||||
"structConnFields", Clazz.newArray (-1, ["*_ptnr1_auth_asym_id", "*_ptnr1_auth_seq_id", "*_ptnr1_auth_comp_id", "*_ptnr1_label_atom_id", "*_pdbx_ptnr1_label_alt_id", "*_ptnr1_symmetry", "*_ptnr2_auth_asym_id", "*_ptnr2_auth_seq_id", "*_ptnr2_auth_comp_id", "*_ptnr2_label_atom_id", "*_pdbx_ptnr2_label_alt_id", "*_ptnr2_symmetry", "*_conn_type_id", "*_pdbx_value_order"]),
|
||||
"CHEM_COMP_BOND_ID", 0,
|
||||
"CHEM_COMP_BOND_ATOM_ID_1", 1,
|
||||
"CHEM_COMP_BOND_ATOM_ID_2", 2,
|
||||
"CHEM_COMP_BOND_VALUE_ORDER", 3,
|
||||
"CHEM_COMP_BOND_AROMATIC_FLAG", 4,
|
||||
"FAMILY_COMPBOND_CAT", "_chem_comp_bond.",
|
||||
"FAMILY_COMPBOND", "_chem_comp_bond",
|
||||
"chemCompBondFields", Clazz.newArray (-1, ["*_comp_id", "*_atom_id_1", "*_atom_id_2", "*_value_order", "*_pdbx_aromatic_flag"]));
|
||||
});
|
||||
@@ -0,0 +1,132 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.cif");
|
||||
Clazz.load (null, "J.adapter.readers.cif.MMCifValidationParser", ["java.lang.Character", "java.util.Hashtable", "JU.Lst", "$.PT", "JS.SV", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.asResidues = false;
|
||||
this.reader = null;
|
||||
this.resMap = null;
|
||||
this.atomMap = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.cif, "MMCifValidationParser");
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
});
|
||||
Clazz.defineMethod (c$, "set",
|
||||
function (reader) {
|
||||
this.reader = reader;
|
||||
this.asResidues = reader.checkFilterKey ("ASRES");
|
||||
return this;
|
||||
}, "J.adapter.smarter.AtomSetCollectionReader");
|
||||
Clazz.defineMethod (c$, "finalizeValidations",
|
||||
function (vwr, modelMap) {
|
||||
var map = this.reader.dssr;
|
||||
if (map != null) return vwr.getAnnotationParser (true).fixDSSRJSONMap (map);
|
||||
this.mapAtomResIDs (modelMap);
|
||||
var svMap = this.reader.validation;
|
||||
var retProps = this.reader.vwr.getAnnotationParser (false).catalogValidations (this.reader.vwr, svMap, this.getModelAtomIndices (), this.resMap, (this.asResidues ? null : this.atomMap), modelMap);
|
||||
var note = (retProps == null || retProps.size () == 0 ? null : this.setProperties (retProps));
|
||||
svMap.mapPut ("_note", JS.SV.newS (note));
|
||||
return note;
|
||||
}, "JV.Viewer,java.util.Map");
|
||||
Clazz.defineMethod (c$, "finalizeRna3d",
|
||||
function (modelMap) {
|
||||
this.mapAtomResIDs (modelMap);
|
||||
var svMap = this.getRna3dMap (this.reader.addedData);
|
||||
var note = this.reader.vwr.getAnnotationParser (false).catalogStructureUnits (this.reader.vwr, svMap, this.getModelAtomIndices (), this.resMap, null, modelMap);
|
||||
svMap.mapPut ("_note", JS.SV.newS (note));
|
||||
for (var i = this.reader.asc.atomSetCount; --i >= 0; ) {
|
||||
var info = this.reader.asc.getAtomSetAuxiliaryInfo (i);
|
||||
info.put ("rna3d", svMap);
|
||||
}
|
||||
return note;
|
||||
}, "java.util.Map");
|
||||
Clazz.defineMethod (c$, "getRna3dMap",
|
||||
function (addedData) {
|
||||
var map = new java.util.Hashtable ();
|
||||
var next = Clazz.newIntArray (1, 0);
|
||||
var id = "";
|
||||
while ((id = JU.PT.getQuotedStringNext (addedData, next)).length > 0) {
|
||||
var units = JU.PT.getQuotedStringNext (addedData, next);
|
||||
var type = "?";
|
||||
switch (id.charAt (0)) {
|
||||
case 'H':
|
||||
type = "hairpinLoops";
|
||||
break;
|
||||
case 'I':
|
||||
type = "internalLoops";
|
||||
break;
|
||||
case 'J':
|
||||
type = "junctions";
|
||||
break;
|
||||
default:
|
||||
JU.Logger.error ("MMCif could not read: " + id + " " + units);
|
||||
continue;
|
||||
}
|
||||
var list = map.get (type);
|
||||
if (list == null) map.put (type, list = new JU.Lst ());
|
||||
var m = new java.util.Hashtable ();
|
||||
m.put ("index", Integer.$valueOf (JU.PT.parseInt (id.substring (id.lastIndexOf ("_") + 1))));
|
||||
m.put ("units", units);
|
||||
list.addLast (m);
|
||||
}
|
||||
return JS.SV.getVariableMap (map);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "mapAtomResIDs",
|
||||
function (modelMap) {
|
||||
var atoms = this.reader.asc.atoms;
|
||||
this.resMap = new java.util.Hashtable ();
|
||||
this.atomMap = new java.util.Hashtable ();
|
||||
var iresLast = -1;
|
||||
var resLast = null;
|
||||
var smodel = "" + modelMap.get ("_0");
|
||||
for (var i = 0, model = 1, i0 = 0, n = this.reader.asc.getAtomSetAtomCount (0); i < n; i++) {
|
||||
var a = atoms[i];
|
||||
var ires = a.sequenceNumber;
|
||||
var res = smodel + "_" + a.chainID + "_" + ires + "_" + (a.insertionCode == '\0' ? "" : "" + a.insertionCode);
|
||||
var atom = res + "_" + a.atomName.toUpperCase () + "_" + (a.altLoc == '\0' ? "" : "" + Character.toLowerCase (a.altLoc));
|
||||
var ia = Integer.$valueOf (i - i0);
|
||||
if (ires != iresLast) {
|
||||
iresLast = ires;
|
||||
if (resLast != null) resLast[1] = i - i0;
|
||||
this.resMap.put (res, resLast = Clazz.newIntArray (-1, [i - i0, n]));
|
||||
}this.atomMap.put (atom, ia);
|
||||
if (i == n - 1) {
|
||||
i0 += n;
|
||||
n = this.reader.asc.getAtomSetAtomCount (model++);
|
||||
}}
|
||||
}, "java.util.Map");
|
||||
Clazz.defineMethod (c$, "getModelAtomIndices",
|
||||
function () {
|
||||
var indices = Clazz.newIntArray (this.reader.asc.atomSetCount + 1, 0);
|
||||
for (var m = indices.length - 1; --m >= 0; ) indices[m] = this.reader.baseAtomIndex + this.reader.asc.getAtomSetAtomIndex (m);
|
||||
|
||||
indices[indices.length - 1] = this.reader.asc.ac;
|
||||
return indices;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setProperties",
|
||||
function (propList) {
|
||||
var note = "Validations loaded:";
|
||||
for (var i = 0, n = propList.size (); i < n; ) {
|
||||
var key = propList.get (i++);
|
||||
var f = propList.get (i++);
|
||||
var model = (propList.get (i++)).intValue ();
|
||||
var isGroup = (propList.get (i++)).booleanValue ();
|
||||
var count = 0;
|
||||
var max = 0;
|
||||
var reslast = -1;
|
||||
var i0 = this.reader.asc.getAtomSetAtomIndex (model);
|
||||
for (var j = f.length; --j >= 0; ) if (f[j] != 0) {
|
||||
if (isGroup) {
|
||||
var res = this.reader.asc.atoms[i0 + j].sequenceNumber;
|
||||
if (res != reslast) {
|
||||
reslast = res;
|
||||
count++;
|
||||
}} else {
|
||||
count++;
|
||||
}max = Math.max (f[j], max);
|
||||
}
|
||||
note += "\n property_" + key + " (" + (isGroup ? "residues: " : "atoms: ") + count + (max == 1 ? "" : ", max: " + (Clazz.floatToInt (max * 100)) / 100) + ")";
|
||||
this.reader.asc.setAtomProperties (key, f, model, isGroup);
|
||||
}
|
||||
return note;
|
||||
}, "JU.Lst");
|
||||
});
|
||||
@@ -0,0 +1,286 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.cif");
|
||||
Clazz.load (["J.adapter.readers.cif.MMCifReader"], "J.adapter.readers.cif.MMTFReader", ["java.lang.Boolean", "java.util.Hashtable", "JU.BS", "$.Lst", "$.M4", "$.MessagePackReader", "$.PT", "$.SB", "J.adapter.smarter.Atom", "$.Bond", "$.Structure", "JS.SV", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.haveStructure = false;
|
||||
this.$pdbID = null;
|
||||
this.map = null;
|
||||
this.fileAtomCount = 0;
|
||||
this.opCount = 0;
|
||||
this.groupModels = null;
|
||||
this.groupMap = null;
|
||||
this.groupDSSP = null;
|
||||
this.atomGroup = null;
|
||||
this.labelAsymList = null;
|
||||
this.atomMap = null;
|
||||
this.entities = null;
|
||||
this.groupCount = 0;
|
||||
this.ac0 = 0;
|
||||
this.bsStructures = null;
|
||||
this.lastGroup = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.cif, "MMTFReader", J.adapter.readers.cif.MMCifReader);
|
||||
Clazz.overrideMethod (c$, "addHeader",
|
||||
function () {
|
||||
});
|
||||
Clazz.overrideMethod (c$, "setup",
|
||||
function (fullPath, htParams, reader) {
|
||||
this.isBinary = true;
|
||||
this.isMMCIF = true;
|
||||
this.iHaveFractionalCoordinates = false;
|
||||
this.setupASCR (fullPath, htParams, reader);
|
||||
}, "~S,java.util.Map,~O");
|
||||
Clazz.overrideMethod (c$, "processBinaryDocument",
|
||||
function () {
|
||||
var doDoubleBonds = (!this.isCourseGrained && !this.checkFilterKey ("NODOUBLE"));
|
||||
this.isDSSP1 = !this.checkFilterKey ("DSSP2");
|
||||
var mmtfImplementsDSSP2 = false;
|
||||
this.applySymmetryToBonds = true;
|
||||
this.map = ( new JU.MessagePackReader (this.binaryDoc, true)).readMap ();
|
||||
this.entities = this.map.get ("entityList");
|
||||
if (JU.Logger.debugging) {
|
||||
for (var s, $s = this.map.keySet ().iterator (); $s.hasNext () && ((s = $s.next ()) || true);) JU.Logger.info (s);
|
||||
|
||||
}this.asc.setInfo ("noAutoBond", Boolean.TRUE);
|
||||
JU.Logger.info ("MMTF version " + this.map.get ("mmtfVersion"));
|
||||
JU.Logger.info ("MMTF Producer " + this.map.get ("mmtfProducer"));
|
||||
var title = this.map.get ("title");
|
||||
if (title != null) this.appendLoadNote (title);
|
||||
this.$pdbID = this.map.get ("structureId");
|
||||
if (this.$pdbID == null) this.$pdbID = this.map.get ("pdbId");
|
||||
this.fileAtomCount = (this.map.get ("numAtoms")).intValue ();
|
||||
var nBonds = (this.map.get ("numBonds")).intValue ();
|
||||
this.groupCount = (this.map.get ("numGroups")).intValue ();
|
||||
this.groupModels = Clazz.newIntArray (this.groupCount, 0);
|
||||
this.groupDSSP = Clazz.newIntArray (this.groupCount, 0);
|
||||
this.groupMap = Clazz.newIntArray (this.groupCount, 0);
|
||||
var modelCount = (this.map.get ("numModels")).intValue ();
|
||||
this.appendLoadNote ("id=" + this.$pdbID + " numAtoms=" + this.fileAtomCount + " numBonds=" + nBonds + " numGroups=" + this.groupCount + " numModels=" + modelCount);
|
||||
this.getMMTFAtoms (doDoubleBonds);
|
||||
if (!this.isCourseGrained) {
|
||||
var bo = this.decode ("bondOrderList");
|
||||
var bi = this.decode ("bondAtomList");
|
||||
this.addMMTFBonds (bo, bi, 0, doDoubleBonds, true);
|
||||
if (this.isDSSP1 || mmtfImplementsDSSP2) this.getStructure ();
|
||||
}this.setMMTFSymmetry ();
|
||||
this.getMMTFBioAssembly ();
|
||||
this.setModelPDB (true);
|
||||
if (JU.Logger.debuggingHigh) JU.Logger.info (JS.SV.getVariable (this.map).asString ());
|
||||
});
|
||||
Clazz.defineMethod (c$, "applySymmetryAndSetTrajectory",
|
||||
function () {
|
||||
this.ac0 = this.ac;
|
||||
Clazz.superCall (this, J.adapter.readers.cif.MMTFReader, "applySymmetryAndSetTrajectory", []);
|
||||
if (this.haveStructure) this.addStructureSymmetry ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "getMMTFAtoms",
|
||||
function (doMulti) {
|
||||
var chainsPerModel = this.map.get ("chainsPerModel");
|
||||
var groupsPerChain = this.map.get ("groupsPerChain");
|
||||
this.labelAsymList = this.decode ("chainIdList");
|
||||
var authAsymList = this.decode ("chainNameList");
|
||||
var groupTypeList = this.decode ("groupTypeList");
|
||||
var groupIdList = this.decode ("groupIdList");
|
||||
var groupList = this.map.get ("groupList");
|
||||
var insCodes = this.decode ("insCodeList");
|
||||
var atomId = this.decode ("atomIdList");
|
||||
var haveSerial = (atomId != null);
|
||||
var altloc = this.decode ("altLocList");
|
||||
var occ = this.decode ("occupancyList");
|
||||
var x = this.decode ("xCoordList");
|
||||
var y = this.decode ("yCoordList");
|
||||
var z = this.decode ("zCoordList");
|
||||
var bf = this.decode ("bFactorList");
|
||||
var nameList = (this.useAuthorChainID ? authAsymList : this.labelAsymList);
|
||||
var iModel = -1;
|
||||
var iChain = 0;
|
||||
var nChain = 0;
|
||||
var iGroup = 0;
|
||||
var nGroup = 0;
|
||||
var chainpt = 0;
|
||||
var seqNo = 0;
|
||||
var iatom = 0;
|
||||
var chainID = "";
|
||||
var authAsym = "";
|
||||
var labelAsym = "";
|
||||
var insCode = '\u0000';
|
||||
this.atomMap = new Array (this.fileAtomCount);
|
||||
this.atomGroup = Clazz.newIntArray (this.fileAtomCount, 0);
|
||||
for (var j = 0, thisGroup = -1; j < this.groupCount; j++) {
|
||||
if (++iGroup >= nGroup) {
|
||||
chainID = nameList[chainpt];
|
||||
authAsym = authAsymList[chainpt];
|
||||
labelAsym = this.labelAsymList[chainpt];
|
||||
nGroup = groupsPerChain[chainpt++];
|
||||
iGroup = 0;
|
||||
if (++iChain >= nChain) {
|
||||
this.groupModels[j] = ++iModel;
|
||||
nChain = chainsPerModel[iModel];
|
||||
iChain = 0;
|
||||
this.setModelPDB (true);
|
||||
this.incrementModel (iModel + 1);
|
||||
this.asc.setCurrentModelInfo ("pdbID", this.$pdbID);
|
||||
this.nAtoms0 = this.asc.ac;
|
||||
if (this.done) return;
|
||||
}}var g = groupList[groupTypeList[j]];
|
||||
var atomNameList = g.get ("atomNameList");
|
||||
var len = atomNameList.length;
|
||||
if (this.skipping) {
|
||||
iatom += len;
|
||||
continue;
|
||||
}var a0 = iatom;
|
||||
if (insCodes != null) insCode = insCodes[j];
|
||||
seqNo = groupIdList[j];
|
||||
var group3 = g.get ("groupName");
|
||||
var isHetero = this.vwr.getJBR ().isHetero (group3);
|
||||
if (isHetero) {
|
||||
var hetName = "" + g.get ("chemCompType");
|
||||
if (this.htHetero == null || !this.htHetero.containsKey (group3)) {
|
||||
if (this.entities != null && hetName.equals ("NON-POLYMER")) out : for (var i = this.entities.length; --i >= 0; ) {
|
||||
var entity = this.entities[i];
|
||||
var chainList = entity.get ("chainIndexList");
|
||||
for (var k = chainList.length; --k >= 0; ) if (chainList[k] == iChain) {
|
||||
hetName = "a component of the entity \"" + entity.get ("description") + "\"";
|
||||
break out;
|
||||
}
|
||||
}
|
||||
this.addHetero (group3, hetName, false, true);
|
||||
}}var elementList = g.get ("elementList");
|
||||
var haveAtom = false;
|
||||
for (var ia = 0, pt = 0; ia < len; ia++, iatom++) {
|
||||
var a = new J.adapter.smarter.Atom ();
|
||||
a.isHetero = isHetero;
|
||||
if (insCode.charCodeAt (0) != 0) a.insertionCode = insCode;
|
||||
this.setAtomCoordXYZ (a, x[iatom], y[iatom], z[iatom]);
|
||||
a.elementSymbol = elementList[pt];
|
||||
a.atomName = atomNameList[pt++];
|
||||
if (seqNo >= 0) this.maxSerial = Math.max (this.maxSerial, a.sequenceNumber = seqNo);
|
||||
a.group3 = group3;
|
||||
this.setChainID (a, chainID);
|
||||
if (bf != null) a.bfactor = bf[iatom];
|
||||
if (altloc != null) a.altLoc = altloc[iatom];
|
||||
if (occ != null) a.foccupancy = occ[iatom];
|
||||
if (haveSerial) a.atomSerial = atomId[iatom];
|
||||
if (!this.filterAtom (a, -1) || !this.processSubclassAtom (a, labelAsym, authAsym)) continue;
|
||||
if (!haveAtom) {
|
||||
thisGroup++;
|
||||
haveAtom = true;
|
||||
}if (haveSerial) {
|
||||
this.asc.addAtomWithMappedSerialNumber (a);
|
||||
} else {
|
||||
this.asc.addAtom (a);
|
||||
}this.atomMap[iatom] = a;
|
||||
this.atomGroup[this.ac] = j;
|
||||
this.groupMap[j] = this.lastGroup = thisGroup;
|
||||
this.ac++;
|
||||
}
|
||||
if (!this.isCourseGrained) {
|
||||
var bo = g.get ("bondOrderList");
|
||||
var bi = g.get ("bondAtomList");
|
||||
this.addMMTFBonds (bo, bi, a0, doMulti, false);
|
||||
}}
|
||||
this.asc.setCurrentModelInfo ("pdbID", this.$pdbID);
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "addMMTFBonds",
|
||||
function (bo, bi, a0, doMulti, isInter) {
|
||||
if (bi == null) return;
|
||||
doMulti = new Boolean (doMulti & (bo != null)).valueOf ();
|
||||
for (var bj = 0, pt = 0, nj = Clazz.doubleToInt (bi.length / 2); bj < nj; bj++) {
|
||||
var a1 = this.atomMap[bi[pt++] + a0];
|
||||
var a2 = this.atomMap[bi[pt++] + a0];
|
||||
if (a1 != null && a2 != null) {
|
||||
var bond = new J.adapter.smarter.Bond (a1.index, a2.index, doMulti ? bo[bj] : 1);
|
||||
this.asc.addBond (bond);
|
||||
if (JU.Logger.debugging && isInter) {
|
||||
JU.Logger.info ("inter-group (" + (a1.atomSetIndex + 1) + "." + a1.index + "/" + (a2.atomSetIndex + 1) + "." + a2.index + ") bond " + a1.group3 + a1.sequenceNumber + "." + a1.atomName + " - " + a2.group3 + a2.sequenceNumber + "." + a2.atomName + " " + bond.order);
|
||||
}}}
|
||||
}, "~A,~A,~N,~B,~B");
|
||||
Clazz.defineMethod (c$, "setMMTFSymmetry",
|
||||
function () {
|
||||
this.setSpaceGroupName (this.map.get ("spaceGroup"));
|
||||
var o = this.map.get ("unitCell");
|
||||
if (o != null) for (var i = 0; i < 6; i++) this.setUnitCellItem (i, o[i]);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "getMMTFBioAssembly",
|
||||
function () {
|
||||
var o = this.map.get ("bioAssemblyList");
|
||||
if (o == null) return;
|
||||
if (this.vBiomolecules == null) this.vBiomolecules = new JU.Lst ();
|
||||
for (var i = o.length; --i >= 0; ) {
|
||||
var info = new java.util.Hashtable ();
|
||||
this.vBiomolecules.addLast (info);
|
||||
var iMolecule = i + 1;
|
||||
this.checkFilterAssembly ("" + iMolecule, info);
|
||||
info.put ("name", "biomolecule " + iMolecule);
|
||||
info.put ("molecule", Integer.$valueOf (iMolecule));
|
||||
var assemb = new JU.Lst ();
|
||||
var ops = new JU.Lst ();
|
||||
info.put ("biomts", new JU.Lst ());
|
||||
info.put ("chains", new JU.Lst ());
|
||||
info.put ("assemblies", assemb);
|
||||
info.put ("operators", ops);
|
||||
var m = o[i];
|
||||
var tlist = m.get ("transformList");
|
||||
var chlist = new JU.SB ();
|
||||
for (var j = 0, n = tlist.length; j < n; j++) {
|
||||
var t = tlist[j];
|
||||
chlist.setLength (0);
|
||||
var chainList = t.get ("chainIndexList");
|
||||
for (var k = 0, kn = chainList.length; k < kn; k++) chlist.append ("$").append (this.labelAsymList[chainList[k]]);
|
||||
|
||||
assemb.addLast (chlist.append ("$").toString ());
|
||||
var id = "" + (++this.opCount);
|
||||
this.addMatrix (id, JU.M4.newA16 (t.get ("matrix")), false);
|
||||
ops.addLast (id);
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getStructure",
|
||||
function () {
|
||||
var a = this.decode ("secStructList");
|
||||
if (JU.Logger.debugging) JU.Logger.info (JU.PT.toJSON ("secStructList", a));
|
||||
this.bsStructures = Clazz.newArray (-1, [ new JU.BS (), null, new JU.BS (), new JU.BS (), new JU.BS (), null, new JU.BS ()]);
|
||||
var lastGroup = -1;
|
||||
for (var j = 0; j < a.length; j++) {
|
||||
var type = a[j];
|
||||
switch (type) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 6:
|
||||
var igroup = this.groupMap[j];
|
||||
this.bsStructures[type].set (igroup);
|
||||
this.groupDSSP[igroup] = type + 1;
|
||||
lastGroup = j;
|
||||
}
|
||||
}
|
||||
var n = (this.isDSSP1 ? this.asc.iSet : this.groupModels[lastGroup]);
|
||||
if (lastGroup >= 0) {
|
||||
this.haveStructure = true;
|
||||
this.asc.addStructure ( new J.adapter.smarter.Structure (n, null, null, null, 0, 0, this.bsStructures));
|
||||
}});
|
||||
Clazz.defineMethod (c$, "addStructureSymmetry",
|
||||
function () {
|
||||
if (this.asc.ac == 0) return;
|
||||
var atoms = this.asc.atoms;
|
||||
var bsAtoms = this.asc.bsAtoms;
|
||||
var ptGroup = this.lastGroup;
|
||||
var mygroup = -1;
|
||||
for (var i = this.ac0, n = this.asc.ac; i < n; i++) {
|
||||
if (bsAtoms == null || bsAtoms.get (i)) {
|
||||
var a = atoms[i];
|
||||
var igroup = this.atomGroup[a.atomSite];
|
||||
if (igroup != mygroup) {
|
||||
mygroup = igroup;
|
||||
ptGroup++;
|
||||
}var dssp = this.groupDSSP[igroup];
|
||||
if (dssp > 0) {
|
||||
this.bsStructures[dssp - 1].set (ptGroup);
|
||||
}}}
|
||||
});
|
||||
Clazz.defineMethod (c$, "decode",
|
||||
function (key) {
|
||||
return JU.MessagePackReader.decode (this.map.get (key));
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,367 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.cif");
|
||||
Clazz.load (["J.adapter.readers.cif.MSRdr"], "J.adapter.readers.cif.MSCifParser", ["java.lang.Character", "$.Double", "JU.M3", "$.Matrix", "$.PT"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.field = null;
|
||||
this.comSSMat = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.cif, "MSCifParser", J.adapter.readers.cif.MSRdr);
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.cif.MSCifParser, []);
|
||||
});
|
||||
Clazz.defineMethod (c$, "processEntry",
|
||||
function () {
|
||||
var cr = this.cr;
|
||||
if (cr.key.equals ("_cell_commen_t_section_1")) {
|
||||
this.isCommensurate = true;
|
||||
this.commensurateSection1 = cr.parseIntStr (cr.data);
|
||||
}if (cr.key.startsWith ("_cell_commen_supercell_matrix")) {
|
||||
this.isCommensurate = true;
|
||||
if (this.comSSMat == null) this.comSSMat = JU.M3.newM3 (null);
|
||||
var tokens = JU.PT.split (cr.key, "_");
|
||||
var r = cr.parseIntStr (tokens[tokens.length - 2]);
|
||||
var c = cr.parseIntStr (tokens[tokens.length - 1]);
|
||||
if (r > 0 && c > 0) this.comSSMat.setElement (r - 1, c - 1, cr.parseFloatStr (cr.data));
|
||||
}});
|
||||
Clazz.defineMethod (c$, "processLoopBlock",
|
||||
function () {
|
||||
var cr = this.cr;
|
||||
var key = cr.key;
|
||||
if (key.equals ("_cell_subsystem_code")) return this.processSubsystemLoopBlock ();
|
||||
if (!key.startsWith ("_cell_wave") && !key.contains ("fourier") && !key.contains ("legendre") && !key.contains ("_special_func")) {
|
||||
if (key.contains ("crenel_ortho")) cr.appendLoadNote ("WARNING: Orthogonalized non-Legendre functions not supported.\nThe following block has been ignored. Use Legendre functions instead.\n\n" + cr.parser.skipLoop (true) + "=================================\n");
|
||||
return 0;
|
||||
}if (cr.asc.iSet < 0) cr.asc.newAtomSet ();
|
||||
cr.parseLoopParametersFor ("_atom_site", J.adapter.readers.cif.MSCifParser.modulationFields);
|
||||
var tok;
|
||||
if (cr.key2col[8] != -1) {
|
||||
cr.key2col[5] = cr.key2col[6] = cr.key2col[7] = -1;
|
||||
}while (cr.parser.getData ()) {
|
||||
var ignore = false;
|
||||
var type_id = null;
|
||||
var atomLabel = null;
|
||||
var axis = null;
|
||||
var pt = Clazz.newDoubleArray (-1, [NaN, NaN, NaN]);
|
||||
var c = NaN;
|
||||
var w = NaN;
|
||||
var fid = null;
|
||||
var n = cr.parser.getColumnCount ();
|
||||
for (var i = 0; i < n; ++i) {
|
||||
switch (tok = this.fieldProperty (cr, i)) {
|
||||
case 1:
|
||||
cr.haveCellWaveVector = true;
|
||||
case 0:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
pt[0] = pt[1] = pt[2] = 0;
|
||||
case 13:
|
||||
case 25:
|
||||
case 50:
|
||||
case 35:
|
||||
case 43:
|
||||
case 44:
|
||||
case 45:
|
||||
switch (tok) {
|
||||
case 1:
|
||||
type_id = "W_";
|
||||
break;
|
||||
case 0:
|
||||
type_id = "F_";
|
||||
break;
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
fid = "?" + this.field;
|
||||
pt[2] = 1;
|
||||
continue;
|
||||
case 43:
|
||||
case 44:
|
||||
case 45:
|
||||
atomLabel = axis = "*";
|
||||
case 13:
|
||||
case 25:
|
||||
case 50:
|
||||
case 35:
|
||||
type_id = Character.toUpperCase (J.adapter.readers.cif.MSCifParser.modulationFields[tok].charAt (11)) + "_";
|
||||
break;
|
||||
}
|
||||
type_id += this.field;
|
||||
break;
|
||||
case 46:
|
||||
type_id = "J_O";
|
||||
pt[0] = pt[2] = 1;
|
||||
axis = "0";
|
||||
atomLabel = this.field;
|
||||
break;
|
||||
case 30:
|
||||
type_id = "O_0";
|
||||
axis = "0";
|
||||
atomLabel = this.field;
|
||||
break;
|
||||
case 18:
|
||||
type_id = "D_S";
|
||||
axis = "0";
|
||||
atomLabel = this.field;
|
||||
break;
|
||||
case 55:
|
||||
type_id = "M_T";
|
||||
axis = "0";
|
||||
atomLabel = this.field;
|
||||
break;
|
||||
case 61:
|
||||
type_id = "D_L";
|
||||
atomLabel = this.field;
|
||||
break;
|
||||
case 65:
|
||||
type_id = "U_L";
|
||||
atomLabel = this.field;
|
||||
break;
|
||||
case 69:
|
||||
type_id = "O_L";
|
||||
atomLabel = this.field;
|
||||
break;
|
||||
case 11:
|
||||
case 24:
|
||||
case 48:
|
||||
case 33:
|
||||
atomLabel = this.field;
|
||||
break;
|
||||
case 12:
|
||||
case 49:
|
||||
case 62:
|
||||
axis = this.field;
|
||||
if (this.modAxes != null && this.modAxes.indexOf (axis.toUpperCase ()) < 0) ignore = true;
|
||||
break;
|
||||
case 66:
|
||||
case 34:
|
||||
axis = this.field.toUpperCase ();
|
||||
break;
|
||||
default:
|
||||
var f = cr.parseFloatStr (this.field);
|
||||
switch (tok) {
|
||||
case 64:
|
||||
case 71:
|
||||
case 68:
|
||||
pt[0] = f;
|
||||
if (f != 0) pt[2] = 0;
|
||||
break;
|
||||
case 27:
|
||||
case 31:
|
||||
case 15:
|
||||
case 52:
|
||||
case 37:
|
||||
case 77:
|
||||
case 73:
|
||||
case 75:
|
||||
pt[2] = 0;
|
||||
case 2:
|
||||
case 5:
|
||||
case 19:
|
||||
case 56:
|
||||
pt[0] = f;
|
||||
break;
|
||||
case 8:
|
||||
type_id += "_coefs_";
|
||||
pt = Clazz.newDoubleArray (this.modDim, 0);
|
||||
pt[0] = f;
|
||||
break;
|
||||
case 16:
|
||||
case 28:
|
||||
case 53:
|
||||
case 38:
|
||||
pt[0] = f;
|
||||
pt[2] = 1;
|
||||
break;
|
||||
case 70:
|
||||
case 74:
|
||||
case 26:
|
||||
axis = "0";
|
||||
case 63:
|
||||
case 67:
|
||||
case 3:
|
||||
case 6:
|
||||
case 9:
|
||||
case 17:
|
||||
case 29:
|
||||
case 54:
|
||||
case 39:
|
||||
case 32:
|
||||
case 20:
|
||||
case 57:
|
||||
case 47:
|
||||
case 14:
|
||||
case 51:
|
||||
case 36:
|
||||
case 72:
|
||||
case 76:
|
||||
pt[1] = f;
|
||||
break;
|
||||
case 4:
|
||||
case 7:
|
||||
case 10:
|
||||
case 21:
|
||||
case 58:
|
||||
pt[2] = f;
|
||||
break;
|
||||
case 22:
|
||||
case 59:
|
||||
c = f;
|
||||
break;
|
||||
case 23:
|
||||
case 60:
|
||||
w = f;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ignore || type_id == null || atomLabel != null && !atomLabel.equals ("*") && cr.rejectAtomName (atomLabel)) continue;
|
||||
var ok = true;
|
||||
for (var j = 0, nzero = pt.length; j < pt.length; j++) if (Double.isNaN (pt[j]) || pt[j] > 1e100 || pt[j] == 0 && --nzero == 0) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
if (!ok) continue;
|
||||
switch (type_id.charAt (0)) {
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'O':
|
||||
case 'M':
|
||||
case 'U':
|
||||
case 'J':
|
||||
if (atomLabel == null || axis == null) continue;
|
||||
if (type_id.equals ("D_S") || type_id.equals ("M_T")) {
|
||||
if (Double.isNaN (c) || Double.isNaN (w)) continue;
|
||||
if (pt[0] != 0) this.addMod (type_id + "#x;" + atomLabel, fid, Clazz.newDoubleArray (-1, [c, w, pt[0]]));
|
||||
if (pt[1] != 0) this.addMod (type_id + "#y;" + atomLabel, fid, Clazz.newDoubleArray (-1, [c, w, pt[1]]));
|
||||
if (pt[2] != 0) this.addMod (type_id + "#z;" + atomLabel, fid, Clazz.newDoubleArray (-1, [c, w, pt[2]]));
|
||||
continue;
|
||||
}if (type_id.indexOf ("_L") == 1) {
|
||||
if (type_id.startsWith ("U")) type_id += Clazz.doubleToInt (pt[1]);
|
||||
else axis += Clazz.doubleToInt (pt[1]);
|
||||
}type_id += "#" + axis + ";" + atomLabel;
|
||||
break;
|
||||
}
|
||||
this.addMod (type_id, fid, pt);
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
Clazz.defineMethod (c$, "addMod",
|
||||
function (id, fid, params) {
|
||||
if (fid != null) id += fid;
|
||||
this.addModulation (null, id, params, -1);
|
||||
}, "~S,~S,~A");
|
||||
Clazz.defineMethod (c$, "processSubsystemLoopBlock",
|
||||
function () {
|
||||
var cr = this.cr;
|
||||
cr.parseLoopParameters (null);
|
||||
while (cr.parser.getData ()) {
|
||||
this.fieldProperty (cr, 0);
|
||||
var id = this.field;
|
||||
this.addSubsystem (id, this.getSparseMatrix (cr, "_w_", 1, 3 + this.modDim));
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getSparseMatrix",
|
||||
function (cr, term, i, dim) {
|
||||
var m = new JU.Matrix (null, dim, dim);
|
||||
var a = m.getArray ();
|
||||
var key;
|
||||
var p;
|
||||
var n = cr.parser.getColumnCount ();
|
||||
for (; i < n; ++i) {
|
||||
if ((p = this.fieldProperty (cr, i)) < 0 || !(key = cr.parser.getColumnName (p)).contains (term)) continue;
|
||||
var tokens = JU.PT.split (key, "_");
|
||||
var r = cr.parseIntStr (tokens[tokens.length - 2]);
|
||||
var c = cr.parseIntStr (tokens[tokens.length - 1]);
|
||||
if (r > 0 && c > 0) a[r - 1][c - 1] = cr.parseFloatStr (this.field);
|
||||
}
|
||||
return m;
|
||||
}, "J.adapter.readers.cif.CifReader,~S,~N,~N");
|
||||
Clazz.defineMethod (c$, "fieldProperty",
|
||||
function (cr, i) {
|
||||
return ((this.field = cr.parser.getColumnData (i)).length > 0 && this.field.charAt (0) != '\0' ? cr.col2key[i] : -1);
|
||||
}, "J.adapter.readers.cif.CifReader,~N");
|
||||
Clazz.defineStatics (c$,
|
||||
"FWV_ID", 0,
|
||||
"WV_ID", 1,
|
||||
"WV_X", 2,
|
||||
"WV_Y", 3,
|
||||
"WV_Z", 4,
|
||||
"FWV_X", 5,
|
||||
"FWV_Y", 6,
|
||||
"FWV_Z", 7,
|
||||
"JANA_FWV_Q1_COEF", 8,
|
||||
"JANA_FWV_Q2_COEF", 9,
|
||||
"JANA_FWV_Q3_COEF", 10,
|
||||
"FWV_DISP_LABEL", 11,
|
||||
"FWV_DISP_AXIS", 12,
|
||||
"FWV_DISP_SEQ_ID", 13,
|
||||
"FWV_DISP_COS", 14,
|
||||
"FWV_DISP_SIN", 15,
|
||||
"FWV_DISP_MODULUS", 16,
|
||||
"FWV_DISP_PHASE", 17,
|
||||
"DISP_SPEC_LABEL", 18,
|
||||
"DISP_SAW_AX", 19,
|
||||
"DISP_SAW_AY", 20,
|
||||
"DISP_SAW_AZ", 21,
|
||||
"DISP_SAW_C", 22,
|
||||
"DISP_SAW_W", 23,
|
||||
"FWV_OCC_LABEL", 24,
|
||||
"FWV_OCC_SEQ_ID", 25,
|
||||
"FWV_OCC_COS", 26,
|
||||
"FWV_OCC_SIN", 27,
|
||||
"FWV_OCC_MODULUS", 28,
|
||||
"FWV_OCC_PHASE", 29,
|
||||
"OCC_SPECIAL_LABEL", 30,
|
||||
"OCC_CRENEL_C", 31,
|
||||
"OCC_CRENEL_W", 32,
|
||||
"FWV_U_LABEL", 33,
|
||||
"FWV_U_TENS", 34,
|
||||
"FWV_U_SEQ_ID", 35,
|
||||
"FWV_U_COS", 36,
|
||||
"FWV_U_SIN", 37,
|
||||
"FWV_U_MODULUS", 38,
|
||||
"FWV_U_PHASE", 39,
|
||||
"FD_ID", 40,
|
||||
"FO_ID", 41,
|
||||
"FU_ID", 42,
|
||||
"FDP_ID", 43,
|
||||
"FOP_ID", 44,
|
||||
"FUP_ID", 45,
|
||||
"JANA_OCC_ABS_LABEL", 46,
|
||||
"JANA_OCC_ABS_O_0", 47,
|
||||
"FWV_SPIN_LABEL", 48,
|
||||
"FWV_SPIN_AXIS", 49,
|
||||
"FWV_SPIN_SEQ_ID", 50,
|
||||
"FWV_SPIN_COS", 51,
|
||||
"FWV_SPIN_SIN", 52,
|
||||
"FWV_SPIN_MODULUS", 53,
|
||||
"FWV_SPIN_PHASE", 54,
|
||||
"SPIN_SPEC_LABEL", 55,
|
||||
"SPIN_SAW_AX", 56,
|
||||
"SPIN_SAW_AY", 57,
|
||||
"SPIN_SAW_AZ", 58,
|
||||
"SPIN_SAW_C", 59,
|
||||
"SPIN_SAW_W", 60,
|
||||
"LEG_DISP_LABEL", 61,
|
||||
"LEG_DISP_AXIS", 62,
|
||||
"LEG_DISP_ORDER", 63,
|
||||
"LEG_DISP_COEF", 64,
|
||||
"LEG_U_LABEL", 65,
|
||||
"LEG_U_TENS", 66,
|
||||
"LEG_U_ORDER", 67,
|
||||
"LEG_U_COEF", 68,
|
||||
"LEG_OCC_LABEL", 69,
|
||||
"LEG_OCC_ORDER", 70,
|
||||
"LEG_OCC_COEF", 71,
|
||||
"DEPR_FD_COS", 72,
|
||||
"DEPR_FD_SIN", 73,
|
||||
"DEPR_FO_COS", 74,
|
||||
"DEPR_FO_SIN", 75,
|
||||
"DEPR_FU_COS", 76,
|
||||
"DEPR_FU_SIN", 77,
|
||||
"modulationFields", Clazz.newArray (-1, ["*_fourier_wave_vector_seq_id", "_cell_wave_vector_seq_id", "_cell_wave_vector_x", "_cell_wave_vector_y", "_cell_wave_vector_z", "*_fourier_wave_vector_x", "*_fourier_wave_vector_y", "*_fourier_wave_vector_z", "*_fourier_wave_vector_q1_coeff", "*_fourier_wave_vector_q2_coeff", "*_fourier_wave_vector_q3_coeff", "*_displace_fourier_atom_site_label", "*_displace_fourier_axis", "*_displace_fourier_wave_vector_seq_id", "*_displace_fourier_param_cos", "*_displace_fourier_param_sin", "*_displace_fourier_param_modulus", "*_displace_fourier_param_phase", "*_displace_special_func_atom_site_label", "*_displace_special_func_sawtooth_ax", "*_displace_special_func_sawtooth_ay", "*_displace_special_func_sawtooth_az", "*_displace_special_func_sawtooth_c", "*_displace_special_func_sawtooth_w", "*_occ_fourier_atom_site_label", "*_occ_fourier_wave_vector_seq_id", "*_occ_fourier_param_cos", "*_occ_fourier_param_sin", "*_occ_fourier_param_modulus", "*_occ_fourier_param_phase", "*_occ_special_func_atom_site_label", "*_occ_special_func_crenel_c", "*_occ_special_func_crenel_w", "*_u_fourier_atom_site_label", "*_u_fourier_tens_elem", "*_u_fourier_wave_vector_seq_id", "*_u_fourier_param_cos", "*_u_fourier_param_sin", "*_u_fourier_param_modulus", "*_u_fourier_param_phase", "*_displace_fourier_id", "*_occ_fourier_id", "*_u_fourier_id", "*_displace_fourier_param_id", "*_occ_fourier_param_id", "*_u_fourier_param_id", "*_occ_fourier_absolute_site_label", "*_occ_fourier_absolute", "*_moment_fourier_atom_site_label", "*_moment_fourier_axis", "*_moment_fourier_wave_vector_seq_id", "*_moment_fourier_param_cos", "*_moment_fourier_param_sin", "*_moment_fourier_param_modulus", "*_moment_fourier_param_phase", "*_moment_special_func_atom_site_label", "*_moment_special_func_sawtooth_ax", "*_moment_special_func_sawtooth_ay", "*_moment_special_func_sawtooth_az", "*_moment_special_func_sawtooth_c", "*_moment_special_func_sawtooth_w", "*_displace_legendre_atom_site_label", "*_displace_legendre_axis", "*_displace_legendre_param_order", "*_displace_legendre_param_coeff", "*_u_legendre_atom_site_label", "*_u_legendre_tens_elem", "*_u_legendre_param_order", "*_u_legendre_param_coeff", "*_occ_legendre_atom_site_label", "*_occ_legendre_param_order", "*_occ_legendre_param_coeff", "*_displace_fourier_cos", "*_displace_fourier_sin", "*_occ_fourier_cos", "*_occ_fourier_sin", "*_u_fourier_cos", "*_u_fourier_sin"]),
|
||||
"NONE", -1);
|
||||
});
|
||||
@@ -0,0 +1,593 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.cif");
|
||||
Clazz.load (["J.adapter.smarter.MSInterface"], "J.adapter.readers.cif.MSRdr", ["java.lang.Boolean", "$.Exception", "$.Float", "java.util.Hashtable", "JU.Lst", "$.M3", "$.Matrix", "$.P3", "$.PT", "J.adapter.readers.cif.Subsystem", "J.adapter.smarter.AtomSetCollectionReader", "JU.BSUtil", "$.BoxInfo", "$.Escape", "$.Logger", "$.Modulation", "$.ModulationSet", "$.Vibration"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.cr = null;
|
||||
this.modDim = 0;
|
||||
this.modAxes = null;
|
||||
this.modAverage = false;
|
||||
this.isCommensurate = false;
|
||||
this.commensurateSection1 = 0;
|
||||
this.modPack = false;
|
||||
this.modVib = false;
|
||||
this.modType = null;
|
||||
this.modCell = null;
|
||||
this.modDebug = false;
|
||||
this.modSelected = -1;
|
||||
this.modLast = false;
|
||||
this.sigma = null;
|
||||
this.htModulation = null;
|
||||
this.htAtomMods = null;
|
||||
this.iopLast = -1;
|
||||
this.gammaE = null;
|
||||
this.nOps = 0;
|
||||
this.haveOccupancy = false;
|
||||
this.atoms = null;
|
||||
this.ac = 0;
|
||||
this.haveAtomMods = false;
|
||||
this.modCoord = false;
|
||||
this.finalized = false;
|
||||
this.symmetry = null;
|
||||
this.supercellSymmetry = null;
|
||||
this.legendres = null;
|
||||
this.atModel = "@0";
|
||||
this.modMatrices = null;
|
||||
this.qlist100 = null;
|
||||
this.qs = null;
|
||||
this.modCount = 0;
|
||||
this.modTUV = null;
|
||||
this.htSubsystems = null;
|
||||
this.minXYZ0 = null;
|
||||
this.maxXYZ0 = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.cif, "MSRdr", null, J.adapter.smarter.MSInterface);
|
||||
Clazz.defineMethod (c$, "getSigma",
|
||||
function () {
|
||||
return this.sigma;
|
||||
});
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initialize",
|
||||
function (r, modDim) {
|
||||
this.cr = r;
|
||||
this.modCoord = r.checkFilterKey ("MODCOORD");
|
||||
this.modDebug = r.checkFilterKey ("MODDEBUG");
|
||||
this.modPack = !r.checkFilterKey ("MODNOPACK");
|
||||
this.modLast = r.checkFilterKey ("MODLAST");
|
||||
this.modAxes = r.getFilter ("MODAXES=");
|
||||
this.modType = r.getFilter ("MODTYPE=");
|
||||
this.modCell = r.getFilter ("MODCELL=");
|
||||
this.modSelected = r.parseIntStr ("" + r.getFilter ("MOD="));
|
||||
this.modVib = r.checkFilterKey ("MODVIB");
|
||||
this.modAverage = r.checkFilterKey ("MODAVE");
|
||||
var smodTUV = r.getFilter ("MODT=");
|
||||
if (smodTUV != null || (smodTUV = r.getFilter ("MODTUV=")) != null) {
|
||||
this.modTUV = new JU.P3 ();
|
||||
var tuv = (JU.PT.replaceAllCharacters (smodTUV, "{}()", "") + ",0,0,0").$plit (",");
|
||||
this.modTUV.x = JU.PT.parseFloatFraction (tuv[0]);
|
||||
this.modTUV.y = JU.PT.parseFloatFraction (tuv[1]);
|
||||
this.modTUV.z = JU.PT.parseFloatFraction (tuv[2]);
|
||||
if (Float.isNaN (this.modTUV.lengthSquared ())) {
|
||||
JU.Logger.error ("MSRdr cannot read modTUV=" + smodTUV);
|
||||
this.modTUV = null;
|
||||
}}this.setModDim (modDim);
|
||||
return modDim;
|
||||
}, "J.adapter.smarter.AtomSetCollectionReader,~N");
|
||||
Clazz.defineMethod (c$, "setSubsystemOptions",
|
||||
function () {
|
||||
this.cr.forceSymmetry (this.modPack);
|
||||
if (this.modCell != null) this.cr.addJmolScript ("unitcell {%" + this.modCell + "}");
|
||||
});
|
||||
Clazz.defineMethod (c$, "setModDim",
|
||||
function (ndim) {
|
||||
this.htModulation = new java.util.Hashtable ();
|
||||
this.modDim = ndim;
|
||||
this.cr.appendLoadNote ("Modulation dimension = " + this.modDim);
|
||||
}, "~N");
|
||||
Clazz.overrideMethod (c$, "addModulation",
|
||||
function (map, id, pt, iModel) {
|
||||
var ch = id.charAt (0);
|
||||
switch (ch) {
|
||||
case 'O':
|
||||
case 'D':
|
||||
case 'M':
|
||||
case 'U':
|
||||
if (this.modType != null && this.modType.indexOf (ch) < 0 || this.modSelected > 0 && this.modSelected != 1) return;
|
||||
break;
|
||||
}
|
||||
var isOK = false;
|
||||
for (var i = pt.length; --i >= 0; ) {
|
||||
if (this.modSelected > 0 && i + 1 != this.modSelected && id.contains ("_coefs_")) {
|
||||
pt[i] = 0;
|
||||
} else if (pt[i] != 0) {
|
||||
isOK = true;
|
||||
break;
|
||||
}}
|
||||
if (!isOK) return;
|
||||
if (map == null) map = this.htModulation;
|
||||
if (id.indexOf ("@") < 0) id += "@" + (iModel >= 0 ? iModel : this.cr.asc.iSet);
|
||||
if (id.startsWith ("D_L#") || id.startsWith ("U_L")) {
|
||||
if (this.legendres == null) this.legendres = new JU.Lst ();
|
||||
this.legendres.addLast (id);
|
||||
}JU.Logger.info ("Adding " + id + " " + JU.Escape.e (pt));
|
||||
map.put (id, pt);
|
||||
}, "java.util.Map,~S,~A,~N");
|
||||
Clazz.overrideMethod (c$, "setModulation",
|
||||
function (isPost, symmetry) {
|
||||
if (this.modDim == 0 || this.htModulation == null) return;
|
||||
if (this.modDebug) JU.Logger.debugging = JU.Logger.debuggingHigh = true;
|
||||
this.cr.asc.setInfo ("someModelsAreModulated", Boolean.TRUE);
|
||||
this.symmetry = symmetry;
|
||||
this.setModulationForStructure (this.cr.asc.iSet, isPost);
|
||||
if (this.modDebug) JU.Logger.debugging = JU.Logger.debuggingHigh = false;
|
||||
}, "~B,J.api.SymmetryInterface");
|
||||
Clazz.overrideMethod (c$, "finalizeModulation",
|
||||
function () {
|
||||
if (!this.finalized && this.modDim > 0 && !this.modVib) {
|
||||
if (this.modTUV != null) this.cr.appendLoadNote ("modTUV=" + this.modTUV);
|
||||
this.cr.asc.setInfo ("modulationOn", this.modTUV == null ? Boolean.TRUE : this.modTUV);
|
||||
this.cr.addJmolScript ("set modulateOccupancy " + (this.haveOccupancy && !this.isCommensurate ? true : false));
|
||||
}this.finalized = true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "checkKey",
|
||||
function (key, checkQ) {
|
||||
var pt = key.indexOf (this.atModel);
|
||||
return (pt < 0 || key.indexOf ("_pos#") >= 0 || key.indexOf ("*;*") >= 0 || checkQ && key.indexOf ("?") >= 0 ? null : key.substring (0, pt));
|
||||
}, "~S,~B");
|
||||
Clazz.overrideMethod (c$, "getMod",
|
||||
function (key) {
|
||||
return this.htModulation.get (key + this.atModel);
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "getModulationMap",
|
||||
function () {
|
||||
return this.htModulation;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setModulationForStructure",
|
||||
function (iModel, isPost) {
|
||||
this.atModel = "@" + iModel;
|
||||
if (this.htModulation.containsKey ("X_" + this.atModel)) return;
|
||||
if (!isPost) {
|
||||
this.initModForStructure (iModel);
|
||||
return;
|
||||
}this.htModulation.put ("X_" + this.atModel, Clazz.newDoubleArray (0, 0));
|
||||
this.cr.appendLoadNote (this.modCount + " modulations for " + this.ac + " modulated atoms");
|
||||
if (!this.haveAtomMods) return;
|
||||
var n = this.cr.asc.ac;
|
||||
this.atoms = this.cr.asc.atoms;
|
||||
if (this.symmetry != null) this.nOps = this.symmetry.getSpaceGroupOperationCount ();
|
||||
this.supercellSymmetry = this.cr.asc.getXSymmetry ().symmetry;
|
||||
if (this.supercellSymmetry === this.symmetry) this.supercellSymmetry = null;
|
||||
this.iopLast = -1;
|
||||
var i0 = this.cr.asc.getLastAtomSetAtomIndex ();
|
||||
for (var i = i0; i < n; i++) this.modulateAtom (this.atoms[i]);
|
||||
|
||||
this.htAtomMods = null;
|
||||
if (this.minXYZ0 != null) this.trimAtomSet ();
|
||||
this.htSubsystems = null;
|
||||
}, "~N,~B");
|
||||
Clazz.defineMethod (c$, "initModForStructure",
|
||||
function (iModel) {
|
||||
var key;
|
||||
if (this.legendres != null) this.fixLegendre ();
|
||||
this.sigma = new JU.Matrix (null, this.modDim, 3);
|
||||
this.qs = null;
|
||||
this.modMatrices = Clazz.newArray (-1, [this.sigma, null]);
|
||||
var pt;
|
||||
for (var i = 0; i < this.modDim; i++) {
|
||||
pt = this.getMod ("W_" + (i + 1));
|
||||
if (pt == null) {
|
||||
JU.Logger.info ("Not enough cell wave vectors for d=" + this.modDim);
|
||||
return;
|
||||
}this.fixDouble (pt);
|
||||
this.cr.appendLoadNote ("W_" + (i + 1) + " = " + JU.Escape.e (pt));
|
||||
this.cr.appendUunitCellInfo ("q" + (i + 1) + "=" + pt[0] + " " + pt[1] + " " + pt[2]);
|
||||
this.sigma.getArray ()[i] = Clazz.newDoubleArray (-1, [pt[0], pt[1], pt[2]]);
|
||||
}
|
||||
var map = new java.util.Hashtable ();
|
||||
for (var e, $e = this.htModulation.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) {
|
||||
if ((key = this.checkKey (e.getKey (), false)) == null) continue;
|
||||
pt = e.getValue ();
|
||||
switch (key.charAt (0)) {
|
||||
case 'O':
|
||||
this.haveOccupancy = true;
|
||||
case 'D':
|
||||
case 'M':
|
||||
case 'U':
|
||||
if (pt[2] == 1 && key.charAt (2) != 'S' && key.charAt (2) != 'T' && key.charAt (2) != 'L') {
|
||||
var ipt = key.indexOf ("?");
|
||||
if (ipt >= 0) {
|
||||
var s = key.substring (ipt + 1);
|
||||
pt = this.getMod (key.substring (0, 2) + s + "#*;*");
|
||||
if (pt != null) this.addModulation (map, key = key.substring (0, ipt), pt, iModel);
|
||||
} else {
|
||||
var a = pt[0];
|
||||
var d = 2 * 3.141592653589793 * pt[1];
|
||||
pt[0] = (a * Math.cos (d));
|
||||
pt[1] = (a * Math.sin (-d));
|
||||
pt[2] = 0;
|
||||
JU.Logger.info ("msCIF setting " + key + " " + JU.Escape.e (pt));
|
||||
}}break;
|
||||
case 'W':
|
||||
if (this.modDim > 1) {
|
||||
continue;
|
||||
}case 'F':
|
||||
if (key.indexOf ("_coefs_") >= 0) {
|
||||
this.cr.appendLoadNote ("Wave vector " + key + "=" + JU.Escape.eAD (pt));
|
||||
} else {
|
||||
var ptHarmonic = this.calculateQCoefs (pt);
|
||||
if (ptHarmonic == null) {
|
||||
this.cr.appendLoadNote ("Cannot match atom wave vector " + key + " " + JU.Escape.eAD (pt) + " to a cell wave vector or its harmonic");
|
||||
} else {
|
||||
var k2 = key + "_coefs_";
|
||||
if (!this.htModulation.containsKey (k2 + this.atModel)) {
|
||||
this.addModulation (map, k2, ptHarmonic, iModel);
|
||||
if (key.startsWith ("F_")) this.cr.appendLoadNote ("atom wave vector " + key + " = " + JU.Escape.e (pt) + " fn = " + JU.Escape.e (ptHarmonic));
|
||||
}}}break;
|
||||
}
|
||||
}
|
||||
if (!map.isEmpty ()) this.htModulation.putAll (map);
|
||||
if (this.htSubsystems == null) {
|
||||
this.haveAtomMods = false;
|
||||
} else {
|
||||
this.cr.strSupercell = null;
|
||||
this.haveAtomMods = true;
|
||||
this.htAtomMods = new java.util.Hashtable ();
|
||||
}for (var e, $e = this.htModulation.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) {
|
||||
if ((key = this.checkKey (e.getKey (), true)) == null) continue;
|
||||
var params = e.getValue ();
|
||||
var atomName = key.substring (key.indexOf (";") + 1);
|
||||
var pt_ = atomName.indexOf ("#=");
|
||||
if (pt_ >= 0) {
|
||||
params = this.getMod (atomName.substring (pt_ + 2));
|
||||
atomName = atomName.substring (0, pt_);
|
||||
}if (JU.Logger.debuggingHigh) JU.Logger.debug ("SetModulation: " + key + " " + JU.Escape.e (params));
|
||||
var type = key.charAt (0);
|
||||
pt_ = key.indexOf ("#") + 1;
|
||||
var utens = null;
|
||||
switch (type) {
|
||||
case 'U':
|
||||
utens = key.substring (pt_, key.indexOf (";"));
|
||||
case 'O':
|
||||
case 'D':
|
||||
case 'M':
|
||||
if (this.modAverage) break;
|
||||
var axis = key.charAt (pt_);
|
||||
type = this.getModType (key);
|
||||
if (this.htAtomMods == null) this.htAtomMods = new java.util.Hashtable ();
|
||||
var p = Clazz.newDoubleArray (params.length, 0);
|
||||
for (var i = p.length; --i >= 0; ) p[i] = params[i];
|
||||
|
||||
var qcoefs = this.getQCoefs (key);
|
||||
if (qcoefs == null) throw new Exception ("Missing cell wave vector for atom wave vector for " + key + " " + JU.Escape.e (params));
|
||||
this.addAtomModulation (atomName, axis, type, p, utens, qcoefs);
|
||||
this.haveAtomMods = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "fixLegendre",
|
||||
function () {
|
||||
for (var i = this.legendres.size (); --i >= 0; ) {
|
||||
var key = this.legendres.get (i);
|
||||
var pt = this.htModulation.get (key);
|
||||
if (pt != null) {
|
||||
var key1 = "O_0#0" + key.substring (key.indexOf (";"));
|
||||
var pt1 = this.htModulation.get (key1);
|
||||
if (pt1 == null) {
|
||||
JU.Logger.error ("Crenel " + key1 + " not found for legendre modulation " + key);
|
||||
pt[2] = NaN;
|
||||
} else {
|
||||
this.htModulation.put (key, Clazz.newDoubleArray (-1, [pt1[0], pt1[1], pt[0], pt[1]]));
|
||||
}}}
|
||||
});
|
||||
Clazz.defineMethod (c$, "fixDouble",
|
||||
function (pt) {
|
||||
if (this.cr.fixJavaFloat) for (var i = pt.length; --i >= 0; ) pt[i] = JU.PT.fixDouble (pt[i], 100000.0);
|
||||
|
||||
}, "~A");
|
||||
Clazz.overrideMethod (c$, "getQCoefs",
|
||||
function (key) {
|
||||
var fn = Math.max (0, this.cr.parseIntAt (key, 2));
|
||||
if (fn == 0) {
|
||||
if (this.qlist100 == null) {
|
||||
this.qlist100 = Clazz.newDoubleArray (this.modDim, 0);
|
||||
this.qlist100[0] = 1;
|
||||
}return this.qlist100;
|
||||
}return this.getMod ("F_" + fn + "_coefs_");
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "getModType",
|
||||
function (key) {
|
||||
var type = key.charAt (0);
|
||||
var id = key.charAt (2);
|
||||
return (id == 'S' ? 's' : id == 'T' ? 't' : id == 'L' ? (type == 'D' ? 'l' : 'L') : id == '0' ? 'c' : type == 'D' ? 'f' : type == 'O' ? 'o' : type == 'M' ? 'm' : type == 'U' ? 'u' : '?');
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "calculateQCoefs",
|
||||
function (p) {
|
||||
if (this.qs == null) {
|
||||
this.qs = new Array (this.modDim);
|
||||
for (var i = 0; i < this.modDim; i++) {
|
||||
this.qs[i] = this.toP3 (this.getMod ("W_" + (i + 1)));
|
||||
}
|
||||
}var pt = this.toP3 (p);
|
||||
for (var i = 0; i < this.modDim; i++) if (this.qs[i] != null) {
|
||||
var ifn = this.approxInt (pt.dot (this.qs[i]) / this.qs[i].dot (this.qs[i]));
|
||||
if (ifn != 0) {
|
||||
p = Clazz.newDoubleArray (this.modDim, 0);
|
||||
p[i] = ifn;
|
||||
return p;
|
||||
}}
|
||||
var p3 = this.toP3 (p);
|
||||
var jmin = (this.modDim < 2 ? 0 : -3);
|
||||
var jmax = (this.modDim < 2 ? 0 : 3);
|
||||
var kmin = (this.modDim < 3 ? 0 : -3);
|
||||
var kmax = (this.modDim < 3 ? 0 : 3);
|
||||
for (var i = -3; i <= 3; i++) for (var j = jmin; j <= jmax; j++) for (var k = kmin; k <= kmax; k++) {
|
||||
pt.setT (this.qs[0]);
|
||||
pt.scale (i);
|
||||
if (this.modDim > 1 && this.qs[1] != null) pt.scaleAdd2 (j, this.qs[1], pt);
|
||||
if (this.modDim > 2 && this.qs[2] != null) pt.scaleAdd2 (k, this.qs[2], pt);
|
||||
if (pt.distanceSquared (p3) < 0.0001) {
|
||||
p = Clazz.newDoubleArray (this.modDim, 0);
|
||||
switch (this.modDim) {
|
||||
default:
|
||||
p[2] = k;
|
||||
case 2:
|
||||
p[1] = j;
|
||||
case 1:
|
||||
p[0] = i;
|
||||
break;
|
||||
}
|
||||
return p;
|
||||
}pt.setT (this.qs[0]);
|
||||
pt.scale (1 / i);
|
||||
if (this.modDim > 1 && this.qs[1] != null) pt.scaleAdd2 (1 / j, this.qs[1], pt);
|
||||
if (this.modDim > 2 && this.qs[2] != null) pt.scaleAdd2 (1 / k, this.qs[2], pt);
|
||||
if (pt.distanceSquared (p3) < 0.0001) {
|
||||
p = Clazz.newDoubleArray (this.modDim, 0);
|
||||
switch (this.modDim) {
|
||||
default:
|
||||
p[2] = 1 / k;
|
||||
case 2:
|
||||
p[1] = 1 / j;
|
||||
case 1:
|
||||
p[0] = 1 / i;
|
||||
break;
|
||||
}
|
||||
return p;
|
||||
}}
|
||||
|
||||
|
||||
pt = this.toP3 (p);
|
||||
for (var i = 0; i < this.modDim; i++) if (this.qs[i] != null) {
|
||||
p3 = this.qs[i];
|
||||
var ifn = 0;
|
||||
if (pt.x != 0) ifn = this.approxInt (pt.x / p3.x);
|
||||
if (pt.y != 0) ifn = Math.max (this.approxInt (pt.y / p3.y), ifn);
|
||||
if (ifn == 0 && pt.z != 0) ifn = Math.max (this.approxInt (pt.z / p3.z), ifn);
|
||||
if (ifn == 0) continue;
|
||||
if (p3.x != 0 && this.approxInt (10 + p3.x * ifn - pt.x) == 0 || p3.y != 0 && this.approxInt (10 + p3.y * ifn - pt.y) == 0 || p3.z != 0 && this.approxInt (10 + p3.z * ifn - pt.z) == 0) continue;
|
||||
p = Clazz.newDoubleArray (this.modDim, 0);
|
||||
p[i] = ifn;
|
||||
return p;
|
||||
}
|
||||
return null;
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "approxInt",
|
||||
function (fn) {
|
||||
var ifn = Math.round (fn);
|
||||
return (Math.abs (fn - ifn) < 0.001 ? ifn : 0);
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "toP3",
|
||||
function (x) {
|
||||
return JU.P3.new3 (x[0], x[1], x[2]);
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "addAtomModulation",
|
||||
function (atomName, axis, type, params, utens, qcoefs) {
|
||||
var list = this.htAtomMods.get (atomName);
|
||||
if (list == null) {
|
||||
this.ac++;
|
||||
this.htAtomMods.put (atomName, list = new JU.Lst ());
|
||||
}list.addLast ( new JU.Modulation (axis, type, params, utens, qcoefs));
|
||||
this.modCount++;
|
||||
}, "~S,~S,~S,~A,~S,~A");
|
||||
Clazz.overrideMethod (c$, "addSubsystem",
|
||||
function (code, w) {
|
||||
if (code == null) return;
|
||||
var ss = new J.adapter.readers.cif.Subsystem (this, code, w);
|
||||
this.cr.appendLoadNote ("subsystem " + code + "\n" + w);
|
||||
this.setSubsystem (code, ss);
|
||||
}, "~S,JU.Matrix");
|
||||
Clazz.defineMethod (c$, "addUStr",
|
||||
function (atom, id, val) {
|
||||
var i = Clazz.doubleToInt ("U11U22U33U12U13U23UISO".indexOf (id) / 3);
|
||||
if (JU.Logger.debuggingHigh) JU.Logger.debug ("MOD RDR adding " + id + " " + i + " " + val + " to " + atom.anisoBorU[i]);
|
||||
this.cr.asc.setU (atom, i, val + atom.anisoBorU[i]);
|
||||
}, "J.adapter.smarter.Atom,~S,~N");
|
||||
Clazz.defineMethod (c$, "modulateAtom",
|
||||
function (a) {
|
||||
if (this.modCoord && this.htSubsystems != null) {
|
||||
var ptc = JU.P3.newP (a);
|
||||
var spt = this.getSymmetry (a);
|
||||
spt.toCartesian (ptc, true);
|
||||
}var list = this.htAtomMods.get (a.atomName);
|
||||
if (list == null && a.altLoc != '\0' && this.htSubsystems != null) {
|
||||
list = new JU.Lst ();
|
||||
}if (list == null || this.symmetry == null || a.bsSymmetry == null) return;
|
||||
var iop = Math.max (a.bsSymmetry.nextSetBit (0), 0);
|
||||
if (this.modLast) iop = Math.max ((a.bsSymmetry.length () - 1) % this.nOps, iop);
|
||||
if (JU.Logger.debuggingHigh) JU.Logger.debug ("\nsetModulation: i=" + a.index + " " + a.atomName + " xyz=" + a + " occ=" + a.foccupancy);
|
||||
if (iop != this.iopLast) {
|
||||
this.iopLast = iop;
|
||||
this.gammaE = new JU.M3 ();
|
||||
this.getSymmetry (a).getSpaceGroupOperation (iop).getRotationScale (this.gammaE);
|
||||
}if (JU.Logger.debugging) {
|
||||
JU.Logger.debug ("setModulation iop = " + iop + " " + this.symmetry.getSpaceGroupXyz (iop, false) + " " + a.bsSymmetry);
|
||||
}var ms = new JU.ModulationSet ().setMod (a.index + " " + a.atomName, this.getAtomR0 (this.cr.asc.atoms[a.atomSite]), this.getAtomR0 (a), this.modDim, list, this.gammaE, this.getMatrices (a), this.getSymmetry (a), this.nOps, iop, Clazz.instanceOf (a.vib, JU.Vibration) ? a.vib : null, this.isCommensurate);
|
||||
ms.calculate (this.modTUV, false);
|
||||
if (!Float.isNaN (ms.vOcc)) {
|
||||
a.foccupancy = ms.setOccupancy (this.getMod ("J_O#0;" + a.atomName), a.foccupancy, (a.vib == null ? 0 : a.vib.x));
|
||||
}if (ms.htUij != null) {
|
||||
var t = (a.tensors == null ? null : a.tensors.get (0));
|
||||
if (t != null && t.parBorU != null) {
|
||||
a.anisoBorU = Clazz.newFloatArray (8, 0);
|
||||
for (var i = 0; i < 8; i++) a.anisoBorU[i] = t.parBorU[i];
|
||||
|
||||
t.isUnmodulated = true;
|
||||
}if (a.anisoBorU == null) {
|
||||
JU.Logger.error ("MOD RDR cannot modulate nonexistent atom anisoBorU for atom " + a.atomName);
|
||||
} else {
|
||||
if (JU.Logger.debuggingHigh) {
|
||||
JU.Logger.debug ("setModulation Uij(initial)=" + JU.Escape.eAF (a.anisoBorU));
|
||||
JU.Logger.debug ("setModulation tensor=" + JU.Escape.e ((a.tensors.get (0)).getInfo ("all")));
|
||||
}for (var e, $e = ms.htUij.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) this.addUStr (a, e.getKey (), e.getValue ().floatValue ());
|
||||
|
||||
var sym = this.getAtomSymmetry (a, this.symmetry);
|
||||
t = this.cr.asc.getXSymmetry ().addRotatedTensor (a, sym.getTensor (this.cr.vwr, a.anisoBorU), iop, false, sym);
|
||||
t.isModulated = true;
|
||||
t.id = JU.Escape.e (a.anisoBorU);
|
||||
a.bfactor = a.anisoBorU[7] * 100;
|
||||
a.anisoBorU = null;
|
||||
if (JU.Logger.debuggingHigh) {
|
||||
JU.Logger.debug ("setModulation Uij(final)=" + JU.Escape.eAF (a.anisoBorU) + "\n");
|
||||
JU.Logger.debug ("setModulation tensor=" + JU.Escape.e ((a.tensors.get (1)).getInfo ("all")));
|
||||
}}}if (Float.isNaN (ms.x)) ms.set (0, 0, 0);
|
||||
a.vib = ms;
|
||||
}, "J.adapter.smarter.Atom");
|
||||
Clazz.defineMethod (c$, "getAtomR0",
|
||||
function (atom) {
|
||||
var r0 = JU.P3.newP (atom);
|
||||
if (this.supercellSymmetry != null) {
|
||||
this.supercellSymmetry.toCartesian (r0, true);
|
||||
this.symmetry.toFractional (r0, true);
|
||||
}return r0;
|
||||
}, "J.adapter.smarter.Atom");
|
||||
Clazz.overrideMethod (c$, "getAtomSymmetry",
|
||||
function (a, defaultSymmetry) {
|
||||
var ss;
|
||||
return (this.htSubsystems == null || (ss = this.getSubsystem (a)) == null ? defaultSymmetry : ss.getSymmetry ());
|
||||
}, "J.adapter.smarter.Atom,J.api.SymmetryInterface");
|
||||
Clazz.defineMethod (c$, "setSubsystem",
|
||||
function (code, system) {
|
||||
if (this.htSubsystems == null) this.htSubsystems = new java.util.Hashtable ();
|
||||
this.htSubsystems.put (code, system);
|
||||
this.setSubsystemOptions ();
|
||||
}, "~S,J.adapter.readers.cif.Subsystem");
|
||||
Clazz.defineMethod (c$, "getMatrices",
|
||||
function (a) {
|
||||
var ss = this.getSubsystem (a);
|
||||
return (ss == null ? this.modMatrices : ss.getModMatrices ());
|
||||
}, "J.adapter.smarter.Atom");
|
||||
Clazz.defineMethod (c$, "getSymmetry",
|
||||
function (a) {
|
||||
var ss = this.getSubsystem (a);
|
||||
return (ss == null ? this.symmetry : ss.getSymmetry ());
|
||||
}, "J.adapter.smarter.Atom");
|
||||
Clazz.defineMethod (c$, "getSubsystem",
|
||||
function (a) {
|
||||
return (this.htSubsystems == null ? null : this.htSubsystems.get ("" + a.altLoc));
|
||||
}, "J.adapter.smarter.Atom");
|
||||
Clazz.overrideMethod (c$, "setMinMax0",
|
||||
function (minXYZ, maxXYZ) {
|
||||
if (this.htSubsystems == null) return;
|
||||
var symmetry = this.getDefaultUnitCell ();
|
||||
this.minXYZ0 = JU.P3.newP (minXYZ);
|
||||
this.maxXYZ0 = JU.P3.newP (maxXYZ);
|
||||
var pt0 = JU.P3.newP (minXYZ);
|
||||
var pt1 = JU.P3.newP (maxXYZ);
|
||||
var pt = new JU.P3 ();
|
||||
symmetry.toCartesian (pt0, true);
|
||||
symmetry.toCartesian (pt1, true);
|
||||
var pts = JU.BoxInfo.unitCubePoints;
|
||||
if (this.sigma == null) {
|
||||
JU.Logger.error ("Why are we in MSRdr.setMinMax0 without modulation init?");
|
||||
return;
|
||||
}for (var e, $e = this.htSubsystems.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) {
|
||||
var sym = e.getValue ().getSymmetry ();
|
||||
for (var i = 8; --i >= 0; ) {
|
||||
pt.x = (pts[i].x == 0 ? pt0.x : pt1.x);
|
||||
pt.y = (pts[i].y == 0 ? pt0.y : pt1.y);
|
||||
pt.z = (pts[i].z == 0 ? pt0.z : pt1.z);
|
||||
this.expandMinMax (pt, sym, minXYZ, maxXYZ);
|
||||
}
|
||||
}
|
||||
}, "JU.P3,JU.P3");
|
||||
Clazz.defineMethod (c$, "expandMinMax",
|
||||
function (pt, sym, minXYZ, maxXYZ) {
|
||||
var pt2 = JU.P3.newP (pt);
|
||||
var slop = 0.0001;
|
||||
sym.toFractional (pt2, false);
|
||||
if (minXYZ.x > pt2.x + slop) minXYZ.x = Clazz.doubleToInt (Math.floor (pt2.x)) - 1;
|
||||
if (minXYZ.y > pt2.y + slop) minXYZ.y = Clazz.doubleToInt (Math.floor (pt2.y)) - 1;
|
||||
if (minXYZ.z > pt2.z + slop) minXYZ.z = Clazz.doubleToInt (Math.floor (pt2.z)) - 1;
|
||||
if (maxXYZ.x < pt2.x - slop) maxXYZ.x = Clazz.doubleToInt (Math.ceil (pt2.x)) + 1;
|
||||
if (maxXYZ.y < pt2.y - slop) maxXYZ.y = Clazz.doubleToInt (Math.ceil (pt2.y)) + 1;
|
||||
if (maxXYZ.z < pt2.z - slop) maxXYZ.z = Clazz.doubleToInt (Math.ceil (pt2.z)) + 1;
|
||||
}, "JU.P3,J.api.SymmetryInterface,JU.P3,JU.P3");
|
||||
Clazz.defineMethod (c$, "trimAtomSet",
|
||||
function () {
|
||||
if (!this.cr.doApplySymmetry) return;
|
||||
var asc = this.cr.asc;
|
||||
var bs = asc.bsAtoms;
|
||||
var sym = this.getDefaultUnitCell ();
|
||||
var atoms = asc.atoms;
|
||||
var pt = new JU.P3 ();
|
||||
if (bs == null) bs = asc.bsAtoms = JU.BSUtil.newBitSet2 (0, asc.ac);
|
||||
for (var i = bs.nextSetBit (0); i >= 0; i = bs.nextSetBit (i + 1)) {
|
||||
var a = atoms[i];
|
||||
var isOK = (!this.isCommensurate || this.modAverage || a.foccupancy >= 0.5);
|
||||
if (isOK) {
|
||||
pt.setT (a);
|
||||
if (a.vib != null) pt.add (a.vib);
|
||||
this.getSymmetry (a).toCartesian (pt, false);
|
||||
sym.toFractional (pt, false);
|
||||
if (this.cr.fixJavaFloat) JU.PT.fixPtFloats (pt, 100000.0);
|
||||
isOK = asc.xtalSymmetry.isWithinCell (3, pt, this.minXYZ0.x, this.maxXYZ0.x, this.minXYZ0.y, this.maxXYZ0.y, this.minXYZ0.z, this.maxXYZ0.z, 0.001);
|
||||
}if (isOK) {
|
||||
if (this.cr.fixJavaFloat) JU.PT.fixPtFloats (a, 100000.0);
|
||||
} else {
|
||||
bs.clear (i);
|
||||
}}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getDefaultUnitCell",
|
||||
function () {
|
||||
return (this.modCell != null && this.htSubsystems.containsKey (this.modCell) ? this.htSubsystems.get (this.modCell).getSymmetry () : this.cr.asc.getSymmetry ());
|
||||
});
|
||||
Clazz.overrideMethod (c$, "getSymmetryFromCode",
|
||||
function (code) {
|
||||
return this.htSubsystems.get (code).getSymmetry ();
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "addLatticeVector",
|
||||
function (lattvecs, data) {
|
||||
var a = null;
|
||||
var c = data.charAt (0);
|
||||
var dim = this.modDim + 3;
|
||||
switch (c) {
|
||||
case 'P':
|
||||
case 'X':
|
||||
break;
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'I':
|
||||
a = Clazz.newFloatArray (-1, [0.5, 0.5, 0.5]);
|
||||
if (c != 'I') a[c.charCodeAt (0) - 65] = 0;
|
||||
break;
|
||||
case 'F':
|
||||
this.addLatticeVector (lattvecs, "A");
|
||||
this.addLatticeVector (lattvecs, "B");
|
||||
this.addLatticeVector (lattvecs, "C");
|
||||
break;
|
||||
case 'M':
|
||||
dim++;
|
||||
case '0':
|
||||
if (data.indexOf (".") >= 0) a = J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (data, null, dim);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
if (a != null) lattvecs.addLast (a);
|
||||
return true;
|
||||
}, "JU.Lst,~S");
|
||||
Clazz.defineStatics (c$,
|
||||
"U_LIST", "U11U22U33U12U13U23UISO");
|
||||
});
|
||||
@@ -0,0 +1,105 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.cif");
|
||||
Clazz.load (null, "J.adapter.readers.cif.Subsystem", ["JU.Lst", "$.Matrix", "$.V3", "JU.Logger", "$.SimpleUnitCell"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.msRdr = null;
|
||||
this.code = null;
|
||||
this.d = 0;
|
||||
this.w = null;
|
||||
this.symmetry = null;
|
||||
this.modMatrices = null;
|
||||
this.isFinalized = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.cif, "Subsystem");
|
||||
Clazz.makeConstructor (c$,
|
||||
function (msRdr, code, w) {
|
||||
this.msRdr = msRdr;
|
||||
this.code = code;
|
||||
this.w = w;
|
||||
this.d = w.getArray ().length - 3;
|
||||
}, "J.adapter.readers.cif.MSRdr,~S,JU.Matrix");
|
||||
Clazz.defineMethod (c$, "getSymmetry",
|
||||
function () {
|
||||
if (!this.isFinalized) this.setSymmetry (true);
|
||||
return this.symmetry;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getModMatrices",
|
||||
function () {
|
||||
if (!this.isFinalized) this.setSymmetry (true);
|
||||
return this.modMatrices;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setSymmetry",
|
||||
function (setOperators) {
|
||||
var a;
|
||||
JU.Logger.info ("[subsystem " + this.code + "]");
|
||||
var winv = this.w.inverse ();
|
||||
JU.Logger.info ("w=" + this.w);
|
||||
JU.Logger.info ("w_inv=" + winv);
|
||||
var w33 = this.w.getSubmatrix (0, 0, 3, 3);
|
||||
var wd3 = this.w.getSubmatrix (3, 0, this.d, 3);
|
||||
var w3d = this.w.getSubmatrix (0, 3, 3, this.d);
|
||||
var wdd = this.w.getSubmatrix (3, 3, this.d, this.d);
|
||||
var sigma = this.msRdr.getSigma ();
|
||||
var sigma_nu = wdd.mul (sigma).add (wd3).mul (w3d.mul (sigma).add (w33).inverse ());
|
||||
var tFactor = wdd.sub (sigma_nu.mul (w3d));
|
||||
JU.Logger.info ("sigma_nu = " + sigma_nu);
|
||||
var s0 = this.msRdr.cr.asc.getSymmetry ();
|
||||
var vu43 = s0.getUnitCellVectors ();
|
||||
var vr43 = JU.SimpleUnitCell.getReciprocal (vu43, null, 1);
|
||||
var mard3 = new JU.Matrix (null, 3 + this.d, 3);
|
||||
var mar3 = new JU.Matrix (null, 3, 3);
|
||||
var mard3a = mard3.getArray ();
|
||||
var mar3a = mar3.getArray ();
|
||||
for (var i = 0; i < 3; i++) mard3a[i] = mar3a[i] = Clazz.newDoubleArray (-1, [vr43[i + 1].x, vr43[i + 1].y, vr43[i + 1].z]);
|
||||
|
||||
var sx = sigma.mul (mar3);
|
||||
a = sx.getArray ();
|
||||
for (var i = 0; i < this.d; i++) mard3a[i + 3] = a[i];
|
||||
|
||||
a = this.w.mul (mard3).getArray ();
|
||||
var uc_nu = new Array (4);
|
||||
uc_nu[0] = vu43[0];
|
||||
for (var i = 0; i < 3; i++) uc_nu[i + 1] = JU.V3.new3 (a[i][0], a[i][1], a[i][2]);
|
||||
|
||||
uc_nu = JU.SimpleUnitCell.getReciprocal (uc_nu, null, 1);
|
||||
this.symmetry = (this.msRdr.cr.getInterface ("JS.Symmetry")).getUnitCell (uc_nu, false, null);
|
||||
this.modMatrices = Clazz.newArray (-1, [sigma_nu, tFactor]);
|
||||
if (!setOperators) return;
|
||||
this.isFinalized = true;
|
||||
JU.Logger.info ("unit cell parameters: " + this.symmetry.getUnitCellInfo ());
|
||||
this.symmetry.createSpaceGroup (-1, "[subsystem " + this.code + "]", new JU.Lst ());
|
||||
var nOps = s0.getSpaceGroupOperationCount ();
|
||||
for (var iop = 0; iop < nOps; iop++) {
|
||||
var rv = s0.getOperationRsVs (iop);
|
||||
var r0 = rv.getRotation ();
|
||||
var v0 = rv.getTranslation ();
|
||||
var r = this.w.mul (r0).mul (winv);
|
||||
var v = this.w.mul (v0);
|
||||
var code = this.code;
|
||||
if (this.isMixed (r)) {
|
||||
for (var e, $e = this.msRdr.htSubsystems.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) {
|
||||
var ss = e.getValue ();
|
||||
if (ss === this) continue;
|
||||
var rj = ss.w.mul (r0).mul (winv);
|
||||
if (!this.isMixed (rj)) {
|
||||
r = rj;
|
||||
v = ss.w.mul (v0);
|
||||
code = ss.code;
|
||||
break;
|
||||
}}
|
||||
}var jf = this.symmetry.addOp (code, r, v, sigma_nu);
|
||||
JU.Logger.info (this.code + "." + (iop + 1) + (this.code.equals (code) ? " " : ">" + code + " ") + jf);
|
||||
}
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "isMixed",
|
||||
function (r) {
|
||||
var a = r.getArray ();
|
||||
for (var i = 3; --i >= 0; ) for (var j = 3 + this.d; --j >= 3; ) if (a[i][j] != 0) return true;
|
||||
|
||||
|
||||
return false;
|
||||
}, "JU.Matrix");
|
||||
Clazz.overrideMethod (c$, "toString",
|
||||
function () {
|
||||
return "Subsystem " + this.code + "\n" + this.w;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.molxyz");
|
||||
Clazz.load (["J.adapter.readers.molxyz.MolReader"], "J.adapter.readers.molxyz.Mol3DReader", null, function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.molxyz, "Mol3DReader", J.adapter.readers.molxyz.MolReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.allow2D = false;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,306 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.molxyz");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.molxyz.MolReader", ["java.lang.Exception", "java.util.Hashtable", "JU.PT", "J.adapter.smarter.Atom", "J.api.JmolAdapter", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.optimize2D = false;
|
||||
this.haveAtomSerials = false;
|
||||
this.dimension = null;
|
||||
this.allow2D = true;
|
||||
this.iatom0 = 0;
|
||||
this.vr = null;
|
||||
this.atomCount = 0;
|
||||
this.atomData = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.molxyz, "MolReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.optimize2D = this.checkFilterKey ("2D");
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
var isMDL = (this.line.startsWith ("$MDL"));
|
||||
if (isMDL) {
|
||||
this.discardLinesUntilStartsWith ("$HDR");
|
||||
this.rd ();
|
||||
if (this.line == null) {
|
||||
JU.Logger.warn ("$HDR not found in MDL RG file");
|
||||
this.continuing = false;
|
||||
return false;
|
||||
}} else if (this.line.equals ("M END")) {
|
||||
return true;
|
||||
}if (this.doGetModel (++this.modelNumber, null)) {
|
||||
this.iatom0 = this.asc.ac;
|
||||
this.processMolSdHeader ();
|
||||
this.processCtab (isMDL);
|
||||
this.vr = null;
|
||||
if (this.isLastModel (this.modelNumber)) {
|
||||
this.continuing = false;
|
||||
return false;
|
||||
}}if (this.line != null && this.line.indexOf ("$$$$") < 0) this.discardLinesUntilStartsWith ("$$$$");
|
||||
return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.finalizeReaderMR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "finalizeReaderMR",
|
||||
function () {
|
||||
if (this.optimize2D) this.set2D ();
|
||||
this.isTrajectory = false;
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "processMolSdHeader",
|
||||
function () {
|
||||
var header = "";
|
||||
var thisDataSetName = this.line.trim ();
|
||||
this.asc.setCollectionName (thisDataSetName);
|
||||
header += this.line + "\n";
|
||||
this.rd ();
|
||||
if (this.line == null) return;
|
||||
header += this.line + "\n";
|
||||
this.dimension = (this.line.length < 22 ? "3D" : this.line.substring (20, 22));
|
||||
if (this.dimension.equals ("2D")) {
|
||||
if (!this.allow2D) throw new Exception ("File is 2D, not 3D");
|
||||
this.appendLoadNote ("This model is 2D. Its 3D structure has not been generated.");
|
||||
}this.asc.setInfo ("dimension", this.dimension);
|
||||
this.rd ();
|
||||
if (this.line == null) return;
|
||||
this.line = this.line.trim ();
|
||||
header += this.line + "\n";
|
||||
JU.Logger.info (header);
|
||||
this.checkCurrentLineForScript ();
|
||||
this.asc.setInfo ("fileHeader", header);
|
||||
this.newAtomSet (thisDataSetName);
|
||||
});
|
||||
Clazz.defineMethod (c$, "processCtab",
|
||||
function (isMDL) {
|
||||
if (isMDL) this.discardLinesUntilStartsWith ("$CTAB");
|
||||
if (this.rd () == null) return;
|
||||
if (this.line.indexOf ("V3000") >= 0) {
|
||||
this.optimize2D = (this.dimension.equals ("2D"));
|
||||
this.vr = (this.getInterface ("J.adapter.readers.molxyz.V3000Rdr")).set (this);
|
||||
this.discardLinesUntilContains ("COUNTS");
|
||||
this.vr.readAtomsAndBonds (this.getTokens ());
|
||||
} else {
|
||||
this.readAtomsAndBonds (this.parseIntRange (this.line, 0, 3), this.parseIntRange (this.line, 3, 6));
|
||||
}this.applySymmetryAndSetTrajectory ();
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "readAtomsAndBonds",
|
||||
function (ac, bc) {
|
||||
this.atomCount = ac;
|
||||
for (var i = 0; i < ac; ++i) {
|
||||
this.rd ();
|
||||
var len = this.line.length;
|
||||
var elementSymbol;
|
||||
var x;
|
||||
var y;
|
||||
var z;
|
||||
var charge = 0;
|
||||
var isotope = 0;
|
||||
var iAtom = -2147483648;
|
||||
x = this.parseFloatRange (this.line, 0, 10);
|
||||
y = this.parseFloatRange (this.line, 10, 20);
|
||||
z = this.parseFloatRange (this.line, 20, 30);
|
||||
if (len < 34) {
|
||||
elementSymbol = this.line.substring (31).trim ();
|
||||
} else {
|
||||
elementSymbol = this.line.substring (31, 34).trim ();
|
||||
if (elementSymbol.equals ("H1")) {
|
||||
elementSymbol = "H";
|
||||
isotope = 1;
|
||||
}if (len >= 39) {
|
||||
var code = this.parseIntRange (this.line, 36, 39);
|
||||
if (code >= 1 && code <= 7) charge = 4 - code;
|
||||
code = this.parseIntRange (this.line, 34, 36);
|
||||
if (code != 0 && code >= -3 && code <= 4) {
|
||||
isotope = J.api.JmolAdapter.getNaturalIsotope (J.api.JmolAdapter.getElementNumber (elementSymbol)) + code;
|
||||
}if (iAtom == -2147483648 && this.haveAtomSerials) iAtom = i + 1;
|
||||
}}this.addMolAtom (iAtom, isotope, elementSymbol, charge, x, y, z);
|
||||
}
|
||||
this.rd ();
|
||||
if (this.line.startsWith ("V ")) {
|
||||
this.readAtomValues ();
|
||||
}if (bc == 0) this.asc.setNoAutoBond ();
|
||||
for (var i = 0; i < bc; ++i) {
|
||||
if (i > 0) this.rd ();
|
||||
var iAtom1;
|
||||
var iAtom2;
|
||||
var stereo = 0;
|
||||
iAtom1 = this.line.substring (0, 3).trim ();
|
||||
iAtom2 = this.line.substring (3, 6).trim ();
|
||||
var order = this.parseIntRange (this.line, 6, 9);
|
||||
if (this.optimize2D && order == 1 && this.line.length >= 12) stereo = this.parseIntRange (this.line, 9, 12);
|
||||
order = this.fixOrder (order, stereo);
|
||||
if (this.haveAtomSerials) this.asc.addNewBondFromNames (iAtom1, iAtom2, order);
|
||||
else this.asc.addNewBondWithOrder (this.iatom0 + this.parseIntStr (iAtom1) - 1, this.iatom0 + this.parseIntStr (iAtom2) - 1, order);
|
||||
}
|
||||
var molData = new java.util.Hashtable ();
|
||||
this.rd ();
|
||||
while (this.line != null && this.line.indexOf ("$$$$") != 0) {
|
||||
if (this.line.indexOf (">") == 0) {
|
||||
this.readMolData (molData);
|
||||
continue;
|
||||
}if (this.line.startsWith ("M ISO")) {
|
||||
this.readIsotopes ();
|
||||
continue;
|
||||
}this.rd ();
|
||||
}
|
||||
if (this.atomData != null) {
|
||||
var atomValueName = molData.get ("atom_value_name");
|
||||
molData.put (atomValueName == null ? "atom_values" : atomValueName.toString (), this.atomData);
|
||||
}if (!molData.isEmpty ()) this.asc.setCurrentModelInfo ("molData", molData);
|
||||
}, "~N,~N");
|
||||
Clazz.defineMethod (c$, "readAtomValues",
|
||||
function () {
|
||||
this.atomData = new Array (this.atomCount);
|
||||
for (var i = this.atomData.length; --i >= 0; ) this.atomData[i] = "";
|
||||
|
||||
while (this.line.indexOf ("V ") == 0) {
|
||||
var iAtom = this.parseIntAt (this.line, 3);
|
||||
if (iAtom < 1 || iAtom > this.atomCount) {
|
||||
JU.Logger.error ("V nnn does not evalute to a valid atom number: " + iAtom);
|
||||
return;
|
||||
}var s = this.line.substring (6).trim ();
|
||||
this.atomData[iAtom - 1] = s;
|
||||
this.rd ();
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readIsotopes",
|
||||
function () {
|
||||
var n = this.parseIntAt (this.line, 6);
|
||||
try {
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
for (var i = 0, pt = 9; i < n; i++) {
|
||||
var ipt = this.parseIntAt (this.line, pt);
|
||||
var atom = this.asc.atoms[ipt + i0 - 1];
|
||||
var iso = this.parseIntAt (this.line, pt + 4);
|
||||
pt += 8;
|
||||
atom.elementSymbol = "" + iso + JU.PT.replaceAllCharacters (atom.elementSymbol, "0123456789", "");
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
this.rd ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolData",
|
||||
function (molData) {
|
||||
var atoms = this.asc.atoms;
|
||||
var dataName = JU.PT.trim (this.line, "> <").toLowerCase ();
|
||||
var data = "";
|
||||
var fdata = null;
|
||||
while (this.rd () != null && !this.line.equals ("$$$$") && this.line.length > 0) data += this.line + "\n";
|
||||
|
||||
data = JU.PT.trim (data, "\n");
|
||||
JU.Logger.info (dataName + ":" + JU.PT.esc (data));
|
||||
molData.put (dataName, data);
|
||||
var ndata = 0;
|
||||
if (dataName.toUpperCase ().contains ("_PARTIAL_CHARGES")) {
|
||||
try {
|
||||
fdata = JU.PT.parseFloatArray (data);
|
||||
for (var i = this.asc.getLastAtomSetAtomIndex (), n = this.asc.ac; i < n; i++) atoms[i].partialCharge = 0;
|
||||
|
||||
var pt = 0;
|
||||
for (var i = Clazz.floatToInt (fdata[pt++]); --i >= 0; ) {
|
||||
var atomIndex = Clazz.floatToInt (fdata[pt++]) + this.iatom0 - 1;
|
||||
var partialCharge = fdata[pt++];
|
||||
atoms[atomIndex].partialCharge = partialCharge;
|
||||
ndata++;
|
||||
}
|
||||
} catch (e) {
|
||||
for (var i = this.asc.getLastAtomSetAtomIndex (), n = this.asc.ac; i < n; i++) atoms[i].partialCharge = 0;
|
||||
|
||||
JU.Logger.error ("error reading " + dataName + " field -- partial charges cleared");
|
||||
}
|
||||
JU.Logger.info (ndata + " partial charges read");
|
||||
} else if (dataName.toUpperCase ().contains ("ATOM_NAMES")) {
|
||||
ndata = 0;
|
||||
try {
|
||||
var tokens = JU.PT.getTokens (data);
|
||||
var pt = 0;
|
||||
for (var i = this.parseIntStr (tokens[pt++]); --i >= 0; ) {
|
||||
var iatom;
|
||||
while ((iatom = this.parseIntStr (tokens[pt++])) == -2147483648) {
|
||||
}
|
||||
var atomIndex = iatom + this.iatom0 - 1;
|
||||
var name = tokens[pt++];
|
||||
if (!name.equals (".")) atoms[atomIndex].atomName = name;
|
||||
ndata++;
|
||||
}
|
||||
} catch (e) {
|
||||
JU.Logger.error ("error reading " + dataName + " field");
|
||||
}
|
||||
JU.Logger.info (ndata + " atom names read");
|
||||
}}, "java.util.Map");
|
||||
Clazz.defineMethod (c$, "addMolAtom",
|
||||
function (iAtom, isotope, elementSymbol, charge, x, y, z) {
|
||||
switch (isotope) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
elementSymbol = "1H";
|
||||
break;
|
||||
case 2:
|
||||
elementSymbol = "2H";
|
||||
break;
|
||||
case 3:
|
||||
elementSymbol = "3H";
|
||||
break;
|
||||
default:
|
||||
elementSymbol = isotope + elementSymbol;
|
||||
}
|
||||
if (this.optimize2D && z != 0) this.optimize2D = false;
|
||||
var atom = new J.adapter.smarter.Atom ();
|
||||
atom.elementSymbol = elementSymbol;
|
||||
atom.formalCharge = charge;
|
||||
this.setAtomCoordXYZ (atom, x, y, z);
|
||||
if (iAtom == -2147483648) {
|
||||
this.asc.addAtom (atom);
|
||||
} else {
|
||||
this.haveAtomSerials = true;
|
||||
atom.atomSerial = iAtom;
|
||||
this.asc.addAtomWithMappedSerialNumber (atom);
|
||||
}}, "~N,~N,~S,~N,~N,~N,~N");
|
||||
Clazz.defineMethod (c$, "fixOrder",
|
||||
function (order, stereo) {
|
||||
switch (order) {
|
||||
default:
|
||||
case 0:
|
||||
case -10:
|
||||
return 1;
|
||||
case 1:
|
||||
switch (stereo) {
|
||||
case 1:
|
||||
return 1025;
|
||||
case 3:
|
||||
case 6:
|
||||
return 1041;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
return 515;
|
||||
case 5:
|
||||
return 66;
|
||||
case 6:
|
||||
return 513;
|
||||
case 7:
|
||||
return 514;
|
||||
case 8:
|
||||
case 9:
|
||||
return 33;
|
||||
case 14:
|
||||
return 4;
|
||||
case 15:
|
||||
return 5;
|
||||
case 16:
|
||||
return 6;
|
||||
}
|
||||
return order;
|
||||
}, "~N,~N");
|
||||
Clazz.defineMethod (c$, "addMolBond",
|
||||
function (iAtom1, iAtom2, order, stereo) {
|
||||
order = this.fixOrder (order, stereo);
|
||||
if (this.haveAtomSerials) this.asc.addNewBondFromNames (iAtom1, iAtom2, order);
|
||||
else this.asc.addNewBondWithOrder (this.iatom0 + this.parseIntStr (iAtom1) - 1, this.iatom0 + this.parseIntStr (iAtom2) - 1, order);
|
||||
}, "~S,~S,~N,~N");
|
||||
});
|
||||
@@ -0,0 +1,158 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.molxyz");
|
||||
Clazz.load (null, "J.adapter.readers.molxyz.V3000Rdr", ["java.util.Hashtable", "JU.PT"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.mr = null;
|
||||
this.line = null;
|
||||
this.userData = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.molxyz, "V3000Rdr");
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
});
|
||||
Clazz.defineMethod (c$, "set",
|
||||
function (mr) {
|
||||
this.mr = mr;
|
||||
return this;
|
||||
}, "J.adapter.smarter.AtomSetCollectionReader");
|
||||
Clazz.defineMethod (c$, "readAtomsAndBonds",
|
||||
function (tokens) {
|
||||
var ac = this.mr.parseIntStr (tokens[3]);
|
||||
this.readAtoms (ac);
|
||||
this.readBonds (this.mr.parseIntStr (tokens[4]));
|
||||
this.readUserData (ac);
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (ac) {
|
||||
this.mr.discardLinesUntilContains ("BEGIN ATOM");
|
||||
for (var i = 0; i < ac; ++i) {
|
||||
this.rd ();
|
||||
this.checkLineContinuation ();
|
||||
var tokens = this.mr.getTokens ();
|
||||
var iAtom = this.mr.parseIntStr (tokens[2]);
|
||||
var elementSymbol = tokens[3];
|
||||
if (elementSymbol.equals ("*")) continue;
|
||||
var x = this.mr.parseFloatStr (tokens[4]);
|
||||
var y = this.mr.parseFloatStr (tokens[5]);
|
||||
var z = this.mr.parseFloatStr (tokens[6]);
|
||||
var charge = 0;
|
||||
var isotope = 0;
|
||||
for (var j = 7; j < tokens.length; j++) {
|
||||
var s = tokens[j].toUpperCase ();
|
||||
if (s.startsWith ("CHG=")) charge = this.mr.parseIntAt (tokens[j], 4);
|
||||
else if (s.startsWith ("MASS=")) isotope = this.mr.parseIntAt (tokens[j], 5);
|
||||
}
|
||||
if (isotope > 1 && elementSymbol.equals ("H")) isotope = 1 - isotope;
|
||||
this.mr.addMolAtom (iAtom, isotope, elementSymbol, charge, x, y, z);
|
||||
}
|
||||
this.mr.discardLinesUntilContains ("END ATOM");
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readBonds",
|
||||
function (bondCount) {
|
||||
this.mr.discardLinesUntilContains ("BEGIN BOND");
|
||||
if (bondCount == 0) this.mr.asc.setNoAutoBond ();
|
||||
for (var i = 0; i < bondCount; ++i) {
|
||||
this.rd ();
|
||||
var stereo = 0;
|
||||
this.checkLineContinuation ();
|
||||
var tokens = this.mr.getTokens ();
|
||||
var order = this.mr.parseIntStr (tokens[3]);
|
||||
var iAtom1 = tokens[4];
|
||||
var iAtom2 = tokens[5];
|
||||
var cfg = this.getField ("CFG");
|
||||
if (cfg == null) {
|
||||
var endpts = this.getField ("ENDPTS");
|
||||
if (endpts != null && this.line.indexOf ("ATTACH=ALL") >= 0) {
|
||||
tokens = JU.PT.getTokens (endpts);
|
||||
var n = this.mr.parseIntStr (tokens[0]);
|
||||
var o = this.mr.fixOrder (order, 0);
|
||||
for (var k = 1; k <= n; k++) this.mr.asc.addNewBondFromNames (iAtom1, tokens[k], o);
|
||||
|
||||
}} else {
|
||||
stereo = this.mr.parseIntStr (cfg);
|
||||
}this.mr.addMolBond (iAtom1, iAtom2, order, stereo);
|
||||
}
|
||||
this.mr.discardLinesUntilContains ("END BOND");
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readUserData",
|
||||
function (ac) {
|
||||
this.userData = null;
|
||||
var pc = null;
|
||||
while (!this.rd ().contains ("END CTAB")) {
|
||||
if (!this.line.contains ("BEGIN SGROUP")) continue;
|
||||
var atoms;
|
||||
var name;
|
||||
var data;
|
||||
while (!this.rd ().contains ("END SGROUP")) {
|
||||
if (this.userData == null) this.userData = new java.util.Hashtable ();
|
||||
if ((atoms = this.getField ("ATOMS")) == null || (name = this.getField ("FIELDNAME")) == null || (data = this.getField ("FIELDDATA")) == null) continue;
|
||||
name = name.toLowerCase ();
|
||||
var isPartial = (name.indexOf ("partial") >= 0);
|
||||
if (isPartial) {
|
||||
if (pc == null) pc = name;
|
||||
else if (!pc.equals (name)) isPartial = false;
|
||||
}if (isPartial) {
|
||||
var at = this.mr.asc.atoms;
|
||||
for (var i = this.mr.asc.getLastAtomSetAtomIndex (), n = this.mr.asc.ac; i < n; i++) at[i].partialCharge = 0;
|
||||
|
||||
}var a = null;
|
||||
var f = 0;
|
||||
if (isPartial) f = this.mr.parseFloatStr (data);
|
||||
else if ((a = this.userData.get (name)) == null) this.userData.put (name, a = new Array (ac));
|
||||
try {
|
||||
var tokens = JU.PT.getTokens (atoms);
|
||||
for (var i = tokens.length; --i >= 1; ) {
|
||||
var atom = tokens[i];
|
||||
if (isPartial) this.mr.asc.getAtomFromName (atom).partialCharge = f;
|
||||
else a[this.mr.parseIntStr (atom) - 1] = data;
|
||||
}
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.userData == null) return;
|
||||
for (var key, $key = this.userData.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) {
|
||||
var a = this.userData.get (key);
|
||||
var f = Clazz.newFloatArray (a.length, 0);
|
||||
for (var i = 0; i < a.length; i++) f[i] = (a[i] == null ? 0 : this.mr.parseFloatStr (a[i]));
|
||||
|
||||
this.mr.asc.setAtomProperties (key, f, -1, false);
|
||||
}
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "getField",
|
||||
function (key) {
|
||||
var pt = this.line.indexOf (key + "=");
|
||||
if (pt < 0) return null;
|
||||
pt += key.length + 1;
|
||||
var term = ' ';
|
||||
switch (this.line.charAt (pt)) {
|
||||
case '"':
|
||||
term = '"';
|
||||
break;
|
||||
case '(':
|
||||
term = ')';
|
||||
break;
|
||||
case '+':
|
||||
break;
|
||||
default:
|
||||
pt--;
|
||||
break;
|
||||
}
|
||||
return this.line.substring (pt + 1, (this.line + term).indexOf (term, pt + 1));
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "rd",
|
||||
function () {
|
||||
return (this.line = this.mr.rd ());
|
||||
});
|
||||
Clazz.defineMethod (c$, "checkLineContinuation",
|
||||
function () {
|
||||
while (this.line.endsWith ("-")) {
|
||||
var s = this.line;
|
||||
this.rd ();
|
||||
this.line = s + this.line;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,80 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.molxyz");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.molxyz.XyzReader", ["java.lang.Float", "JU.Logger"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.molxyz, "XyzReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
var modelAtomCount = this.parseIntStr (this.line);
|
||||
if (modelAtomCount == -2147483648) {
|
||||
this.continuing = false;
|
||||
return false;
|
||||
}this.vibrationNumber = ++this.modelNumber;
|
||||
if (this.desiredVibrationNumber <= 0 ? this.doGetModel (this.modelNumber, null) : this.doGetVibration (this.vibrationNumber)) {
|
||||
this.rd ();
|
||||
this.checkCurrentLineForScript ();
|
||||
this.asc.newAtomSet ();
|
||||
var name = this.line.trim ();
|
||||
this.readAtoms (modelAtomCount);
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.asc.setAtomSetName (name);
|
||||
if (this.isLastModel (this.modelNumber)) {
|
||||
this.continuing = false;
|
||||
return false;
|
||||
}} else {
|
||||
this.skipAtomSet (modelAtomCount);
|
||||
}this.discardLinesUntilNonBlank ();
|
||||
return false;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.isTrajectory = false;
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "skipAtomSet",
|
||||
function (modelAtomCount) {
|
||||
this.rd ();
|
||||
for (var i = modelAtomCount; --i >= 0; ) this.rd ();
|
||||
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (modelAtomCount) {
|
||||
for (var i = 0; i < modelAtomCount; ++i) {
|
||||
this.rd ();
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length < 4) {
|
||||
JU.Logger.warn ("line cannot be read for XYZ atom data: " + this.line);
|
||||
continue;
|
||||
}var atom = this.addAtomXYZSymName (tokens, 1, null, null);
|
||||
this.setElementAndIsotope (atom, tokens[0]);
|
||||
var vpt = 4;
|
||||
switch (tokens.length) {
|
||||
case 4:
|
||||
continue;
|
||||
case 5:
|
||||
case 6:
|
||||
case 8:
|
||||
case 9:
|
||||
if (tokens[4].indexOf (".") >= 0) {
|
||||
atom.partialCharge = this.parseFloatStr (tokens[4]);
|
||||
} else {
|
||||
var charge = this.parseIntStr (tokens[4]);
|
||||
if (charge != -2147483648) atom.formalCharge = charge;
|
||||
}switch (tokens.length) {
|
||||
case 5:
|
||||
continue;
|
||||
case 6:
|
||||
atom.radius = this.parseFloatStr (tokens[5]);
|
||||
continue;
|
||||
case 9:
|
||||
atom.atomSerial = this.parseIntStr (tokens[8]);
|
||||
}
|
||||
vpt++;
|
||||
default:
|
||||
var vx = this.parseFloatStr (tokens[vpt++]);
|
||||
var vy = this.parseFloatStr (tokens[vpt++]);
|
||||
var vz = this.parseFloatStr (tokens[vpt++]);
|
||||
if (Float.isNaN (vx) || Float.isNaN (vy) || Float.isNaN (vz)) continue;
|
||||
this.asc.addVibrationVector (atom.index, vx, vy, vz);
|
||||
}
|
||||
}
|
||||
}, "~N");
|
||||
});
|
||||
@@ -0,0 +1,152 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.more");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.more.BinaryDcdReader", ["java.lang.Boolean", "JU.BS", "$.P3", "$.SB", "JU.Escape", "$.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.nModels = 0;
|
||||
this.nAtoms = 0;
|
||||
this.nFree = 0;
|
||||
this.bsFree = null;
|
||||
this.xAll = null;
|
||||
this.yAll = null;
|
||||
this.zAll = null;
|
||||
this.crystGroup = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.more, "BinaryDcdReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "setup",
|
||||
function (fullPath, htParams, reader) {
|
||||
this.isBinary = true;
|
||||
this.requiresBSFilter = true;
|
||||
this.setupASCR (fullPath, htParams, reader);
|
||||
}, "~S,java.util.Map,~O");
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.initializeTrajectoryFile ();
|
||||
this.asc.setInfo ("ignoreUnitCell", Boolean.TRUE);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processBinaryDocument",
|
||||
function () {
|
||||
var bytes = Clazz.newByteArray (40, 0);
|
||||
this.binaryDoc.setStream (null, this.binaryDoc.readInt () == 0x54);
|
||||
this.binaryDoc.readInt ();
|
||||
this.nModels = this.binaryDoc.readInt ();
|
||||
var nPriv = this.binaryDoc.readInt ();
|
||||
var nSaveC = this.binaryDoc.readInt ();
|
||||
var nStep = this.binaryDoc.readInt ();
|
||||
this.binaryDoc.readInt ();
|
||||
this.binaryDoc.readInt ();
|
||||
this.binaryDoc.readInt ();
|
||||
var ndegf = this.binaryDoc.readInt ();
|
||||
this.nFree = Clazz.doubleToInt (ndegf / 3);
|
||||
var nFixed = this.binaryDoc.readInt ();
|
||||
var delta4 = this.binaryDoc.readInt ();
|
||||
this.crystGroup = this.binaryDoc.readInt ();
|
||||
this.binaryDoc.readByteArray (bytes, 0, 32);
|
||||
this.binaryDoc.readInt ();
|
||||
this.binaryDoc.readInt ();
|
||||
this.binaryDoc.readInt ();
|
||||
var sb = new JU.SB ();
|
||||
for (var i = 0, n = this.binaryDoc.readInt (); i < n; i++) sb.append (this.trimString (this.binaryDoc.readString (80))).appendC ('\n');
|
||||
|
||||
this.binaryDoc.readInt ();
|
||||
JU.Logger.info ("BinaryDcdReadaer:\n" + sb);
|
||||
this.binaryDoc.readInt ();
|
||||
this.nAtoms = this.binaryDoc.readInt ();
|
||||
this.binaryDoc.readInt ();
|
||||
this.nFree = this.nAtoms - nFixed;
|
||||
if (nFixed != 0) {
|
||||
this.binaryDoc.readInt ();
|
||||
this.bsFree = JU.BS.newN (this.nFree);
|
||||
for (var i = 0; i < this.nFree; i++) this.bsFree.set (this.binaryDoc.readInt () - 1);
|
||||
|
||||
this.binaryDoc.readInt ();
|
||||
JU.Logger.info ("free: " + this.bsFree.cardinality () + " " + JU.Escape.eBS (this.bsFree));
|
||||
}this.readCoordinates ();
|
||||
JU.Logger.info ("Total number of trajectory steps=" + this.trajectorySteps.size ());
|
||||
});
|
||||
Clazz.defineMethod (c$, "trimString",
|
||||
function (s) {
|
||||
var pt = s.indexOf ('\0');
|
||||
if (pt >= 0) s = s.substring (0, pt);
|
||||
return s.trim ();
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readFloatArray",
|
||||
function () {
|
||||
var n = Clazz.doubleToInt (this.binaryDoc.readInt () / 4);
|
||||
var data = Clazz.newFloatArray (n, 0);
|
||||
for (var i = 0; i < n; i++) data[i] = this.binaryDoc.readFloat ();
|
||||
|
||||
this.binaryDoc.readInt ();
|
||||
return data;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readDoubleArray",
|
||||
function () {
|
||||
var n = Clazz.doubleToInt (this.binaryDoc.readInt () / 8);
|
||||
var data = Clazz.newDoubleArray (n, 0);
|
||||
for (var i = 0; i < n; i++) data[i] = this.binaryDoc.readDouble ();
|
||||
|
||||
this.binaryDoc.readInt ();
|
||||
return data;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCoordinates",
|
||||
function () {
|
||||
var ac = (this.bsFilter == null ? this.templateAtomCount : (this.htParams.get ("filteredAtomCount")).intValue ());
|
||||
for (var i = 0; i < this.nModels; i++) if (this.doGetModel (++this.modelNumber, null)) {
|
||||
var trajectoryStep = new Array (ac);
|
||||
if (!this.getTrajectoryStep (trajectoryStep)) return;
|
||||
this.trajectorySteps.addLast (trajectoryStep);
|
||||
if (this.isLastModel (this.modelNumber)) return;
|
||||
} else {
|
||||
if (this.crystGroup > 0) this.readDoubleArray ();
|
||||
this.readFloatArray ();
|
||||
this.readFloatArray ();
|
||||
this.readFloatArray ();
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getTrajectoryStep",
|
||||
function (trajectoryStep) {
|
||||
try {
|
||||
var ac = trajectoryStep.length;
|
||||
var n = -1;
|
||||
if (this.crystGroup > 0) this.calcUnitCell (this.readDoubleArray ());
|
||||
var x = this.readFloatArray ();
|
||||
var y = this.readFloatArray ();
|
||||
var z = this.readFloatArray ();
|
||||
var bs = (this.xAll == null ? null : this.bsFree);
|
||||
if (bs == null) {
|
||||
this.xAll = x;
|
||||
this.yAll = y;
|
||||
this.zAll = z;
|
||||
}for (var i = 0, vpt = 0; i < this.nAtoms; i++) {
|
||||
var pt = new JU.P3 ();
|
||||
if (bs == null || bs.get (i)) {
|
||||
pt.set (x[vpt], y[vpt], z[vpt]);
|
||||
vpt++;
|
||||
} else {
|
||||
pt.set (this.xAll[i], this.yAll[i], this.zAll[i]);
|
||||
}if (this.bsFilter == null || this.bsFilter.get (i)) {
|
||||
if (++n == ac) return true;
|
||||
trajectoryStep[n] = pt;
|
||||
}}
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
return false;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "calcUnitCell",
|
||||
function (abc) {
|
||||
var a = abc[0];
|
||||
var angle1 = abc[1];
|
||||
var b = abc[2];
|
||||
var angle2 = abc[3];
|
||||
var angle3 = abc[4];
|
||||
var c = abc[5];
|
||||
var alpha = (1.5707963267948966 - Math.asin (angle3)) * 180 / 3.141592653589793;
|
||||
var beta = (1.5707963267948966 - Math.asin (angle2)) * 180 / 3.141592653589793;
|
||||
var gamma = (1.5707963267948966 - Math.asin (angle1)) * 180 / 3.141592653589793;
|
||||
System.out.println ("unitcell:[" + a + " " + b + " " + c + " " + alpha + " " + beta + " " + gamma + "]");
|
||||
return Clazz.newFloatArray (-1, [a, b, c, alpha, beta, gamma]);
|
||||
}, "~A");
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.more");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader", "java.util.Properties"], "J.adapter.readers.more.ForceFieldReader", ["java.lang.Character", "JU.PT", "J.adapter.smarter.Atom"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.userAtomTypes = null;
|
||||
this.atomTypes = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.more, "ForceFieldReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.atomTypes = new java.util.Properties ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "setUserAtomTypes",
|
||||
function () {
|
||||
this.userAtomTypes = this.htParams.get ("atomTypes");
|
||||
if (this.userAtomTypes != null) this.userAtomTypes = ";" + this.userAtomTypes + ";";
|
||||
});
|
||||
Clazz.defineMethod (c$, "getElementSymbol",
|
||||
function (atom, atomType) {
|
||||
var elementSymbol = this.atomTypes.get (atomType);
|
||||
if (elementSymbol != null) {
|
||||
atom.elementSymbol = elementSymbol;
|
||||
return true;
|
||||
}var nChar = atomType.length;
|
||||
var haveSymbol = (nChar < 2);
|
||||
var ptType;
|
||||
if (this.userAtomTypes != null && (ptType = this.userAtomTypes.indexOf (";" + atomType + "=>")) >= 0) {
|
||||
ptType += nChar + 3;
|
||||
elementSymbol = this.userAtomTypes.substring (ptType, this.userAtomTypes.indexOf (";", ptType)).trim ();
|
||||
haveSymbol = true;
|
||||
} else if (nChar == 1) {
|
||||
elementSymbol = atomType.toUpperCase ();
|
||||
haveSymbol = true;
|
||||
} else {
|
||||
var ch0 = atomType.charAt (0);
|
||||
var ch1 = atomType.charAt (1);
|
||||
var isXx = (JU.PT.isUpperCase (ch0) && JU.PT.isLowerCase (ch1));
|
||||
if (" IM IP sz az sy ay ayt ".indexOf (atomType) >= 0) {
|
||||
if (ch0 == 'I') {
|
||||
elementSymbol = atom.atomName.substring (0, 2);
|
||||
if (!JU.PT.isLowerCase (elementSymbol.charAt (1))) elementSymbol = elementSymbol.substring (0, 1);
|
||||
} else {
|
||||
elementSymbol = (ch0 == 's' ? "Si" : "Al");
|
||||
}} else if (nChar == 2 && isXx) {
|
||||
} else if (JU.PT.isLetter (ch0) && !JU.PT.isLetter (ch1)) {
|
||||
elementSymbol = "" + Character.toUpperCase (ch0);
|
||||
} else if (nChar > 2 && isXx && !JU.PT.isLetter (atomType.charAt (2))) {
|
||||
elementSymbol = "" + ch0 + ch1;
|
||||
} else {
|
||||
ch0 = Character.toUpperCase (ch0);
|
||||
var check = " " + atomType + " ";
|
||||
if (" CA CB CC CD CE CF CG CH CI CJ CK CM CN CP CQ CR CT CV CW HA HP HC HO HS HW LP NA NB NC NT OH OS OW SH AH BH HT HY AC BC CS OA OB OE OT dw hc hi hn ho hp hs hw hscp htip ca cg ci cn co coh cp cr cs ct c3h c3m c4h c4m na nb nh nho nh+ ni nn np npc nr nt nz oc oe oh op oscp otip sc sh sp br cl ca+ ar si lp nu sz oz az pz ga ge tioc titd li+ na+ rb+ cs+ mg2+ ca2+ ba2+ cu2+ cl- br- so4 sy oy ay ayt nac+ mg2c fe2c mn4c mn3c co2c ni2c lic+ pd2+ ti4c sr2c ca2c cly- hocl py vy nh4+ so4y lioh naoh koh foh cloh beoh al CE1 CF1 CF2 CF3 CG CD2 CH1E CH2E CH3E CM CP3 CPH1 CPH2 CQ66 CR55 CR56 CR66 CS66 CT CT3 CT4 CUA1 CUA2 CUA3 CUY1 CUY2 HA HC HMU HO HT LP NC NC2 NO2 NP NR1 NR2 NR3 NR55 NR56 NR66 NT NX OA OAC OC OE OH2 OK OM OS OSH OSI OT OW PO3 PO4 PT PUA1 PUY1 SE SH1E SK SO1 SO2 SO3 SO4 ST ST2 ST2 br br- br1 cl cl- cl1 cl12 cl13 cl14 cl1p ca+ cu+2 fe+2 mg+2 zn+2 cs+ li+ na+ rb+ al4z si si4 si4c si4z ar he kr ne xe dw hi hw ca cg ci co coh cp cr cs ct ct3 na nb nh nho ni no np nt nt2 nz oa oc oh op os ot sp bt cl\' si4l si5l si5t si6 si6o si\' br ca cc cd ce cf cl cp cq cu cv cx cy ha hc hn ho hp hs na nb nc nd nh oh os pb pc pd pe pf px py sh ss sx sy hn2 ho2 cz oo oz si sio hsi osi ".indexOf (check) < 0) {
|
||||
} else if (" AH BH AC BC ".indexOf (check) >= 0) {
|
||||
elementSymbol = "" + ch1;
|
||||
} else if (" al al4z ar ba2+ beoh br br- br1 ca+ ca2+ ca2c cl cl\' cl- cl1 cl12 cl13 cl14 cl1p cloh cly- co2c cs+ cu+2 cu2+ fe+2 fe2c ga ge he kr li+ lic+ lioh lp LP mg+2 mg2+ mg2c mn3c mn4c na+ nac+ naoh ne ni2c nu pd2+ rb+ si si\' si4 si4c si4l si4z si5l si5t si6 si6o sio sr2c ti4c tioc titd xe zn+2 ".indexOf (check) >= 0) {
|
||||
elementSymbol = "" + ch0 + ch1;
|
||||
} else {
|
||||
elementSymbol = "" + ch0;
|
||||
}}if (elementSymbol == null) {
|
||||
elementSymbol = "" + ch0 + Character.toLowerCase (ch1);
|
||||
} else {
|
||||
haveSymbol = true;
|
||||
}}atom.elementSymbol = elementSymbol;
|
||||
if (haveSymbol) this.atomTypes.put (atomType, elementSymbol);
|
||||
return haveSymbol;
|
||||
}, "J.adapter.smarter.Atom,~S");
|
||||
c$.deducePdbElementSymbol = Clazz.defineMethod (c$, "deducePdbElementSymbol",
|
||||
function (isHetero, XX, group3) {
|
||||
var i = XX.indexOf ('\0');
|
||||
var atomType = null;
|
||||
if (i >= 0) {
|
||||
atomType = XX.substring (i + 1);
|
||||
XX = XX.substring (0, i);
|
||||
if (atomType != null && atomType.length == 1) return atomType;
|
||||
}if (XX.equalsIgnoreCase (group3)) return XX;
|
||||
var len = XX.length;
|
||||
var ch1 = ' ';
|
||||
i = 0;
|
||||
while (i < len && (ch1 = XX.charAt (i++)) <= '9') {
|
||||
}
|
||||
var ch2 = (i < len ? XX.charAt (i) : ' ');
|
||||
var full = group3 + "." + ch1 + ch2;
|
||||
if (("OEC.CA ICA.CA OC1.CA OC2.CA OC4.CA").indexOf (full) >= 0) return "Ca";
|
||||
if (XX.indexOf ("'") > 0 || XX.indexOf ("*") >= 0 || "HCNO".indexOf (ch1) >= 0 && ch2 <= 'H' || XX.startsWith ("CM")) return "" + ch1;
|
||||
if (isHetero && J.adapter.smarter.Atom.isValidSymNoCase (ch1, ch2)) return ("" + ch1 + ch2).trim ();
|
||||
if (J.adapter.smarter.Atom.isValidSym1 (ch1)) return "" + ch1;
|
||||
if (J.adapter.smarter.Atom.isValidSym1 (ch2)) return "" + ch2;
|
||||
return "Xx";
|
||||
}, "~B,~S,~S");
|
||||
Clazz.defineStatics (c$,
|
||||
"ffTypes", " CA CB CC CD CE CF CG CH CI CJ CK CM CN CP CQ CR CT CV CW HA HP HC HO HS HW LP NA NB NC NT OH OS OW SH AH BH HT HY AC BC CS OA OB OE OT dw hc hi hn ho hp hs hw hscp htip ca cg ci cn co coh cp cr cs ct c3h c3m c4h c4m na nb nh nho nh+ ni nn np npc nr nt nz oc oe oh op oscp otip sc sh sp br cl ca+ ar si lp nu sz oz az pz ga ge tioc titd li+ na+ rb+ cs+ mg2+ ca2+ ba2+ cu2+ cl- br- so4 sy oy ay ayt nac+ mg2c fe2c mn4c mn3c co2c ni2c lic+ pd2+ ti4c sr2c ca2c cly- hocl py vy nh4+ so4y lioh naoh koh foh cloh beoh al CE1 CF1 CF2 CF3 CG CD2 CH1E CH2E CH3E CM CP3 CPH1 CPH2 CQ66 CR55 CR56 CR66 CS66 CT CT3 CT4 CUA1 CUA2 CUA3 CUY1 CUY2 HA HC HMU HO HT LP NC NC2 NO2 NP NR1 NR2 NR3 NR55 NR56 NR66 NT NX OA OAC OC OE OH2 OK OM OS OSH OSI OT OW PO3 PO4 PT PUA1 PUY1 SE SH1E SK SO1 SO2 SO3 SO4 ST ST2 ST2 br br- br1 cl cl- cl1 cl12 cl13 cl14 cl1p ca+ cu+2 fe+2 mg+2 zn+2 cs+ li+ na+ rb+ al4z si si4 si4c si4z ar he kr ne xe dw hi hw ca cg ci co coh cp cr cs ct ct3 na nb nh nho ni no np nt nt2 nz oa oc oh op os ot sp bt cl\' si4l si5l si5t si6 si6o si\' br ca cc cd ce cf cl cp cq cu cv cx cy ha hc hn ho hp hs na nb nc nd nh oh os pb pc pd pe pf px py sh ss sx sy hn2 ho2 cz oo oz si sio hsi osi ",
|
||||
"twoChar", " al al4z ar ba2+ beoh br br- br1 ca+ ca2+ ca2c cl cl' cl- cl1 cl12 cl13 cl14 cl1p cloh cly- co2c cs+ cu+2 cu2+ fe+2 fe2c ga ge he kr li+ lic+ lioh lp LP mg+2 mg2+ mg2c mn3c mn4c na+ nac+ naoh ne ni2c nu pd2+ rb+ si si' si4 si4c si4l si4z si5l si5t si6 si6o sio sr2c ti4c tioc titd xe zn+2 ",
|
||||
"specialTypes", " IM IP sz az sy ay ayt ",
|
||||
"secondCharOnly", " AH BH AC BC ");
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.more");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.more.GromacsReader", ["java.lang.Float", "JU.P3", "J.adapter.smarter.Atom", "JU.Logger"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.more, "GromacsReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.setIsPDB ();
|
||||
this.asc.newAtomSet ();
|
||||
this.setModelPDB (true);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
this.checkCurrentLineForScript ();
|
||||
this.asc.setAtomSetName (this.line.trim ());
|
||||
this.readAtoms ();
|
||||
this.readUnitCell ();
|
||||
this.continuing = false;
|
||||
return false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
var modelAtomCount = this.parseIntStr (this.rd ());
|
||||
for (var i = 0; i < modelAtomCount; ++i) {
|
||||
this.rd ();
|
||||
var len = this.line.length;
|
||||
if (len != 44 && len != 68) {
|
||||
JU.Logger.warn ("line cannot be read for GROMACS atom data: " + this.line);
|
||||
continue;
|
||||
}var atom = new J.adapter.smarter.Atom ();
|
||||
atom.sequenceNumber = this.parseIntRange (this.line, 0, 5);
|
||||
this.setAtomName (atom, this.parseTokenRange (this.line, 5, 9).trim (), this.line.substring (11, 15).trim ());
|
||||
atom.atomSerial = this.parseIntRange (this.line, 15, 20);
|
||||
atom.x = this.parseFloatRange (this.line, 20, 28) * 10;
|
||||
atom.y = this.parseFloatRange (this.line, 28, 36) * 10;
|
||||
atom.z = this.parseFloatRange (this.line, 36, 44) * 10;
|
||||
if (Float.isNaN (atom.x) || Float.isNaN (atom.y) || Float.isNaN (atom.z)) {
|
||||
JU.Logger.warn ("line cannot be read for GROMACS atom data: " + this.line);
|
||||
atom.set (0, 0, 0);
|
||||
}this.setAtomCoord (atom);
|
||||
atom.elementSymbol = this.deduceElementSymbol (atom.group3, atom.atomName);
|
||||
if (!this.filterAtom (atom, i)) continue;
|
||||
atom.isHetero = false;
|
||||
this.asc.addAtom (atom);
|
||||
if (len < 69) continue;
|
||||
var vx = this.parseFloatRange (this.line, 44, 52) * 10;
|
||||
var vy = this.parseFloatRange (this.line, 52, 60) * 10;
|
||||
var vz = this.parseFloatRange (this.line, 60, 68) * 10;
|
||||
if (Float.isNaN (vx) || Float.isNaN (vy) || Float.isNaN (vz)) continue;
|
||||
this.asc.addVibrationVector (atom.index, vx, vy, vz);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "setAtomName",
|
||||
function (atom, gname, aname) {
|
||||
atom.atomName = aname;
|
||||
if (gname.equals ("SOL") && aname.length == 3 && "OW1;HW2;HW3".indexOf (aname) >= 0) gname = "WAT";
|
||||
atom.group3 = gname;
|
||||
}, "J.adapter.smarter.Atom,~S,~S");
|
||||
Clazz.defineMethod (c$, "deduceElementSymbol",
|
||||
function (group3, atomName) {
|
||||
if (atomName.length <= 2 && group3.equals (atomName)) return atomName;
|
||||
var ch1 = (atomName.length == 4 ? atomName.charAt (0) : '\0');
|
||||
var ch2 = atomName.charAt (atomName.length == 4 ? 1 : 0);
|
||||
var isHetero = this.vwr.getJBR ().isHetero (group3);
|
||||
if (J.adapter.smarter.Atom.isValidSymNoCase (ch1, ch2)) return (isHetero || ch1 != 'H' ? "" + ch1 + ch2 : "H");
|
||||
if (J.adapter.smarter.Atom.isValidSym1 (ch2)) return "" + ch2;
|
||||
if (J.adapter.smarter.Atom.isValidSym1 (ch1)) return "" + ch1;
|
||||
return "Xx";
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "readUnitCell",
|
||||
function () {
|
||||
if (this.rd () == null) return;
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length < 3 || !this.doApplySymmetry) return;
|
||||
var a = 10 * this.parseFloatStr (tokens[0]);
|
||||
var b = 10 * this.parseFloatStr (tokens[1]);
|
||||
var c = 10 * this.parseFloatStr (tokens[2]);
|
||||
this.setUnitCell (a, b, c, 90, 90, 90);
|
||||
this.setSpaceGroupName ("P1");
|
||||
var atoms = this.asc.atoms;
|
||||
var pt = JU.P3.new3 (0.5, 0.5, 0.5);
|
||||
for (var i = this.asc.ac; --i >= 0; ) {
|
||||
this.setAtomCoord (atoms[i]);
|
||||
atoms[i].add (pt);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,287 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.more");
|
||||
Clazz.load (["J.adapter.readers.molxyz.MolReader", "J.api.JmolJDXMOLReader", "JU.Lst"], "J.adapter.readers.more.JcampdxReader", ["java.lang.Float", "JU.BS", "$.PT", "$.Rdr", "J.adapter.smarter.SmarterJmolAdapter", "J.api.Interface", "JU.BSUtil", "$.Logger", "JV.JC"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.selectedModel = 0;
|
||||
this.mpr = null;
|
||||
this.acdMolFile = null;
|
||||
this.nPeaks = 0;
|
||||
this.acdAssignments = null;
|
||||
this.title = null;
|
||||
this.nucleus = "";
|
||||
this.type = null;
|
||||
this.peakData = null;
|
||||
this.allTypes = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.more, "JcampdxReader", J.adapter.readers.molxyz.MolReader, J.api.JmolJDXMOLReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.peakData = new JU.Lst ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.vwr.setBooleanProperty ("_JSpecView".toLowerCase (), true);
|
||||
if (this.isTrajectory) {
|
||||
JU.Logger.warn ("TRAJECTORY keyword ignored");
|
||||
this.isTrajectory = false;
|
||||
}if (this.reverseModels) {
|
||||
JU.Logger.warn ("REVERSE keyword ignored");
|
||||
this.reverseModels = false;
|
||||
}this.selectedModel = this.desiredModelNumber;
|
||||
this.desiredModelNumber = -2147483648;
|
||||
if (!this.checkFilterKey ("NOSYNC")) this.addJmolScript ("sync on");
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
var i = this.line.indexOf ("=");
|
||||
if (i < 0 || !this.line.startsWith ("##")) return true;
|
||||
var label = JU.PT.replaceAllCharacters (this.line.substring (0, i).trim (), " ", "").toUpperCase ();
|
||||
if (label.length > 12) label = label.substring (0, 12);
|
||||
var pt = ("##$MODELS ##$PEAKS ##$SIGNALS ##$MOLFILE ##NPOINTS ##TITLE ##PEAKASSIGN##$UVIR_ASSI##$MS_FRAGME##.OBSERVENU##DATATYPE ").indexOf (label);
|
||||
if (pt < 0) return true;
|
||||
if (this.mpr == null) this.mpr = (J.api.Interface.getOption ("jsv.JDXMOLParser", this.vwr, "file")).set (this, this.filePath, this.htParams);
|
||||
var value = this.line.substring (i + 1).trim ();
|
||||
this.mpr.setLine (value);
|
||||
switch (pt) {
|
||||
case 0:
|
||||
this.mpr.readModels ();
|
||||
break;
|
||||
case 12:
|
||||
case 24:
|
||||
this.mpr.readPeaks (pt == 24, -1);
|
||||
break;
|
||||
case 36:
|
||||
this.acdMolFile = this.mpr.readACDMolFile ();
|
||||
this.processModelData (this.acdMolFile, this.title + " (assigned)", "MOL", "mol", "", 0.01, NaN, true);
|
||||
if (this.asc.errorMessage != null) {
|
||||
this.continuing = false;
|
||||
return false;
|
||||
}break;
|
||||
case 48:
|
||||
this.nPeaks = JU.PT.parseInt (value);
|
||||
break;
|
||||
case 60:
|
||||
this.title = JU.PT.split (value, "$$")[0].trim ();
|
||||
break;
|
||||
case 72:
|
||||
case 84:
|
||||
case 96:
|
||||
this.acdAssignments = this.mpr.readACDAssignments (this.nPeaks, pt == 72);
|
||||
break;
|
||||
case 108:
|
||||
this.nucleus = value.substring (1);
|
||||
break;
|
||||
case 120:
|
||||
this.type = value;
|
||||
if ((pt = this.type.indexOf (" ")) >= 0) this.type = this.type.substring (0, pt);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
if (this.mpr != null) this.processPeakData ();
|
||||
this.finalizeReaderMR ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processModelData",
|
||||
function (data, id, type, base, last, modelScale, vibScale, isFirst) {
|
||||
var model0 = this.asc.iSet;
|
||||
var model = null;
|
||||
while (true) {
|
||||
var ret = J.adapter.smarter.SmarterJmolAdapter.staticGetAtomSetCollectionReader (this.filePath, type, JU.Rdr.getBR (data), this.htParams);
|
||||
if (Clazz.instanceOf (ret, String)) {
|
||||
JU.Logger.warn ("" + ret);
|
||||
if ((ret).startsWith (JV.JC.READER_NOT_FOUND)) this.asc.errorMessage = ret;
|
||||
break;
|
||||
}ret = J.adapter.smarter.SmarterJmolAdapter.staticGetAtomSetCollection (ret);
|
||||
if (Clazz.instanceOf (ret, String)) {
|
||||
JU.Logger.warn ("" + ret);
|
||||
break;
|
||||
}model = ret;
|
||||
var baseModel = base;
|
||||
if (baseModel.length == 0) baseModel = last;
|
||||
if (baseModel.length != 0) {
|
||||
var ibase = this.findModelById (baseModel);
|
||||
if (ibase >= 0) {
|
||||
this.asc.setModelInfoForSet ("jdxModelID", baseModel, ibase);
|
||||
for (var i = model.atomSetCount; --i >= 0; ) model.setModelInfoForSet ("jdxBaseModel", baseModel, i);
|
||||
|
||||
if (model.bondCount == 0) this.setBonding (model, ibase);
|
||||
}}if (!Float.isNaN (vibScale)) {
|
||||
JU.Logger.info ("JcampdxReader applying vibration scaling of " + vibScale + " to " + model.ac + " atoms");
|
||||
var atoms = model.atoms;
|
||||
for (var i = model.ac; --i >= 0; ) {
|
||||
if (atoms[i].vib != null && !Float.isNaN (atoms[i].vib.z)) atoms[i].vib.scale (vibScale);
|
||||
}
|
||||
}if (!Float.isNaN (modelScale)) {
|
||||
JU.Logger.info ("JcampdxReader applying model scaling of " + modelScale + " to " + model.ac + " atoms");
|
||||
var atoms = model.atoms;
|
||||
for (var i = model.ac; --i >= 0; ) atoms[i].scale (modelScale);
|
||||
|
||||
}JU.Logger.info ("jdx model=" + id + " type=" + model.fileTypeName);
|
||||
this.asc.appendAtomSetCollection (-1, model);
|
||||
break;
|
||||
}
|
||||
this.updateModelIDs (id, model0, isFirst);
|
||||
}, "~S,~S,~S,~S,~S,~N,~N,~B");
|
||||
Clazz.defineMethod (c$, "setBonding",
|
||||
function (a, ibase) {
|
||||
var n0 = this.asc.getAtomSetAtomCount (ibase);
|
||||
var n = a.ac;
|
||||
if (n % n0 != 0) {
|
||||
JU.Logger.warn ("atom count in secondary model (" + n + ") is not a multiple of " + n0 + " -- bonding ignored");
|
||||
return;
|
||||
}var bonds = this.asc.bonds;
|
||||
var b0 = 0;
|
||||
for (var i = 0; i < ibase; i++) b0 += this.asc.getAtomSetBondCount (i);
|
||||
|
||||
var b1 = b0 + this.asc.getAtomSetBondCount (ibase);
|
||||
var ii0 = this.asc.getAtomSetAtomIndex (ibase);
|
||||
var nModels = a.atomSetCount;
|
||||
for (var j = 0; j < nModels; j++) {
|
||||
var i0 = a.getAtomSetAtomIndex (j) - ii0;
|
||||
if (a.getAtomSetAtomCount (j) != n0) {
|
||||
JU.Logger.warn ("atom set atom count in secondary model (" + a.getAtomSetAtomCount (j) + ") is not equal to " + n0 + " -- bonding ignored");
|
||||
return;
|
||||
}for (var i = b0; i < b1; i++) a.addNewBondWithOrder (bonds[i].atomIndex1 + i0, bonds[i].atomIndex2 + i0, bonds[i].order);
|
||||
|
||||
}
|
||||
}, "J.adapter.smarter.AtomSetCollection,~N");
|
||||
Clazz.defineMethod (c$, "updateModelIDs",
|
||||
function (id, model0, isFirst) {
|
||||
var n = this.asc.atomSetCount;
|
||||
if (isFirst && n == model0 + 2) {
|
||||
this.asc.setCurrentModelInfo ("modelID", id);
|
||||
return;
|
||||
}for (var pt = 0, i = model0; ++i < n; ) this.asc.setModelInfoForSet ("modelID", id + "." + (++pt), i);
|
||||
|
||||
}, "~S,~N,~B");
|
||||
Clazz.overrideMethod (c$, "addPeakData",
|
||||
function (info) {
|
||||
this.peakData.addLast (info);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "processPeakData",
|
||||
function () {
|
||||
if (this.acdAssignments != null) {
|
||||
try {
|
||||
this.mpr.setACDAssignments (this.title, this.nucleus + this.type, 0, this.acdAssignments, this.acdMolFile);
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}var n = this.peakData.size ();
|
||||
if (n == 0) return;
|
||||
var bsModels = new JU.BS ();
|
||||
var havePeaks = (n > 0);
|
||||
for (var p = 0; p < n; p++) {
|
||||
this.line = this.peakData.get (p);
|
||||
var type = this.mpr.getAttribute (this.line, "type");
|
||||
var id = this.mpr.getAttribute (this.line, "model");
|
||||
var i = this.findModelById (id);
|
||||
if (i < 0) {
|
||||
JU.Logger.warn ("cannot find model " + id + " required for " + this.line);
|
||||
continue;
|
||||
}this.addType (i, type);
|
||||
var title = type + ": " + this.mpr.getAttribute (this.line, "title");
|
||||
var key = "jdxAtomSelect_" + this.mpr.getAttribute (this.line, "type");
|
||||
bsModels.set (i);
|
||||
var s;
|
||||
if (this.mpr.getAttribute (this.line, "atoms").length != 0) {
|
||||
this.processPeakSelectAtom (i, key, this.line);
|
||||
s = type + ": ";
|
||||
} else if (this.processPeakSelectModel (i, title)) {
|
||||
s = "model: ";
|
||||
} else {
|
||||
s = "ignored: ";
|
||||
}JU.Logger.info (s + this.line);
|
||||
}
|
||||
n = this.asc.atomSetCount;
|
||||
for (var i = n; --i >= 0; ) {
|
||||
var id = this.asc.getAtomSetAuxiliaryInfoValue (i, "modelID");
|
||||
if (havePeaks && !bsModels.get (i) && id.indexOf (".") >= 0) {
|
||||
this.removeAtomSet (i);
|
||||
n--;
|
||||
}}
|
||||
if (this.selectedModel == -2147483648) {
|
||||
if (this.allTypes != null) this.appendLoadNote (this.allTypes);
|
||||
} else {
|
||||
if (this.selectedModel == 0) this.selectedModel = n - 1;
|
||||
for (var i = this.asc.atomSetCount; --i >= 0; ) if (i + 1 != this.selectedModel) this.removeAtomSet (i);
|
||||
|
||||
if (n > 0) this.appendLoadNote (this.asc.getAtomSetAuxiliaryInfoValue (0, "name"));
|
||||
}for (var i = this.asc.atomSetCount; --i >= 0; ) this.asc.setAtomSetNumber (i, i + 1);
|
||||
|
||||
this.asc.centralize ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "findModelById",
|
||||
function (modelID) {
|
||||
for (var i = this.asc.atomSetCount; --i >= 0; ) {
|
||||
var id = this.asc.getAtomSetAuxiliaryInfoValue (i, "modelID");
|
||||
if (modelID.equals (id)) return i;
|
||||
}
|
||||
return -1;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "addType",
|
||||
function (imodel, type) {
|
||||
var types = this.addTypeStr (this.asc.getAtomSetAuxiliaryInfoValue (imodel, "spectrumTypes"), type);
|
||||
if (types == null) return;
|
||||
this.asc.setModelInfoForSet ("spectrumTypes", types, imodel);
|
||||
var s = this.addTypeStr (this.allTypes, type);
|
||||
if (s != null) this.allTypes = s;
|
||||
}, "~N,~S");
|
||||
Clazz.defineMethod (c$, "addTypeStr",
|
||||
function (types, type) {
|
||||
if (types != null && types.contains (type)) return null;
|
||||
if (types == null) types = "";
|
||||
else types += ",";
|
||||
return types + type;
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "processPeakSelectAtom",
|
||||
function (i, key, data) {
|
||||
var peaks = this.asc.getAtomSetAuxiliaryInfoValue (i, key);
|
||||
if (peaks == null) this.asc.setModelInfoForSet (key, peaks = new JU.Lst (), i);
|
||||
peaks.addLast (data);
|
||||
}, "~N,~S,~S");
|
||||
Clazz.defineMethod (c$, "processPeakSelectModel",
|
||||
function (i, title) {
|
||||
if (this.asc.getAtomSetAuxiliaryInfoValue (i, "jdxModelSelect") != null) return false;
|
||||
this.asc.setModelInfoForSet ("name", title, i);
|
||||
this.asc.setModelInfoForSet ("jdxModelSelect", this.line, i);
|
||||
return true;
|
||||
}, "~N,~S");
|
||||
Clazz.overrideMethod (c$, "setSpectrumPeaks",
|
||||
function (nH, piUnitsX, piUnitsY) {
|
||||
}, "~N,~S,~S");
|
||||
Clazz.defineMethod (c$, "removeAtomSet",
|
||||
function (imodel) {
|
||||
if (this.asc.bsAtoms == null) this.asc.bsAtoms = JU.BSUtil.newBitSet2 (0, this.asc.ac);
|
||||
var i0 = this.asc.atomSetAtomIndexes[imodel];
|
||||
var nAtoms = this.asc.atomSetAtomCounts[imodel];
|
||||
var i1 = i0 + nAtoms;
|
||||
this.asc.bsAtoms.clearBits (i0, i1);
|
||||
for (var i = i1; i < this.asc.ac; i++) this.asc.atoms[i].atomSetIndex--;
|
||||
|
||||
for (var i = imodel + 1; i < this.asc.atomSetCount; i++) {
|
||||
this.asc.atomSetAuxiliaryInfo[i - 1] = this.asc.atomSetAuxiliaryInfo[i];
|
||||
this.asc.atomSetAtomIndexes[i - 1] = this.asc.atomSetAtomIndexes[i];
|
||||
this.asc.atomSetBondCounts[i - 1] = this.asc.atomSetBondCounts[i];
|
||||
this.asc.atomSetAtomCounts[i - 1] = this.asc.atomSetAtomCounts[i];
|
||||
this.asc.atomSetNumbers[i - 1] = this.asc.atomSetNumbers[i];
|
||||
}
|
||||
for (var i = 0; i < this.asc.bondCount; i++) this.asc.bonds[i].atomSetIndex = this.asc.atoms[this.asc.bonds[i].atomIndex1].atomSetIndex;
|
||||
|
||||
this.asc.atomSetAuxiliaryInfo[--this.asc.atomSetCount] = null;
|
||||
var n = 0;
|
||||
for (var i = 0; i < this.asc.structureCount; i++) {
|
||||
var s = this.asc.structures[i];
|
||||
if (s.modelStartEnd[0] == imodel && s.modelStartEnd[1] == imodel) {
|
||||
this.asc.structures[i] = null;
|
||||
n++;
|
||||
}}
|
||||
if (n > 0) {
|
||||
var ss = new Array (this.asc.structureCount - n);
|
||||
for (var i = 0, pt = 0; i < this.asc.structureCount; i++) if (this.asc.structures[i] != null) ss[pt++] = this.asc.structures[i];
|
||||
|
||||
this.asc.structures = ss;
|
||||
}}, "~N");
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.more");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.more.MdCrdReader", ["java.lang.Float", "JU.P3", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.ptFloat = 0;
|
||||
this.lenLine = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.more, "MdCrdReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "setup",
|
||||
function (fullPath, htParams, readerOrDocument) {
|
||||
this.requiresBSFilter = true;
|
||||
this.setupASCR (fullPath, htParams, readerOrDocument);
|
||||
}, "~S,java.util.Map,~O");
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.initializeTrajectoryFile ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
this.readCoordinates ();
|
||||
JU.Logger.info ("Total number of trajectory steps=" + this.trajectorySteps.size ());
|
||||
this.continuing = false;
|
||||
return false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCoordinates",
|
||||
function () {
|
||||
this.line = null;
|
||||
var ac = (this.bsFilter == null ? this.templateAtomCount : (this.htParams.get ("filteredAtomCount")).intValue ());
|
||||
var isPeriodic = this.htParams.containsKey ("isPeriodic");
|
||||
var floatCount = this.templateAtomCount * 3 + (isPeriodic ? 3 : 0);
|
||||
while (true) if (this.doGetModel (++this.modelNumber, null)) {
|
||||
var trajectoryStep = new Array (ac);
|
||||
if (!this.getTrajectoryStep (trajectoryStep, isPeriodic)) return;
|
||||
this.trajectorySteps.addLast (trajectoryStep);
|
||||
if (this.isLastModel (this.modelNumber)) return;
|
||||
} else {
|
||||
if (!this.skipFloats (floatCount)) return;
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getFloat",
|
||||
function () {
|
||||
while (this.line == null || this.ptFloat >= this.lenLine) {
|
||||
if (this.rd () == null) return NaN;
|
||||
this.ptFloat = 0;
|
||||
this.lenLine = this.line.length;
|
||||
}
|
||||
this.ptFloat += 8;
|
||||
return this.parseFloatRange (this.line, this.ptFloat - 8, this.ptFloat);
|
||||
});
|
||||
Clazz.defineMethod (c$, "getPoint",
|
||||
function () {
|
||||
var x = this.getFloat ();
|
||||
var y = this.getFloat ();
|
||||
var z = this.getFloat ();
|
||||
return (Float.isNaN (z) ? null : JU.P3.new3 (x, y, z));
|
||||
});
|
||||
Clazz.defineMethod (c$, "getTrajectoryStep",
|
||||
function (trajectoryStep, isPeriodic) {
|
||||
var ac = trajectoryStep.length;
|
||||
var n = -1;
|
||||
for (var i = 0; i < this.templateAtomCount; i++) {
|
||||
var pt = this.getPoint ();
|
||||
if (pt == null) return false;
|
||||
if (this.bsFilter == null || this.bsFilter.get (i)) {
|
||||
if (++n == ac) return false;
|
||||
trajectoryStep[n] = pt;
|
||||
}}
|
||||
if (isPeriodic) this.getPoint ();
|
||||
return (this.line != null);
|
||||
}, "~A,~B");
|
||||
Clazz.defineMethod (c$, "skipFloats",
|
||||
function (n) {
|
||||
var i = 0;
|
||||
while (i < n && this.rd () != null) i += this.getTokens ().length;
|
||||
|
||||
return (this.line != null);
|
||||
}, "~N");
|
||||
});
|
||||
@@ -0,0 +1,133 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.more");
|
||||
Clazz.load (["J.adapter.readers.more.ForceFieldReader"], "J.adapter.readers.more.MdTopReader", ["java.lang.Boolean", "JU.Lst", "J.adapter.smarter.Atom", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.nAtoms = 0;
|
||||
this.ac = 0;
|
||||
this.$atomTypes = null;
|
||||
this.group3s = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.more, "MdTopReader", J.adapter.readers.more.ForceFieldReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.setIsPDB ();
|
||||
this.setUserAtomTypes ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf ("%FLAG ") != 0) return true;
|
||||
this.line = this.line.substring (6).trim ();
|
||||
if (this.line.equals ("POINTERS")) this.getPointers ();
|
||||
else if (this.line.equals ("ATOM_NAME")) this.getAtomNames ();
|
||||
else if (this.line.equals ("CHARGE")) this.getCharges ();
|
||||
else if (this.line.equals ("RESIDUE_LABEL")) this.getResidueLabels ();
|
||||
else if (this.line.equals ("RESIDUE_POINTER")) this.getResiduePointers ();
|
||||
else if (this.line.equals ("AMBER_ATOM_TYPE")) this.getAtomTypes ();
|
||||
else if (this.line.equals ("MASS")) this.getMasses ();
|
||||
return false;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.finalizeReaderASCR ();
|
||||
var atoms = this.asc.atoms;
|
||||
var atom;
|
||||
for (var i = 0; i < this.ac; i++) {
|
||||
atom = atoms[i];
|
||||
atom.isHetero = this.vwr.getJBR ().isHetero (atom.group3);
|
||||
var atomType = this.$atomTypes[i];
|
||||
if (!this.getElementSymbol (atom, atomType)) atom.elementSymbol = J.adapter.readers.more.ForceFieldReader.deducePdbElementSymbol (atom.isHetero, atom.atomName, atom.group3);
|
||||
}
|
||||
var atoms2 = null;
|
||||
if (this.filter == null) {
|
||||
this.nAtoms = this.ac;
|
||||
} else {
|
||||
atoms2 = new Array (atoms.length);
|
||||
this.nAtoms = 0;
|
||||
for (var i = 0; i < this.ac; i++) if (this.filterAtom (atoms[i], i)) atoms2[this.nAtoms++] = atoms[i];
|
||||
|
||||
}for (var i = 0, j = 0, k = 0; i < this.ac; i++) {
|
||||
if (this.filter == null || this.bsFilter.get (i)) {
|
||||
if (k % 100 == 0) j++;
|
||||
this.setAtomCoordXYZ (atoms[i], (i % 100) * 2, j * 2, 0);
|
||||
}}
|
||||
if (atoms2 != null) {
|
||||
this.discardPreviousAtoms ();
|
||||
for (var i = 0; i < this.nAtoms; i++) this.asc.addAtom (atoms2[i]);
|
||||
|
||||
}JU.Logger.info ("Total number of atoms used=" + this.nAtoms);
|
||||
this.setModelPDB (true);
|
||||
this.htParams.put ("defaultType", "mdcrd");
|
||||
});
|
||||
Clazz.defineMethod (c$, "getDataBlock",
|
||||
function () {
|
||||
var vdata = new JU.Lst ();
|
||||
this.discardLinesUntilContains ("FORMAT");
|
||||
var n = J.adapter.smarter.AtomSetCollectionReader.getFortranFormatLengths (this.line.substring (this.line.indexOf ("("))).get (0).intValue ();
|
||||
var i = 0;
|
||||
var len = 0;
|
||||
while (true) {
|
||||
if (i >= len) {
|
||||
if (this.rd () == null) break;
|
||||
i = 0;
|
||||
len = this.line.length;
|
||||
if (len == 0 || this.line.indexOf ("FLAG") >= 0) break;
|
||||
}vdata.addLast (this.line.substring (i, i + n).trim ());
|
||||
i += n;
|
||||
}
|
||||
return vdata.toArray ( new Array (vdata.size ()));
|
||||
});
|
||||
Clazz.defineMethod (c$, "getPointers",
|
||||
function () {
|
||||
var tokens = this.getDataBlock ();
|
||||
this.ac = this.parseIntStr (tokens[0]);
|
||||
var isPeriodic = (tokens[27].charAt (0) != '0');
|
||||
if (isPeriodic) {
|
||||
JU.Logger.info ("Periodic type: " + tokens[27]);
|
||||
this.htParams.put ("isPeriodic", Boolean.TRUE);
|
||||
}JU.Logger.info ("Total number of atoms read=" + this.ac);
|
||||
this.htParams.put ("templateAtomCount", Integer.$valueOf (this.ac));
|
||||
for (var i = 0; i < this.ac; i++) this.asc.addAtom ( new J.adapter.smarter.Atom ());
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "getAtomTypes",
|
||||
function () {
|
||||
this.$atomTypes = this.getDataBlock ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "getCharges",
|
||||
function () {
|
||||
var data = this.getDataBlock ();
|
||||
if (data.length != this.ac) return;
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = this.ac; --i >= 0; ) atoms[i].partialCharge = this.parseFloatStr (data[i]);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "getResiduePointers",
|
||||
function () {
|
||||
var resPtrs = this.getDataBlock ();
|
||||
JU.Logger.info ("Total number of residues=" + resPtrs.length);
|
||||
var pt1 = this.ac;
|
||||
var pt2;
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = resPtrs.length; --i >= 0; ) {
|
||||
var ptr = pt2 = this.parseIntStr (resPtrs[i]) - 1;
|
||||
while (ptr < pt1) {
|
||||
if (this.group3s != null) atoms[ptr].group3 = this.group3s[i];
|
||||
atoms[ptr++].sequenceNumber = i + 1;
|
||||
}
|
||||
pt1 = pt2;
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getResidueLabels",
|
||||
function () {
|
||||
this.group3s = this.getDataBlock ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "getAtomNames",
|
||||
function () {
|
||||
var names = this.getDataBlock ();
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = 0; i < this.ac; i++) atoms[i].atomName = names[i];
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "getMasses",
|
||||
function () {
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,171 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.more");
|
||||
Clazz.load (["J.adapter.readers.more.ForceFieldReader"], "J.adapter.readers.more.Mol2Reader", ["java.lang.Character", "JU.PT", "J.adapter.smarter.Bond"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.nAtoms = 0;
|
||||
this.ac = 0;
|
||||
this.isPDB = false;
|
||||
this.lastSequenceNumber = 2147483647;
|
||||
this.chainID = 64;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.more, "Mol2Reader", J.adapter.readers.more.ForceFieldReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.setUserAtomTypes ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.equals ("@<TRIPOS>MOLECULE")) {
|
||||
if (!this.processMolecule ()) {
|
||||
return true;
|
||||
}this.continuing = !this.isLastModel (this.modelNumber);
|
||||
return false;
|
||||
}if (this.line.length != 0 && this.line.charAt (0) == '#') {
|
||||
this.checkCurrentLineForScript ();
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processMolecule",
|
||||
function () {
|
||||
this.isPDB = false;
|
||||
var thisDataSetName = this.rd ().trim ();
|
||||
if (!this.doGetModel (++this.modelNumber, thisDataSetName)) {
|
||||
return false;
|
||||
}this.lastSequenceNumber = 2147483647;
|
||||
this.chainID = 64;
|
||||
this.rd ();
|
||||
this.line += " 0 0 0 0 0 0";
|
||||
this.ac = this.parseIntStr (this.line);
|
||||
var bondCount = this.parseInt ();
|
||||
if (bondCount == 0) this.asc.setNoAutoBond ();
|
||||
var resCount = this.parseInt ();
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
if (this.rd () != null && (this.line.length == 0 || this.line.charAt (0) != '@')) {
|
||||
if (this.rd () != null && this.line.length != 0 && this.line.charAt (0) != '@') {
|
||||
if (this.line.indexOf ("jmolscript:") >= 0) {
|
||||
this.checkCurrentLineForScript ();
|
||||
if (this.line.equals ("#")) {
|
||||
this.line = "";
|
||||
}}if (this.line.length != 0) {
|
||||
thisDataSetName += ": " + this.line.trim ();
|
||||
}}}this.newAtomSet (thisDataSetName);
|
||||
while (this.line != null && !this.line.equals ("@<TRIPOS>MOLECULE")) {
|
||||
if (this.line.equals ("@<TRIPOS>ATOM")) {
|
||||
this.readAtoms (this.ac);
|
||||
this.asc.setAtomSetName (thisDataSetName);
|
||||
} else if (this.line.equals ("@<TRIPOS>BOND")) {
|
||||
this.readBonds (bondCount);
|
||||
} else if (this.line.equals ("@<TRIPOS>SUBSTRUCTURE")) {
|
||||
this.readResInfo (resCount);
|
||||
} else if (this.line.equals ("@<TRIPOS>CRYSIN")) {
|
||||
this.readCrystalInfo ();
|
||||
}this.rd ();
|
||||
}
|
||||
this.nAtoms += this.ac;
|
||||
if (this.isPDB) {
|
||||
this.setIsPDB ();
|
||||
this.setModelPDB (true);
|
||||
}this.applySymmetryAndSetTrajectory ();
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (ac) {
|
||||
if (ac == 0) return;
|
||||
var i0 = this.asc.ac;
|
||||
for (var i = 0; i < ac; ++i) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
var atomType = tokens[5];
|
||||
var name = tokens[1];
|
||||
var pt = atomType.indexOf (".");
|
||||
if (pt >= 0) {
|
||||
atom.elementSymbol = atomType.substring (0, pt);
|
||||
} else {
|
||||
atom.atomName = name;
|
||||
atom.elementSymbol = atom.getElementSymbol ();
|
||||
}atom.atomName = name + '\0' + atomType;
|
||||
atom.set (this.parseFloatStr (tokens[2]), this.parseFloatStr (tokens[3]), this.parseFloatStr (tokens[4]));
|
||||
if (tokens.length > 6) {
|
||||
atom.sequenceNumber = this.parseIntStr (tokens[6]);
|
||||
if (atom.sequenceNumber < this.lastSequenceNumber) {
|
||||
if (this.chainID == 90) this.chainID = 96;
|
||||
this.chainID++;
|
||||
}this.lastSequenceNumber = atom.sequenceNumber;
|
||||
this.setChainID (atom, "" + String.fromCharCode (this.chainID));
|
||||
}if (tokens.length > 7) atom.group3 = tokens[7];
|
||||
if (tokens.length > 8) {
|
||||
atom.partialCharge = this.parseFloatStr (tokens[8]);
|
||||
if (atom.partialCharge == Clazz.floatToInt (atom.partialCharge)) atom.formalCharge = Clazz.floatToInt (atom.partialCharge);
|
||||
}}
|
||||
var atoms = this.asc.atoms;
|
||||
var g3 = atoms[i0].group3;
|
||||
if (g3 == null) return;
|
||||
var isPDB = false;
|
||||
if (!g3.equals ("UNK") && !g3.startsWith ("RES")) {
|
||||
for (var i = this.asc.ac; --i >= i0; ) if (!g3.equals (atoms[this.asc.ac - 1].group3)) {
|
||||
isPDB = true;
|
||||
break;
|
||||
}
|
||||
if (isPDB) {
|
||||
isPDB = false;
|
||||
for (var i = this.asc.ac; --i >= i0; ) {
|
||||
var pt = this.getPDBGroupLength (atoms[i].group3);
|
||||
if (pt == 0 || pt > 3) break;
|
||||
if (this.vwr.getJBR ().isKnownPDBGroup (g3.substring (0, pt), 2147483647)) {
|
||||
isPDB = this.isPDB = true;
|
||||
break;
|
||||
}}
|
||||
}}for (var i = this.asc.ac; --i >= i0; ) {
|
||||
if (isPDB) {
|
||||
g3 = atoms[i].group3;
|
||||
g3 = g3.substring (0, this.getPDBGroupLength (g3));
|
||||
atoms[i].isHetero = this.vwr.getJBR ().isHetero (g3);
|
||||
} else {
|
||||
g3 = null;
|
||||
}atoms[i].group3 = g3;
|
||||
}
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "getPDBGroupLength",
|
||||
function (g3) {
|
||||
var pt0 = g3.length;
|
||||
var pt = pt0;
|
||||
while (--pt > 0 && Character.isDigit (g3.charAt (pt))) {
|
||||
}
|
||||
return ++pt;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readBonds",
|
||||
function (bondCount) {
|
||||
for (var i = 0; i < bondCount; ++i) {
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
var atomIndex1 = this.parseIntStr (tokens[1]);
|
||||
var atomIndex2 = this.parseIntStr (tokens[2]);
|
||||
var order = this.parseIntStr (tokens[3]);
|
||||
if (order == -2147483648) order = (tokens[3].equals ("ar") ? 515 : tokens[3].equals ("am") ? 1 : 17);
|
||||
this.asc.addBond ( new J.adapter.smarter.Bond (this.nAtoms + atomIndex1 - 1, this.nAtoms + atomIndex2 - 1, order));
|
||||
}
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readResInfo",
|
||||
function (resCount) {
|
||||
for (var i = 0; i < resCount; ++i) {
|
||||
this.rd ();
|
||||
}
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readCrystalInfo",
|
||||
function () {
|
||||
this.rd ();
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length < 6) return;
|
||||
var name = "";
|
||||
for (var i = 6; i < tokens.length; i++) name += " " + tokens[i];
|
||||
|
||||
if (name === "") name = " P1";
|
||||
else name += " *";
|
||||
name = name.substring (1);
|
||||
this.setSpaceGroupName (name);
|
||||
if (this.ignoreFileUnitCell) return;
|
||||
for (var i = 0; i < 6; i++) this.setUnitCellItem (i, this.parseFloatStr (tokens[i]));
|
||||
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = 0; i < this.ac; ++i) this.setAtomCoord (atoms[this.nAtoms + i]);
|
||||
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.more");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.more.TlsDataOnlyReader", ["java.lang.Float", "java.util.Hashtable", "JU.Lst", "$.P3", "$.PT", "$.SB", "JU.Escape", "$.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.vTlsModels = null;
|
||||
this.sbTlsErrors = null;
|
||||
this.tlsGroupID = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.more, "TlsDataOnlyReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.readTlsData ();
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readTlsData",
|
||||
function () {
|
||||
this.vTlsModels = new JU.Lst ();
|
||||
var tlsGroups;
|
||||
var tlsGroup = null;
|
||||
var ranges = null;
|
||||
var range = null;
|
||||
tlsGroups = new JU.Lst ();
|
||||
while (this.rd () != null) {
|
||||
var tokens = JU.PT.getTokens (this.line.$replace ('\'', ' '));
|
||||
if (tokens.length == 0) continue;
|
||||
if (tokens[0].equals ("TLS")) {
|
||||
tlsGroup = new java.util.Hashtable ();
|
||||
ranges = new JU.Lst ();
|
||||
tlsGroup.put ("ranges", ranges);
|
||||
tlsGroups.addLast (tlsGroup);
|
||||
tlsGroup.put ("id", Integer.$valueOf (++this.tlsGroupID));
|
||||
} else if (tokens[0].equals ("RANGE")) {
|
||||
range = new java.util.Hashtable ();
|
||||
var chain1 = tokens[1].charAt (0);
|
||||
var chain2 = tokens[3].charAt (0);
|
||||
var res1 = JU.PT.parseInt (tokens[2]);
|
||||
var res2 = JU.PT.parseInt (tokens[4]);
|
||||
if (chain1 == chain2) {
|
||||
range.put ("chains", "" + chain1 + chain2);
|
||||
if (res1 <= res2) {
|
||||
range.put ("residues", Clazz.newIntArray (-1, [res1, res2]));
|
||||
ranges.addLast (range);
|
||||
} else {
|
||||
this.tlsAddError (" TLS group residues are not in order (range ignored)");
|
||||
}} else {
|
||||
this.tlsAddError (" TLS group chains are different (range ignored)");
|
||||
}} else if (tokens[0].equals ("ORIGIN")) {
|
||||
var origin = new JU.P3 ();
|
||||
tlsGroup.put ("origin", origin);
|
||||
origin.set (this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]), this.parseFloatStr (tokens[3]));
|
||||
if (Float.isNaN (origin.x) || Float.isNaN (origin.y) || Float.isNaN (origin.z)) {
|
||||
origin.set (NaN, NaN, NaN);
|
||||
this.tlsAddError ("invalid origin: " + this.line);
|
||||
}} else if (tokens[0].equals ("T") || tokens[0].equals ("L") || tokens[0].equals ("S")) {
|
||||
var tensorType = tokens[0].charAt (0);
|
||||
var nn = (tensorType == 'S' ? J.adapter.readers.more.TlsDataOnlyReader.Snn : J.adapter.readers.more.TlsDataOnlyReader.TLnn);
|
||||
var tensor = Clazz.newFloatArray (3, 3, 0);
|
||||
tlsGroup.put ("t" + tensorType, tensor);
|
||||
for (var i = 1; i < tokens.length; i++) {
|
||||
var ti = nn[i].charCodeAt (0) - 49;
|
||||
var tj = nn[i].charCodeAt (1) - 49;
|
||||
tensor[ti][tj] = this.parseFloatStr (tokens[++i]);
|
||||
if (ti < tj) tensor[tj][ti] = tensor[ti][tj];
|
||||
}
|
||||
if (tensorType == 'S') tensor[0][0] = -tensor[0][0];
|
||||
for (var i = 0; i < 3; i++) for (var j = 0; j < 3; j++) if (Float.isNaN (tensor[i][j])) {
|
||||
this.tlsAddError ("invalid tensor: " + JU.Escape.escapeFloatAA (tensor, false));
|
||||
}
|
||||
|
||||
}}
|
||||
JU.Logger.info (this.tlsGroupID + " TLS groups read");
|
||||
var groups = new java.util.Hashtable ();
|
||||
groups.put ("groupCount", Integer.$valueOf (this.tlsGroupID));
|
||||
groups.put ("groups", tlsGroups);
|
||||
this.vTlsModels.addLast (groups);
|
||||
this.htParams.put ("vTlsModels", this.vTlsModels);
|
||||
});
|
||||
Clazz.defineMethod (c$, "tlsAddError",
|
||||
function (error) {
|
||||
if (this.sbTlsErrors == null) this.sbTlsErrors = new JU.SB ();
|
||||
this.sbTlsErrors.append (this.fileName).appendC ('\t').append ("TLS group ").appendI (this.tlsGroupID).appendC ('\t').append (error).appendC ('\n');
|
||||
}, "~S");
|
||||
c$.TLnn = c$.prototype.TLnn = Clazz.newArray (-1, ["11", "22", "33", "12", "13", "23"]);
|
||||
c$.Snn = c$.prototype.Snn = Clazz.newArray (-1, ["22", "11", "12", "13", "23", "21", "31", "32"]);
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.pdb");
|
||||
Clazz.load (["J.adapter.readers.pdb.PdbReader"], "J.adapter.readers.pdb.JmolDataReader", ["java.util.Hashtable", "JU.P3", "JU.Logger", "$.Parser"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.props = null;
|
||||
this.residueNames = null;
|
||||
this.atomNames = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.pdb, "JmolDataReader", J.adapter.readers.pdb.PdbReader);
|
||||
Clazz.overrideMethod (c$, "checkRemark",
|
||||
function () {
|
||||
while (true) {
|
||||
if (this.line.length < 30 || this.line.indexOf ("Jmol") != 11) break;
|
||||
switch ("Ppard".indexOf (this.line.substring (16, 17))) {
|
||||
case 0:
|
||||
this.props = new java.util.Hashtable ();
|
||||
this.asc.setInfo ("jmolData", this.line);
|
||||
if (!this.line.endsWith ("#noautobond")) this.line += "#noautobond";
|
||||
break;
|
||||
case 1:
|
||||
var pt1 = this.line.indexOf ("[");
|
||||
var pt2 = this.line.indexOf ("]");
|
||||
if (pt1 < 25 || pt2 <= pt1) return;
|
||||
var name = this.line.substring (25, pt1).trim ();
|
||||
this.line = this.line.substring (pt1 + 1, pt2).$replace (',', ' ');
|
||||
var tokens = this.getTokens ();
|
||||
JU.Logger.info ("reading " + name + " " + tokens.length);
|
||||
var prop = Clazz.newFloatArray (tokens.length, 0);
|
||||
for (var i = prop.length; --i >= 0; ) prop[i] = this.parseFloatStr (tokens[i]);
|
||||
|
||||
this.props.put (name, prop);
|
||||
break;
|
||||
case 2:
|
||||
this.line = this.line.substring (27);
|
||||
this.atomNames = this.getTokens ();
|
||||
JU.Logger.info ("reading atom names " + this.atomNames.length);
|
||||
break;
|
||||
case 3:
|
||||
this.line = this.line.substring (30);
|
||||
this.residueNames = this.getTokens ();
|
||||
JU.Logger.info ("reading residue names " + this.residueNames.length);
|
||||
break;
|
||||
case 4:
|
||||
JU.Logger.info (this.line);
|
||||
var data = Clazz.newFloatArray (15, 0);
|
||||
JU.Parser.parseStringInfestedFloatArray (this.line.substring (10).$replace ('=', ' ').$replace ('{', ' ').$replace ('}', ' '), null, data);
|
||||
var minXYZ = JU.P3.new3 (data[0], data[1], data[2]);
|
||||
var maxXYZ = JU.P3.new3 (data[3], data[4], data[5]);
|
||||
this.fileScaling = JU.P3.new3 (data[6], data[7], data[8]);
|
||||
this.fileOffset = JU.P3.new3 (data[9], data[10], data[11]);
|
||||
var plotScale = JU.P3.new3 (data[12], data[13], data[14]);
|
||||
if (plotScale.x <= 0) plotScale.x = 100;
|
||||
if (plotScale.y <= 0) plotScale.y = 100;
|
||||
if (plotScale.z <= 0) plotScale.z = 100;
|
||||
if (this.fileScaling.y == 0) this.fileScaling.y = 1;
|
||||
if (this.fileScaling.z == 0) this.fileScaling.z = 1;
|
||||
this.setFractionalCoordinates (true);
|
||||
this.latticeCells = Clazz.newIntArray (3, 0);
|
||||
this.asc.xtalSymmetry = null;
|
||||
this.setUnitCell (plotScale.x * 2 / (maxXYZ.x - minXYZ.x), plotScale.y * 2 / (maxXYZ.y - minXYZ.y), plotScale.z * 2 / (maxXYZ.z == minXYZ.z ? 1 : maxXYZ.z - minXYZ.z), 90, 90, 90);
|
||||
this.unitCellOffset = JU.P3.newP (plotScale);
|
||||
this.unitCellOffset.scale (-1);
|
||||
this.getSymmetry ();
|
||||
this.symmetry.toFractional (this.unitCellOffset, false);
|
||||
this.unitCellOffset.scaleAdd2 (-1.0, minXYZ, this.unitCellOffset);
|
||||
this.symmetry.setOffsetPt (this.unitCellOffset);
|
||||
this.asc.setInfo ("jmolDataScaling", Clazz.newArray (-1, [minXYZ, maxXYZ, plotScale]));
|
||||
this.doApplySymmetry = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.checkCurrentLineForScript ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "setAdditionalAtomParameters",
|
||||
function (atom) {
|
||||
if (this.residueNames != null && atom.index < this.residueNames.length) atom.group3 = this.residueNames[atom.index];
|
||||
if (this.atomNames != null && atom.index < this.atomNames.length) atom.atomName = this.atomNames[atom.index];
|
||||
}, "J.adapter.smarter.Atom");
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.asc.setCurrentModelInfo ("jmolDataProperties", this.props);
|
||||
this.finalizeReaderPDB ();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.pdb");
|
||||
Clazz.load (["J.adapter.readers.pdb.PdbReader", "JU.Lst"], "J.adapter.readers.pdb.P2nReader", null, function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.altNames = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.pdb, "P2nReader", J.adapter.readers.pdb.PdbReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.altNames = new JU.Lst ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "setAdditionalAtomParameters",
|
||||
function (atom) {
|
||||
var altName = this.line.substring (69, 72).trim ();
|
||||
if (altName.length == 0) altName = atom.atomName;
|
||||
if (this.useAltNames) atom.atomName = altName;
|
||||
else this.altNames.addLast (altName);
|
||||
}, "J.adapter.smarter.Atom");
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.finalizeReaderPDB ();
|
||||
if (!this.useAltNames) this.asc.setCurrentModelInfo ("altName", this.altNames.toArray ( new Array (this.altNames.size ())));
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.pdb");
|
||||
Clazz.load (["J.adapter.readers.pdb.PdbReader"], "J.adapter.readers.pdb.PqrReader", null, function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.pdb, "PqrReader", J.adapter.readers.pdb.PdbReader);
|
||||
Clazz.overrideMethod (c$, "setAdditionalAtomParameters",
|
||||
function (atom) {
|
||||
if (this.gromacsWideFormat) {
|
||||
atom.partialCharge = this.parseFloatRange (this.line, 60, 68);
|
||||
atom.radius = J.adapter.readers.pdb.PdbReader.fixRadius (this.parseFloatRange (this.line, 68, 76));
|
||||
} else {
|
||||
var tokens = this.getTokens ();
|
||||
var pt = tokens.length - 2 - (this.line.length > 75 ? 1 : 0);
|
||||
atom.partialCharge = this.parseFloatStr (tokens[pt++]);
|
||||
atom.radius = J.adapter.readers.pdb.PdbReader.fixRadius (this.parseFloatStr (tokens[pt]));
|
||||
}}, "J.adapter.smarter.Atom");
|
||||
});
|
||||
@@ -0,0 +1,259 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.pymol");
|
||||
Clazz.load (null, "J.adapter.readers.pymol.JmolObject", ["java.lang.Float", "JU.P3", "$.PT", "$.SB", "J.adapter.readers.pymol.PyMOLReader", "JU.BSUtil", "$.Escape"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.id = 0;
|
||||
this.bsAtoms = null;
|
||||
this.info = null;
|
||||
this.size = -1;
|
||||
this.colors = null;
|
||||
this.modelIndex = -2147483648;
|
||||
this.jmolName = null;
|
||||
this.argb = 0;
|
||||
this.translucency = 0;
|
||||
this.visible = true;
|
||||
this.rd = null;
|
||||
this.cacheID = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.pymol, "JmolObject");
|
||||
Clazz.makeConstructor (c$,
|
||||
function (id, branchNameID, bsAtoms, info) {
|
||||
this.id = id;
|
||||
this.bsAtoms = bsAtoms;
|
||||
this.info = info;
|
||||
this.jmolName = branchNameID;
|
||||
}, "~N,~S,JU.BS,~O");
|
||||
Clazz.defineMethod (c$, "offset",
|
||||
function (modelOffset, atomOffset) {
|
||||
if (modelOffset > 0) {
|
||||
if (this.modelIndex != -2147483648) this.modelIndex += modelOffset;
|
||||
switch (this.id) {
|
||||
case 1610625028:
|
||||
case 12294:
|
||||
return;
|
||||
case 4115:
|
||||
var i = (this.info).intValue ();
|
||||
if (i >= 0) this.info = Integer.$valueOf (modelOffset + i);
|
||||
return;
|
||||
case 1073742031:
|
||||
var movie = this.info;
|
||||
var frames = movie.get ("frames");
|
||||
for (var j = frames.length; --j >= 0; ) frames[j] += modelOffset;
|
||||
|
||||
return;
|
||||
}
|
||||
}if (atomOffset <= 0) return;
|
||||
if (this.id == 12290) {
|
||||
var map = (this.info).values ();
|
||||
for (var o, $o = map.iterator (); $o.hasNext () && ((o = $o.next ()) || true);) JU.BSUtil.offset (o, 0, atomOffset);
|
||||
|
||||
return;
|
||||
}if (this.bsAtoms != null) JU.BSUtil.offset (this.bsAtoms, 0, atomOffset);
|
||||
if (this.colors != null) {
|
||||
var colixes = this.colors[0];
|
||||
var c = Clazz.newShortArray (colixes.length + atomOffset, 0);
|
||||
System.arraycopy (colixes, 0, c, atomOffset, colixes.length);
|
||||
this.colors[0] = c;
|
||||
}}, "~N,~N");
|
||||
Clazz.defineMethod (c$, "finalizeObject",
|
||||
function (pymolScene, m, mepList, doCache) {
|
||||
var sm = m.sm;
|
||||
var color = "color";
|
||||
var sID;
|
||||
var sb = null;
|
||||
if (this.bsAtoms != null) this.modelIndex = this.getModelIndex (m);
|
||||
switch (this.id) {
|
||||
case 2097194:
|
||||
sm.vwr.displayAtoms (this.bsAtoms, false, false, 1275069441, true);
|
||||
return;
|
||||
case 12295:
|
||||
var bs = sm.vwr.getModelUndeletedAtomsBitSet (this.argb);
|
||||
JU.BSUtil.invertInPlace (bs, sm.vwr.ms.ac);
|
||||
sm.vwr.select (bs, false, 0, true);
|
||||
sm.restrictSelected (false, true);
|
||||
return;
|
||||
case 1610625028:
|
||||
case 12294:
|
||||
if (this.bsAtoms == null) {
|
||||
if (this.info == null) {
|
||||
sm.vwr.displayAtoms (null, true, false, 0, true);
|
||||
}sm.vwr.setObjectProp (this.info, this.id);
|
||||
} else {
|
||||
sm.vwr.displayAtoms (this.bsAtoms, this.id == 1610625028, false, 1275069441, true);
|
||||
}return;
|
||||
case 12290:
|
||||
sm.vwr.defineAtomSets (this.info);
|
||||
return;
|
||||
case 1073742031:
|
||||
sm.vwr.am.setMovie (this.info);
|
||||
return;
|
||||
case 4115:
|
||||
var frame = (this.info).intValue ();
|
||||
if (frame >= 0) {
|
||||
sm.vwr.setCurrentModelIndex (frame);
|
||||
} else {
|
||||
sm.vwr.setAnimationRange (-1, -1);
|
||||
sm.vwr.setCurrentModelIndex (-1);
|
||||
}return;
|
||||
case 1073742139:
|
||||
sm.vwr.stm.saveScene (this.jmolName, this.info);
|
||||
sm.vwr.stm.saveOrientation (this.jmolName, (this.info).get ("pymolView"));
|
||||
return;
|
||||
case 5:
|
||||
sm.loadShape (this.id);
|
||||
sm.setShapePropertyBs (this.id, "pymolLabels", this.info, this.bsAtoms);
|
||||
return;
|
||||
case 1677721602:
|
||||
break;
|
||||
case 659488:
|
||||
case 1:
|
||||
if (this.size != -1) {
|
||||
sm.setShapeSizeBs (1, this.size, null, this.bsAtoms);
|
||||
var bsBonds = (sm.getShapePropertyIndex (1, "sets", 0))[1];
|
||||
pymolScene.setUniqueBonds (bsBonds, this.id == 1);
|
||||
this.size = -1;
|
||||
}this.id = 1;
|
||||
break;
|
||||
case 1140850689:
|
||||
this.id = 0;
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
case 10:
|
||||
case 9:
|
||||
sm.loadShape (this.id);
|
||||
var bsCarb = m.getAtoms (2097188, null);
|
||||
JU.BSUtil.andNot (this.bsAtoms, bsCarb);
|
||||
break;
|
||||
case 16:
|
||||
sm.loadShape (this.id);
|
||||
sm.setShapePropertyBs (this.id, "ignore", JU.BSUtil.copyInvert (this.bsAtoms, sm.vwr.ms.ac), null);
|
||||
break;
|
||||
default:
|
||||
if (!this.visible) return;
|
||||
break;
|
||||
}
|
||||
switch (this.id) {
|
||||
case 23:
|
||||
sm.vwr.setCGO (this.info);
|
||||
break;
|
||||
case 16:
|
||||
case 0:
|
||||
case 7:
|
||||
case 20:
|
||||
case 11:
|
||||
case 9:
|
||||
case 10:
|
||||
case 24:
|
||||
if (Clazz.instanceOf (this.info, Array)) {
|
||||
sm.loadShape (this.id);
|
||||
sm.setShapePropertyBs (this.id, "params", this.info, this.bsAtoms);
|
||||
}break;
|
||||
case 6:
|
||||
if (this.modelIndex < 0) return;
|
||||
sm.loadShape (this.id);
|
||||
var md = this.info;
|
||||
md.setModelSet (m);
|
||||
var points = md.points;
|
||||
for (var i = points.size (); --i >= 0; ) (points.get (i)).mi = this.modelIndex;
|
||||
|
||||
sm.setShapePropertyBs (this.id, "measure", md, this.bsAtoms);
|
||||
return;
|
||||
case 135180:
|
||||
sID = (this.bsAtoms == null ? this.info : this.jmolName);
|
||||
if (sm.getShapeIdFromObjectName (sID) >= 0) {
|
||||
sm.vwr.setObjectProp (sID, 1610625028);
|
||||
return;
|
||||
}sb = new JU.SB ();
|
||||
sb.append ("isosurface ID ").append (JU.PT.esc (sID));
|
||||
if (this.modelIndex < 0) this.modelIndex = sm.vwr.am.cmi;
|
||||
if (this.bsAtoms == null) {
|
||||
sb.append (" model ").append (m.getModelNumberDotted (this.modelIndex)).append (" color density sigma 1.0 ").append (JU.PT.esc (this.cacheID)).append (" ").append (JU.PT.esc (sID));
|
||||
if (doCache) sb.append (";isosurface cache");
|
||||
} else {
|
||||
var lighting = (this.info)[0];
|
||||
var only = (this.info)[1];
|
||||
only = " only";
|
||||
var bsCarve = (this.info)[2];
|
||||
var carveDistance = ((this.info)[3]).floatValue ();
|
||||
var resolution = "";
|
||||
if (lighting == null) {
|
||||
lighting = "mesh nofill";
|
||||
resolution = " resolution 1.5";
|
||||
}var haveMep = JU.PT.isOneOf (sID, mepList);
|
||||
var model = m.getModelNumberDotted (this.modelIndex);
|
||||
var ignore = "";
|
||||
var type = (this.size < 0 ? " sasurface " : " solvent ");
|
||||
sb.append (" model ").append (model).append (resolution).append (" select ").append (JU.Escape.eBS (this.bsAtoms)).append (only).append (ignore).append (type).appendF (Math.abs (this.size / 1000));
|
||||
if (!haveMep) {
|
||||
if (this.argb == 0) sb.append (" map property color");
|
||||
else sb.append (";color isosurface ").append (JU.Escape.escapeColor (this.argb));
|
||||
}sb.append (";isosurface frontOnly ").append (lighting);
|
||||
if (this.translucency > 0) sb.append (";color isosurface translucent " + this.translucency);
|
||||
if (bsCarve != null && !bsCarve.isEmpty ()) sb.append (";isosurface slab within " + carveDistance + " {" + model + " and " + JU.Escape.eBS (bsCarve) + "}");
|
||||
if (doCache && !haveMep) sb.append (";isosurface cache");
|
||||
}break;
|
||||
case 1073742016:
|
||||
var mep = this.info;
|
||||
sID = mep.get (mep.size () - 2).toString ();
|
||||
var mapID = mep.get (mep.size () - 1).toString ();
|
||||
var min = J.adapter.readers.pymol.PyMOLReader.floatAt (J.adapter.readers.pymol.PyMOLReader.listAt (mep, 3), 0);
|
||||
var max = J.adapter.readers.pymol.PyMOLReader.floatAt (J.adapter.readers.pymol.PyMOLReader.listAt (mep, 3), 2);
|
||||
sb = new JU.SB ();
|
||||
sb.append (";isosurface ID ").append (JU.PT.esc (sID)).append (" map ").append (JU.PT.esc (this.cacheID)).append (" ").append (JU.PT.esc (mapID)).append (";color isosurface range " + min + " " + max + ";isosurface colorscheme rwb;set isosurfacekey true");
|
||||
if (this.translucency > 0) sb.append (";color isosurface translucent " + this.translucency);
|
||||
if (doCache) sb.append (";isosurface cache");
|
||||
break;
|
||||
case 1073742018:
|
||||
this.modelIndex = sm.vwr.am.cmi;
|
||||
var mesh = this.info;
|
||||
sID = mesh.get (mesh.size () - 2).toString ();
|
||||
sb = new JU.SB ();
|
||||
sb.append ("isosurface ID ").append (JU.PT.esc (sID)).append (" model ").append (m.getModelNumberDotted (this.modelIndex)).append (" color ").append (JU.Escape.escapeColor (this.argb)).append (" ").append (JU.PT.esc (this.cacheID)).append (" ").append (JU.PT.esc (sID)).append (" mesh nofill frontonly");
|
||||
var list = J.adapter.readers.pymol.PyMOLReader.sublistAt (mesh, [2, 0]);
|
||||
var within = J.adapter.readers.pymol.PyMOLReader.floatAt (list, 11);
|
||||
list = J.adapter.readers.pymol.PyMOLReader.listAt (list, 12);
|
||||
if (within > 0) {
|
||||
var pt = new JU.P3 ();
|
||||
sb.append (";isosurface slab within ").appendF (within).append (" [ ");
|
||||
for (var j = list.size () - 3; j >= 0; j -= 3) {
|
||||
J.adapter.readers.pymol.PyMOLReader.pointAt (list, j, pt);
|
||||
sb.append (JU.Escape.eP (pt));
|
||||
}
|
||||
sb.append (" ]");
|
||||
}if (doCache && !JU.PT.isOneOf (sID, mepList)) sb.append (";isosurface cache");
|
||||
sb.append (";set meshScale ").appendI (Clazz.doubleToInt (this.size / 500));
|
||||
break;
|
||||
case 134222850:
|
||||
sb = this.info;
|
||||
break;
|
||||
case 1112152078:
|
||||
sm.loadShape (this.id = 10);
|
||||
sm.setShapePropertyBs (this.id, "putty", this.info, this.bsAtoms);
|
||||
break;
|
||||
}
|
||||
if (sb != null) {
|
||||
sm.vwr.runScriptCautiously (sb.toString ());
|
||||
return;
|
||||
}if (this.size != -1 || this.rd != null) sm.setShapeSizeBs (this.id, this.size, this.rd, this.bsAtoms);
|
||||
if (this.argb != 0) sm.setShapePropertyBs (this.id, color, Integer.$valueOf (this.argb), this.bsAtoms);
|
||||
if (this.translucency > 0) {
|
||||
sm.setShapePropertyBs (this.id, "translucentLevel", Float.$valueOf (this.translucency), this.bsAtoms);
|
||||
sm.setShapePropertyBs (this.id, "translucency", "translucent", this.bsAtoms);
|
||||
} else if (this.colors != null) sm.setShapePropertyBs (this.id, "colors", this.colors, this.bsAtoms);
|
||||
}, "J.adapter.readers.pymol.PyMOLScene,JM.ModelSet,~S,~B");
|
||||
Clazz.defineMethod (c$, "getModelIndex",
|
||||
function (m) {
|
||||
if (this.bsAtoms == null) return -1;
|
||||
var iAtom = this.bsAtoms.nextSetBit (0);
|
||||
if (iAtom >= m.at.length) System.out.println ("PyMOL LOADING ERROR IN MERGE");
|
||||
return (iAtom < 0 ? -1 : m.at[iAtom].mi);
|
||||
}, "JM.ModelSet");
|
||||
Clazz.defineMethod (c$, "setColors",
|
||||
function (colixes, translucency) {
|
||||
this.colors = Clazz.newArray (-1, [colixes, Float.$valueOf (translucency)]);
|
||||
}, "~A,~N");
|
||||
Clazz.defineMethod (c$, "setSize",
|
||||
function (size) {
|
||||
this.size = Clazz.floatToInt (size * 1000);
|
||||
}, "~N");
|
||||
});
|
||||
@@ -0,0 +1,318 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.pymol");
|
||||
Clazz.load (["java.util.Hashtable", "JU.Lst"], "J.adapter.readers.pymol.PickleReader", ["java.lang.Double", "$.Long", "JU.AU", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.vwr = null;
|
||||
this.binaryDoc = null;
|
||||
this.stack = null;
|
||||
this.marks = null;
|
||||
this.build = null;
|
||||
this.memo = null;
|
||||
this.logging = false;
|
||||
this.id = 0;
|
||||
this.markCount = 0;
|
||||
this.filePt = 0;
|
||||
this.emptyListPt = 0;
|
||||
this.thisSection = null;
|
||||
this.inMovie = false;
|
||||
this.inNames = false;
|
||||
this.thisName = null;
|
||||
this.lastMark = 0;
|
||||
this.retrieveCount = 0;
|
||||
this.ipt = 0;
|
||||
this.aTemp = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.pymol, "PickleReader");
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.stack = new JU.Lst ();
|
||||
this.marks = new JU.Lst ();
|
||||
this.build = new JU.Lst ();
|
||||
this.memo = new java.util.Hashtable ();
|
||||
this.aTemp = Clazz.newByteArray (16, 0);
|
||||
});
|
||||
Clazz.makeConstructor (c$,
|
||||
function (doc, vwr) {
|
||||
this.binaryDoc = doc;
|
||||
this.vwr = vwr;
|
||||
this.stack.ensureCapacity (1000);
|
||||
}, "javajs.api.GenericBinaryDocument,JV.Viewer");
|
||||
Clazz.defineMethod (c$, "log",
|
||||
function (s) {
|
||||
this.vwr.log (s + "\0");
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getMap",
|
||||
function (logging) {
|
||||
this.logging = logging;
|
||||
var b;
|
||||
var i;
|
||||
var mark;
|
||||
var d;
|
||||
var o;
|
||||
var a;
|
||||
var map;
|
||||
var l;
|
||||
this.ipt = 0;
|
||||
var going = true;
|
||||
while (going) {
|
||||
b = this.binaryDoc.readByte ();
|
||||
this.ipt++;
|
||||
switch (b) {
|
||||
case 125:
|
||||
this.push ( new java.util.Hashtable ());
|
||||
break;
|
||||
case 97:
|
||||
o = this.pop ();
|
||||
(this.peek ()).addLast (o);
|
||||
break;
|
||||
case 101:
|
||||
l = this.getObjects (this.getMark ());
|
||||
if (this.inNames && this.markCount == 2) {
|
||||
var pt = this.binaryDoc.getPosition ();
|
||||
var l2 = new JU.Lst ();
|
||||
l2.addLast (Integer.$valueOf (this.filePt));
|
||||
l2.addLast (Integer.$valueOf (pt - this.filePt));
|
||||
l.addLast (l2);
|
||||
}(this.peek ()).addAll (l);
|
||||
break;
|
||||
case 71:
|
||||
d = this.binaryDoc.readDouble ();
|
||||
this.push (Double.$valueOf (d));
|
||||
break;
|
||||
case 74:
|
||||
i = this.binaryDoc.readIntLE ();
|
||||
this.push (Integer.$valueOf (i));
|
||||
break;
|
||||
case 75:
|
||||
i = this.binaryDoc.readByte () & 0xff;
|
||||
this.push (Integer.$valueOf (i));
|
||||
break;
|
||||
case 77:
|
||||
i = (this.binaryDoc.readByte () & 0xff | ((this.binaryDoc.readByte () & 0xff) << 8)) & 0xffff;
|
||||
this.push (Integer.$valueOf (i));
|
||||
break;
|
||||
case 113:
|
||||
i = this.binaryDoc.readByte ();
|
||||
this.putMemo (i, false);
|
||||
break;
|
||||
case 114:
|
||||
i = this.binaryDoc.readIntLE ();
|
||||
this.putMemo (i, true);
|
||||
break;
|
||||
case 104:
|
||||
i = this.binaryDoc.readByte ();
|
||||
o = this.getMemo (i);
|
||||
this.push (o == null ? "BINGET" + (++this.id) : o);
|
||||
break;
|
||||
case 106:
|
||||
i = this.binaryDoc.readIntLE ();
|
||||
o = this.getMemo (i);
|
||||
this.push (o == null ? "LONG_BINGET" + (++this.id) : o);
|
||||
break;
|
||||
case 85:
|
||||
i = this.binaryDoc.readByte () & 0xff;
|
||||
a = Clazz.newByteArray (i, 0);
|
||||
this.binaryDoc.readByteArray (a, 0, i);
|
||||
if (this.inNames && this.markCount == 3 && this.lastMark == this.stack.size ()) {
|
||||
this.thisName = this.bytesToString (a);
|
||||
this.filePt = this.emptyListPt;
|
||||
}this.push (a);
|
||||
break;
|
||||
case 84:
|
||||
i = this.binaryDoc.readIntLE ();
|
||||
a = Clazz.newByteArray (i, 0);
|
||||
this.binaryDoc.readByteArray (a, 0, i);
|
||||
this.push (a);
|
||||
break;
|
||||
case 87:
|
||||
i = this.binaryDoc.readIntLE ();
|
||||
a = Clazz.newByteArray (i, 0);
|
||||
this.binaryDoc.readByteArray (a, 0, i);
|
||||
this.push (a);
|
||||
break;
|
||||
case 93:
|
||||
this.emptyListPt = this.binaryDoc.getPosition () - 1;
|
||||
this.push ( new JU.Lst ());
|
||||
break;
|
||||
case 99:
|
||||
l = new JU.Lst ();
|
||||
l.addLast ("global");
|
||||
l.addLast (this.readStringAsBytes ());
|
||||
l.addLast (this.readStringAsBytes ());
|
||||
this.push (l);
|
||||
break;
|
||||
case 98:
|
||||
o = this.pop ();
|
||||
this.build.addLast (o);
|
||||
break;
|
||||
case 40:
|
||||
this.putMark (this.stack.size ());
|
||||
break;
|
||||
case 78:
|
||||
this.push (null);
|
||||
break;
|
||||
case 111:
|
||||
this.push (this.getObjects (this.getMark ()));
|
||||
break;
|
||||
case 115:
|
||||
o = this.pop ();
|
||||
var s = this.bytesToString (this.pop ());
|
||||
(this.peek ()).put (s, o);
|
||||
break;
|
||||
case 117:
|
||||
mark = this.getMark ();
|
||||
l = this.getObjects (mark);
|
||||
o = this.peek ();
|
||||
if (Clazz.instanceOf (o, JU.Lst)) {
|
||||
for (i = 0; i < l.size (); i++) (o).addLast (l.get (i));
|
||||
|
||||
} else {
|
||||
map = o;
|
||||
for (i = l.size (); --i >= 0; ) {
|
||||
o = l.get (i);
|
||||
map.put (this.bytesToString (l.get (--i)), o);
|
||||
}
|
||||
}break;
|
||||
case 46:
|
||||
going = false;
|
||||
break;
|
||||
case 116:
|
||||
this.push (this.getObjects (this.getMark ()));
|
||||
break;
|
||||
case 73:
|
||||
s = this.bytesToString (this.readStringAsBytes ());
|
||||
try {
|
||||
this.push (Integer.$valueOf (Integer.parseInt (s)));
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
var ll = Long.parseLong (s);
|
||||
this.push (Integer.$valueOf ((ll & 0xFFFFFFFF)));
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
JU.Logger.error ("Pickle reader error: " + b + " " + this.binaryDoc.getPosition ());
|
||||
}
|
||||
}
|
||||
if (logging) this.log ("");
|
||||
JU.Logger.info ("PyMOL Pickle reader cached " + this.memo.size () + " tokens; retrieved " + this.retrieveCount);
|
||||
map = this.stack.removeItemAt (0);
|
||||
if (map.size () == 0) for (i = this.stack.size (); --i >= 0; ) {
|
||||
o = this.stack.get (i--);
|
||||
a = this.stack.get (i);
|
||||
map.put (this.bytesToString (a), o);
|
||||
}
|
||||
this.memo = null;
|
||||
return map;
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "bytesToString",
|
||||
function (o) {
|
||||
try {
|
||||
return (JU.AU.isAB (o) ? String.instantialize (o, "UTF-8") : o.toString ());
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, java.io.UnsupportedEncodingException)) {
|
||||
return "";
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}, "~O");
|
||||
Clazz.defineMethod (c$, "putMemo",
|
||||
function (i, doCheck) {
|
||||
var o = this.peek ();
|
||||
if (JU.AU.isAB (o)) o = this.bytesToString (o);
|
||||
if (Clazz.instanceOf (o, String)) {
|
||||
if (doCheck && this.markCount >= 6 || this.markCount == 3 && this.inMovie) return;
|
||||
this.memo.put (Integer.$valueOf (i), o);
|
||||
}}, "~N,~B");
|
||||
Clazz.defineMethod (c$, "getMemo",
|
||||
function (i) {
|
||||
var o = this.memo.get (Integer.$valueOf (i));
|
||||
if (o == null) return o;
|
||||
this.retrieveCount++;
|
||||
return o;
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "getObjects",
|
||||
function (mark) {
|
||||
var n = this.stack.size () - mark;
|
||||
var args = new JU.Lst ();
|
||||
args.ensureCapacity (n);
|
||||
for (var i = mark; i < this.stack.size (); ++i) args.addLast (this.stack.get (i));
|
||||
|
||||
for (var i = this.stack.size (); --i >= mark; ) this.stack.removeItemAt (i);
|
||||
|
||||
return args;
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readStringAsBytes",
|
||||
function () {
|
||||
var n = 0;
|
||||
var a = this.aTemp;
|
||||
while (true) {
|
||||
var b = this.binaryDoc.readByte ();
|
||||
if (b == 0xA) break;
|
||||
if (n >= a.length) a = this.aTemp = JU.AU.arrayCopyByte (a, a.length * 2);
|
||||
a[n++] = b;
|
||||
}
|
||||
return JU.AU.arrayCopyByte (a, n);
|
||||
});
|
||||
Clazz.defineMethod (c$, "putMark",
|
||||
function (i) {
|
||||
if (this.logging) this.log ("\n " + Integer.toHexString (this.binaryDoc.getPosition ()) + " [");
|
||||
this.marks.addLast (Integer.$valueOf (this.lastMark = i));
|
||||
this.markCount++;
|
||||
switch (this.markCount) {
|
||||
case 2:
|
||||
var o = this.stack.get (i - 2);
|
||||
if (JU.AU.isAB (o)) {
|
||||
this.thisSection = this.bytesToString (o);
|
||||
this.inMovie = "movie".equals (this.thisSection);
|
||||
this.inNames = "names".equals (this.thisSection);
|
||||
}break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "getMark",
|
||||
function () {
|
||||
return this.marks.removeItemAt (--this.markCount).intValue ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "push",
|
||||
function (o) {
|
||||
if (this.logging && (Clazz.instanceOf (o, String) || Clazz.instanceOf (o, Double) || Clazz.instanceOf (o, Integer))) this.log ((Clazz.instanceOf (o, String) ? "'" + o + "'" : o) + ", ");
|
||||
this.stack.addLast (o);
|
||||
}, "~O");
|
||||
Clazz.defineMethod (c$, "peek",
|
||||
function () {
|
||||
return this.stack.get (this.stack.size () - 1);
|
||||
});
|
||||
Clazz.defineMethod (c$, "pop",
|
||||
function () {
|
||||
return this.stack.removeItemAt (this.stack.size () - 1);
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"APPEND", 97,
|
||||
"APPENDS", 101,
|
||||
"BINFLOAT", 71,
|
||||
"BININT", 74,
|
||||
"BININT1", 75,
|
||||
"BININT2", 77,
|
||||
"BINPUT", 113,
|
||||
"BINSTRING", 84,
|
||||
"BINUNICODE", 87,
|
||||
"BUILD", 98,
|
||||
"EMPTY_DICT", 125,
|
||||
"EMPTY_LIST", 93,
|
||||
"GLOBAL", 99,
|
||||
"LONG_BINPUT", 114,
|
||||
"MARK", 40,
|
||||
"NONE", 78,
|
||||
"OBJ", 111,
|
||||
"SETITEM", 115,
|
||||
"SETITEMS", 117,
|
||||
"SHORT_BINSTRING", 85,
|
||||
"STOP", 46,
|
||||
"BINGET", 104,
|
||||
"LONG_BINGET", 106,
|
||||
"TUPLE", 116,
|
||||
"INT", 73);
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,44 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.pymol");
|
||||
Clazz.load (["java.util.Hashtable", "JU.BS"], "J.adapter.readers.pymol.PyMOLGroup", null, function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.name = null;
|
||||
this.objectNameID = null;
|
||||
this.list = null;
|
||||
this.object = null;
|
||||
this.visible = true;
|
||||
this.occluded = false;
|
||||
this.bsAtoms = null;
|
||||
this.firstAtom = 0;
|
||||
this.type = 0;
|
||||
this.parent = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.pymol, "PyMOLGroup");
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.list = new java.util.Hashtable ();
|
||||
this.bsAtoms = new JU.BS ();
|
||||
});
|
||||
Clazz.makeConstructor (c$,
|
||||
function (name) {
|
||||
this.name = name;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "addList",
|
||||
function (child) {
|
||||
var group = this.list.get (child.name);
|
||||
if (group != null) return;
|
||||
this.list.put (child.name, child);
|
||||
child.parent = this;
|
||||
}, "J.adapter.readers.pymol.PyMOLGroup");
|
||||
Clazz.defineMethod (c$, "set",
|
||||
function () {
|
||||
if (this.parent != null) return;
|
||||
});
|
||||
Clazz.defineMethod (c$, "addGroupAtoms",
|
||||
function (bs) {
|
||||
this.bsAtoms.or (bs);
|
||||
if (this.parent != null) this.parent.addGroupAtoms (this.bsAtoms);
|
||||
}, "JU.BS");
|
||||
Clazz.overrideMethod (c$, "toString",
|
||||
function () {
|
||||
return this.name;
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,250 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.SlaterReader"], "J.adapter.readers.quantum.AdfReader", ["java.lang.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "J.api.JmolAdapter", "J.quantum.SlaterData", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.htSymmetries = null;
|
||||
this.vSymmetries = null;
|
||||
this.energy = null;
|
||||
this.nXX = 0;
|
||||
this.symLine = null;
|
||||
if (!Clazz.isClassDefined ("J.adapter.readers.quantum.AdfReader.SymmetryData")) {
|
||||
J.adapter.readers.quantum.AdfReader.$AdfReader$SymmetryData$ ();
|
||||
}
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "AdfReader", J.adapter.readers.quantum.SlaterReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf ("Irreducible Representations, including subspecies") >= 0) {
|
||||
this.readSymmetries ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("S F O s *** (Symmetrized Fragment Orbitals) ***") >= 0) {
|
||||
this.readSlaterBasis ();
|
||||
return true;
|
||||
}if (this.line.indexOf (" Coordinates (Cartesian, in Input Orientation)") >= 0 || this.line.indexOf ("G E O M E T R Y ***") >= 0) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.readCoordinates ();
|
||||
return true;
|
||||
}if (this.line.indexOf (" ====== Eigenvectors (rows) in BAS representation") >= 0) {
|
||||
if (this.doReadMolecularOrbitals) this.readMolecularOrbitals (JU.PT.getTokens (this.symLine)[1]);
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.indexOf ("Energy:") >= 0) {
|
||||
var tokens = JU.PT.getTokens (this.line.substring (this.line.indexOf ("Energy:")));
|
||||
this.energy = tokens[1];
|
||||
return true;
|
||||
}if (this.line.indexOf ("Vibrations") >= 0) {
|
||||
this.readFrequencies ();
|
||||
return true;
|
||||
}if (this.line.indexOf (" === ") >= 0) {
|
||||
this.symLine = this.line;
|
||||
return true;
|
||||
}if (this.line.indexOf (" ====== Eigenvectors (rows) in BAS representation") >= 0) {
|
||||
this.readMolecularOrbitals (JU.PT.getTokens (this.symLine)[1]);
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCoordinates",
|
||||
function () {
|
||||
var isGeometry = (this.line.indexOf ("G E O M E T R Y") >= 0);
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetName ("" + this.energy);
|
||||
this.discardLinesUntilContains ("----");
|
||||
var pt0 = (isGeometry ? 2 : 5);
|
||||
this.nXX = 0;
|
||||
var tokens;
|
||||
while (this.rd () != null && !this.line.startsWith (" -----")) {
|
||||
tokens = this.getTokens ();
|
||||
if (tokens.length < 5) break;
|
||||
var symbol = tokens[1];
|
||||
var name = null;
|
||||
if (symbol.indexOf (".") >= 0) {
|
||||
name = symbol;
|
||||
symbol = symbol.substring (0, symbol.indexOf ("."));
|
||||
}if (J.api.JmolAdapter.getElementNumber (symbol) < 1) this.nXX++;
|
||||
else this.addAtomXYZSymName (tokens, pt0, symbol, name);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
this.rd ();
|
||||
while (this.rd () != null) {
|
||||
while (this.rd () != null && this.line.indexOf (".") < 0 && this.line.indexOf ("====") < 0) {
|
||||
}
|
||||
if (this.line == null || this.line.indexOf (".") < 0) return;
|
||||
var frequencies = this.getTokens ();
|
||||
this.rd ();
|
||||
var iAtom0 = this.asc.ac;
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var frequencyCount = frequencies.length;
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
for (var i = 0; i < frequencyCount; ++i) {
|
||||
ignore[i] = !this.doGetVibration (++this.vibrationNumber);
|
||||
if (ignore[i]) continue;
|
||||
this.asc.cloneLastAtomSet ();
|
||||
this.asc.setAtomSetFrequency (null, null, frequencies[i], null);
|
||||
}
|
||||
this.readLines (this.nXX);
|
||||
this.fillFrequencyData (iAtom0, ac, ac, ignore, true, 0, 0, null, 0);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSymmetries",
|
||||
function () {
|
||||
this.vSymmetries = new JU.Lst ();
|
||||
this.htSymmetries = new java.util.Hashtable ();
|
||||
this.rd ();
|
||||
var index = 0;
|
||||
var syms = "";
|
||||
while (this.rd () != null && this.line.length > 1) syms += this.line;
|
||||
|
||||
var tokens = JU.PT.getTokens (syms);
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var sd = Clazz.innerTypeInstance (J.adapter.readers.quantum.AdfReader.SymmetryData, this, null, index++, tokens[i]);
|
||||
this.htSymmetries.put (tokens[i], sd);
|
||||
this.vSymmetries.addLast (sd);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSlaterBasis",
|
||||
function () {
|
||||
if (this.vSymmetries == null) return;
|
||||
var nBF = 0;
|
||||
for (var i = 0; i < this.vSymmetries.size (); i++) {
|
||||
var sd = this.vSymmetries.get (i);
|
||||
JU.Logger.info (sd.sym);
|
||||
this.discardLinesUntilContains ("=== " + sd.sym + " ===");
|
||||
if (this.line == null) {
|
||||
JU.Logger.error ("Symmetry slater basis section not found: " + sd.sym);
|
||||
return;
|
||||
}sd.nSFO = this.parseIntAt (this.rd (), 15);
|
||||
sd.nBF = this.parseIntAt (this.rd (), 75);
|
||||
var funcList = "";
|
||||
while (this.rd () != null && this.line.length > 1) funcList += this.line;
|
||||
|
||||
var tokens = JU.PT.getTokens (funcList);
|
||||
if (tokens.length != sd.nBF) return;
|
||||
sd.basisFunctions = Clazz.newIntArray (tokens.length, 0);
|
||||
for (var j = tokens.length; --j >= 0; ) {
|
||||
var n = this.parseIntStr (tokens[j]);
|
||||
if (n > nBF) nBF = n;
|
||||
sd.basisFunctions[j] = n - 1;
|
||||
}
|
||||
}
|
||||
this.slaterArray = new Array (nBF);
|
||||
this.discardLinesUntilContains ("(power of)");
|
||||
this.readLines (2);
|
||||
while (this.rd () != null && this.line.length > 3 && this.line.charAt (3) == ' ') {
|
||||
var data = this.line;
|
||||
while (this.rd ().indexOf ("---") < 0) data += this.line;
|
||||
|
||||
var tokens = JU.PT.getTokens (data);
|
||||
var nAtoms = tokens.length - 1;
|
||||
var atomList = Clazz.newIntArray (nAtoms, 0);
|
||||
for (var i = 1; i <= nAtoms; i++) atomList[i - 1] = this.parseIntStr (tokens[i]) - 1;
|
||||
|
||||
this.rd ();
|
||||
while (this.line.length >= 10) {
|
||||
data = this.line;
|
||||
while (this.rd ().length > 35 && this.line.substring (0, 35).trim ().length == 0) data += this.line;
|
||||
|
||||
tokens = JU.PT.getTokens (data);
|
||||
var isCore = tokens[0].equals ("Core");
|
||||
var pt = (isCore ? 1 : 0);
|
||||
var x = this.parseIntStr (tokens[pt++]);
|
||||
var y = this.parseIntStr (tokens[pt++]);
|
||||
var z = this.parseIntStr (tokens[pt++]);
|
||||
var r = this.parseIntStr (tokens[pt++]);
|
||||
var zeta = this.parseFloatStr (tokens[pt++]);
|
||||
for (var i = 0; i < nAtoms; i++) {
|
||||
var ptBF = this.parseIntStr (tokens[pt++]) - 1;
|
||||
this.slaterArray[ptBF] = new J.quantum.SlaterData (atomList[i], x, y, z, r, zeta, 1);
|
||||
this.slaterArray[ptBF].index = ptBF;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbitals",
|
||||
function (sym) {
|
||||
var sd = this.htSymmetries.get (sym);
|
||||
if (sd == null) return;
|
||||
var ptSym = sd.index;
|
||||
var isLast = (ptSym == this.vSymmetries.size () - 1);
|
||||
var n = 0;
|
||||
var nBF = this.slaterArray.length;
|
||||
sd.coefs = Clazz.newFloatArray (sd.nSFO, nBF, 0);
|
||||
while (n < sd.nBF) {
|
||||
this.rd ();
|
||||
var nLine = JU.PT.getTokens (this.rd ()).length;
|
||||
this.rd ();
|
||||
sd.mos = JU.AU.createArrayOfHashtable (sd.nSFO);
|
||||
var data = new Array (sd.nSFO);
|
||||
this.fillDataBlock (data, 0);
|
||||
for (var j = 1; j < nLine; j++) {
|
||||
var pt = sd.basisFunctions[n++];
|
||||
for (var i = 0; i < sd.nSFO; i++) sd.coefs[i][pt] = this.parseFloatStr (data[i][j]);
|
||||
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < sd.nSFO; i++) {
|
||||
var mo = new java.util.Hashtable ();
|
||||
mo.put ("coefficients", sd.coefs[i]);
|
||||
mo.put ("id", sym + " " + (i + 1));
|
||||
sd.mos[i] = mo;
|
||||
}
|
||||
if (!isLast) return;
|
||||
var nSym = this.htSymmetries.size ();
|
||||
this.discardLinesUntilContains (nSym == 1 ? "Orbital Energies, per Irrep" : "Orbital Energies, all Irreps");
|
||||
this.readLines (4);
|
||||
var pt = (nSym == 1 ? 0 : 1);
|
||||
if (nSym == 1) sym = this.rd ().trim ();
|
||||
while (this.rd () != null && this.line.length > 10) {
|
||||
this.line = this.line.$replace ('(', ' ').$replace (')', ' ');
|
||||
var tokens = this.getTokens ();
|
||||
var len = tokens.length;
|
||||
if (nSym > 1) sym = tokens[0];
|
||||
var moPt = this.parseIntStr (tokens[pt]);
|
||||
var occ = this.parseFloatStr (tokens[len - 4 + pt]);
|
||||
var energy = this.parseFloatStr (tokens[len - 2 + pt]);
|
||||
this.addMo (sym, moPt, occ, energy);
|
||||
}
|
||||
var iAtom0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
for (var i = 0; i < nBF; i++) this.slaterArray[i].atomNo += iAtom0 + 1;
|
||||
|
||||
this.setSlaters (true, true);
|
||||
this.sortOrbitals ();
|
||||
this.setMOs ("eV");
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "addMo",
|
||||
function (sym, moPt, occ, energy) {
|
||||
var sd = this.htSymmetries.get (sym);
|
||||
if (sd == null) {
|
||||
for (var entry, $entry = this.htSymmetries.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) if (entry.getKey ().startsWith (sym + ":")) {
|
||||
sd = entry.getValue ();
|
||||
break;
|
||||
}
|
||||
if (sd == null) return;
|
||||
}var mo = sd.mos[moPt - 1];
|
||||
mo.put ("occupancy", Float.$valueOf (occ > 2 ? 2 : occ));
|
||||
mo.put ("energy", Float.$valueOf (energy));
|
||||
mo.put ("symmetry", sd.sym + "_" + moPt);
|
||||
this.setMO (mo);
|
||||
}, "~S,~N,~N,~N");
|
||||
c$.$AdfReader$SymmetryData$ = function () {
|
||||
Clazz.pu$h(self.c$);
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
Clazz.prepareCallback (this, arguments);
|
||||
this.index = 0;
|
||||
this.sym = null;
|
||||
this.nSFO = 0;
|
||||
this.nBF = 0;
|
||||
this.coefs = null;
|
||||
this.mos = null;
|
||||
this.basisFunctions = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum.AdfReader, "SymmetryData");
|
||||
Clazz.makeConstructor (c$,
|
||||
function (a, b) {
|
||||
JU.Logger.info ("ADF reader creating SymmetryData " + b + " " + a);
|
||||
this.index = a;
|
||||
this.sym = b;
|
||||
}, "~N,~S");
|
||||
c$ = Clazz.p0p ();
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,130 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader", "java.util.Hashtable", "JU.Lst"], "J.adapter.readers.quantum.BasisFunctionReader", ["java.util.Arrays", "JU.PT", "J.quantum.QS", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.shells = null;
|
||||
this.moData = null;
|
||||
this.orbitals = null;
|
||||
this.nOrbitals = 0;
|
||||
this.ignoreMOs = false;
|
||||
this.alphaBeta = "";
|
||||
this.dfCoefMaps = null;
|
||||
this.filterTokens = null;
|
||||
this.filterIsNot = false;
|
||||
this.spin = null;
|
||||
if (!Clazz.isClassDefined ("J.adapter.readers.quantum.BasisFunctionReader.MOEnergySorter")) {
|
||||
J.adapter.readers.quantum.BasisFunctionReader.$BasisFunctionReader$MOEnergySorter$ ();
|
||||
}
|
||||
this.orbitalMaps = null;
|
||||
this.nCoef = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "BasisFunctionReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.moData = new java.util.Hashtable ();
|
||||
this.orbitals = new JU.Lst ();
|
||||
this.orbitalMaps = new java.util.Hashtable ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "filterMO",
|
||||
function () {
|
||||
var isHeader = (this.line.indexOf ('\n') == 0);
|
||||
if (!isHeader && !this.doReadMolecularOrbitals) return false;
|
||||
var isOK = true;
|
||||
this.line += " " + this.alphaBeta;
|
||||
var ucline = this.line.toUpperCase ();
|
||||
if (this.filter != null) {
|
||||
var nOK = 0;
|
||||
if (this.filterTokens == null) {
|
||||
this.filterIsNot = (this.filter.indexOf ("!") >= 0);
|
||||
this.filterTokens = JU.PT.getTokens (this.filter.$replace ('!', ' ').$replace (',', ' ').$replace (';', ' '));
|
||||
}for (var i = 0; i < this.filterTokens.length; i++) if (ucline.indexOf (this.filterTokens[i]) >= 0) {
|
||||
if (!this.filterIsNot) {
|
||||
nOK = this.filterTokens.length;
|
||||
break;
|
||||
}} else if (this.filterIsNot) {
|
||||
nOK++;
|
||||
}
|
||||
isOK = (nOK == this.filterTokens.length);
|
||||
if (!isHeader) JU.Logger.info ("filter MOs: " + isOK + " for \"" + this.line + "\"");
|
||||
}this.spin = (ucline.indexOf ("ALPHA") >= 0 ? "alpha" : ucline.indexOf ("BETA") >= 0 ? "beta" : null);
|
||||
return isOK;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setMO",
|
||||
function (mo) {
|
||||
if (this.dfCoefMaps != null) mo.put ("dfCoefMaps", this.dfCoefMaps);
|
||||
this.orbitals.addLast (mo);
|
||||
mo.put ("index", Integer.$valueOf (this.orbitals.size ()));
|
||||
if (this.spin != null) mo.put ("spin", this.spin);
|
||||
}, "java.util.Map");
|
||||
Clazz.defineMethod (c$, "getDFMap",
|
||||
function (shell, fileList, shellType, jmolList, minLength) {
|
||||
this.orbitalMaps.put (shell, fileList);
|
||||
this.moData.put ("orbitalMaps", this.orbitalMaps);
|
||||
if (fileList.equals (jmolList)) return true;
|
||||
this.getDfCoefMaps ();
|
||||
var isOK = J.quantum.QS.createDFMap (this.dfCoefMaps[shellType], fileList, jmolList, minLength);
|
||||
if (!isOK) JU.Logger.error ("Disabling orbitals of type " + shellType + " -- Cannot read orbital order for: " + fileList + "\n expecting: " + jmolList);
|
||||
return isOK;
|
||||
}, "~S,~S,~N,~S,~N");
|
||||
Clazz.defineMethod (c$, "getDfCoefMaps",
|
||||
function () {
|
||||
return (this.dfCoefMaps == null ? (this.dfCoefMaps = J.quantum.QS.getNewDfCoefMap ()) : this.dfCoefMaps);
|
||||
});
|
||||
c$.canonicalizeQuantumSubshellTag = Clazz.defineMethod (c$, "canonicalizeQuantumSubshellTag",
|
||||
function (tag) {
|
||||
var firstChar = tag.charAt (0);
|
||||
if (firstChar == 'X' || firstChar == 'Y' || firstChar == 'Z') {
|
||||
var sorted = tag.toCharArray ();
|
||||
java.util.Arrays.sort (sorted);
|
||||
return String.instantialize (sorted);
|
||||
}return tag;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "fixSlaterTypes",
|
||||
function (typeOld, typeNew) {
|
||||
if (this.shells == null) return 0;
|
||||
this.nCoef = 0;
|
||||
for (var i = this.shells.size (); --i >= 0; ) {
|
||||
var slater = this.shells.get (i);
|
||||
if (slater[1] == typeOld) slater[1] = typeNew;
|
||||
var m = this.getDfCoefMaps ()[slater[1]].length;
|
||||
this.nCoef += m;
|
||||
}
|
||||
return this.nCoef;
|
||||
}, "~N,~N");
|
||||
c$.getQuantumShellTagIDSpherical = Clazz.defineMethod (c$, "getQuantumShellTagIDSpherical",
|
||||
function (tag) {
|
||||
return J.quantum.QS.getQuantumShellTagIDSpherical (tag);
|
||||
}, "~S");
|
||||
c$.getQuantumShellTagID = Clazz.defineMethod (c$, "getQuantumShellTagID",
|
||||
function (tag) {
|
||||
return J.quantum.QS.getQuantumShellTagID (tag);
|
||||
}, "~S");
|
||||
c$.getQuantumShellTag = Clazz.defineMethod (c$, "getQuantumShellTag",
|
||||
function (id) {
|
||||
return J.quantum.QS.getQuantumShellTag (id);
|
||||
}, "~N");
|
||||
Clazz.overrideMethod (c$, "discardPreviousAtoms",
|
||||
function () {
|
||||
this.asc.discardPreviousAtoms ();
|
||||
this.moData.remove ("mos");
|
||||
this.orbitals.clear ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "clearOrbitals",
|
||||
function () {
|
||||
this.orbitals = new JU.Lst ();
|
||||
this.moData = new java.util.Hashtable ();
|
||||
this.alphaBeta = "";
|
||||
});
|
||||
c$.$BasisFunctionReader$MOEnergySorter$ = function () {
|
||||
Clazz.pu$h(self.c$);
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
Clazz.prepareCallback (this, arguments);
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum.BasisFunctionReader, "MOEnergySorter", null, java.util.Comparator);
|
||||
Clazz.overrideMethod (c$, "compare",
|
||||
function (a, b) {
|
||||
var c = ((a).get ("energy")).floatValue ();
|
||||
var d = ((b).get ("energy")).floatValue ();
|
||||
return (c < d ? -1 : c > d ? 1 : 0);
|
||||
}, "~O,~O");
|
||||
c$ = Clazz.p0p ();
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,437 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MopacSlaterReader", "java.util.Hashtable"], "J.adapter.readers.quantum.CsfReader", ["java.lang.Float", "JU.AU", "$.Lst", "$.PT", "J.adapter.readers.quantum.BasisFunctionReader", "J.adapter.smarter.Atom", "$.Bond", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.nAtoms = 0;
|
||||
this.strAtomicNumbers = "";
|
||||
this.fieldCount = 0;
|
||||
this.nVibrations = 0;
|
||||
this.nGaussians = 0;
|
||||
this.nSlaters = 0;
|
||||
this.htBonds = null;
|
||||
this.propertyItemCounts = null;
|
||||
this.fieldTypes = null;
|
||||
this.connectors = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "CsfReader", J.adapter.readers.quantum.MopacSlaterReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.propertyItemCounts = new java.util.Hashtable ();
|
||||
this.fieldTypes = Clazz.newIntArray (100, 0);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.equals ("local_transform")) {
|
||||
this.processLocalTransform ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("object_class")) {
|
||||
if (this.line.equals ("object_class connector")) {
|
||||
this.processConnectorObject ();
|
||||
return false;
|
||||
}if (this.line.equals ("object_class atom")) {
|
||||
this.processAtomObject ();
|
||||
return false;
|
||||
}if (this.line.equals ("object_class bond")) {
|
||||
this.processBondObject ();
|
||||
return false;
|
||||
}if (this.line.equals ("object_class vibrational_level")) {
|
||||
this.processVibrationObject ();
|
||||
return false;
|
||||
}if (this.line.equals ("object_class mol_orbital")) {
|
||||
this.processMolecularOrbitalObject ();
|
||||
return false;
|
||||
}if (this.line.equals ("object_class sto_basis_fxn")) {
|
||||
this.processBasisObject ("sto");
|
||||
return false;
|
||||
}if (this.line.equals ("object_class gto_basis_fxn")) {
|
||||
this.processBasisObject ("gto");
|
||||
return false;
|
||||
}}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processLocalTransform",
|
||||
function () {
|
||||
var tokens = JU.PT.getTokens (this.rd () + " " + this.rd () + " " + this.rd () + " " + this.rd ());
|
||||
this.setTransform (this.parseFloatStr (tokens[0]), this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]), this.parseFloatStr (tokens[4]), this.parseFloatStr (tokens[5]), this.parseFloatStr (tokens[6]), this.parseFloatStr (tokens[8]), this.parseFloatStr (tokens[9]), this.parseFloatStr (tokens[10]));
|
||||
});
|
||||
Clazz.defineMethod (c$, "getPropertyCount",
|
||||
function (what) {
|
||||
var count = this.propertyItemCounts.get (what);
|
||||
return (what.equals ("ID") ? 1 : count == null ? 0 : count.intValue ());
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "parseLineParameters",
|
||||
function (fields, fieldMap) {
|
||||
for (var i = 0; i < this.fieldCount; i++) this.fieldTypes[i] = 0;
|
||||
|
||||
this.fieldCount = -1;
|
||||
if (this.line == null || this.line.startsWith ("property_flags:")) this.rd ();
|
||||
if (this.line == null || this.line.startsWith ("object_class")) return this.fieldCount;
|
||||
var tokens = new Array (0);
|
||||
while (this.line != null) {
|
||||
tokens = this.getTokens ();
|
||||
if (this.line.indexOf ("property ") == 0) this.propertyItemCounts.put (tokens[1], Integer.$valueOf ((tokens[6].equals ("STRING") ? 1 : this.parseIntStr (tokens[5]))));
|
||||
else if (this.line.indexOf ("ID") == 0) break;
|
||||
this.rd ();
|
||||
}
|
||||
for (var ipt = 0, fpt = 0; ipt < tokens.length; ipt++) {
|
||||
var field = tokens[ipt];
|
||||
for (var i = fields.length; --i >= 0; ) if (field.equals (fields[i])) {
|
||||
this.fieldTypes[fpt] = fieldMap[i];
|
||||
this.fieldCount = fpt + 1;
|
||||
break;
|
||||
}
|
||||
fpt += this.getPropertyCount (field);
|
||||
}
|
||||
return this.fieldCount;
|
||||
}, "~A,~A");
|
||||
Clazz.defineMethod (c$, "fillCsfArray",
|
||||
function (property, tokens, i0, f, isInteger) {
|
||||
var n = this.getPropertyCount (property);
|
||||
var ioffset = i0;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var ipt = ioffset + i;
|
||||
if (ipt == tokens.length) {
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
ioffset -= ipt - i0;
|
||||
ipt = i0;
|
||||
}if (isInteger) (f)[i] = this.parseIntStr (tokens[ipt]);
|
||||
else (f)[i] = this.parseFloatStr (tokens[ipt]);
|
||||
}
|
||||
}, "~S,~A,~N,~O,~B");
|
||||
Clazz.defineMethod (c$, "processConnectorObject",
|
||||
function () {
|
||||
this.connectors = new java.util.Hashtable ();
|
||||
this.rd ();
|
||||
this.parseLineParameters (J.adapter.readers.quantum.CsfReader.connectorFields, J.adapter.readers.quantum.CsfReader.connectorFieldMap);
|
||||
out : for (; this.rd () != null; ) {
|
||||
if (this.line.startsWith ("property_flags:")) break;
|
||||
var thisAtomID = null;
|
||||
var thisBondID = null;
|
||||
var tokens = this.getTokens ();
|
||||
var field2 = "";
|
||||
var isVibration = false;
|
||||
for (var i = 0; i < this.fieldCount; ++i) {
|
||||
var field = tokens[i];
|
||||
switch (this.fieldTypes[i]) {
|
||||
case 1:
|
||||
if (!field.equals ("atom")) continue out;
|
||||
break;
|
||||
case 3:
|
||||
field2 = field;
|
||||
if (field.equals ("sto_basis_fxn")) this.nSlaters++;
|
||||
else if (field.equals ("gto_basis_fxn")) this.nGaussians++;
|
||||
else if (field.equals ("vibrational_level")) isVibration = true;
|
||||
else if (!field.equals ("bond")) continue out;
|
||||
break;
|
||||
case 2:
|
||||
thisAtomID = field;
|
||||
break;
|
||||
case 4:
|
||||
thisBondID = field2 + field;
|
||||
if (isVibration) this.nVibrations = Math.max (this.nVibrations, this.parseIntStr (field));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
if (thisAtomID != null && thisBondID != null) {
|
||||
if (this.connectors.containsKey (thisBondID)) {
|
||||
var connect = this.connectors.get (thisBondID);
|
||||
connect[1] = thisAtomID;
|
||||
if (this.htBonds != null) this.setBond (this.htBonds.get (thisBondID), connect);
|
||||
} else {
|
||||
var connect = new Array (2);
|
||||
connect[0] = thisAtomID;
|
||||
this.connectors.put (thisBondID, connect);
|
||||
}}}
|
||||
});
|
||||
Clazz.defineMethod (c$, "setBond",
|
||||
function (bond, connect) {
|
||||
bond.atomIndex1 = this.asc.getAtomIndex (connect[0]);
|
||||
bond.atomIndex2 = this.asc.getAtomIndex (connect[1]);
|
||||
this.asc.addBond (bond);
|
||||
}, "J.adapter.smarter.Bond,~A");
|
||||
Clazz.defineMethod (c$, "processAtomObject",
|
||||
function () {
|
||||
this.rd ();
|
||||
this.parseLineParameters (J.adapter.readers.quantum.CsfReader.atomFields, J.adapter.readers.quantum.CsfReader.atomFieldMap);
|
||||
this.nAtoms = 0;
|
||||
for (; this.rd () != null; ) {
|
||||
if (this.line.startsWith ("property_flags:")) break;
|
||||
var tokens = this.getTokens ();
|
||||
var atom = new J.adapter.smarter.Atom ();
|
||||
var field;
|
||||
for (var i = 0; i < this.fieldCount; i++) {
|
||||
var type = this.fieldTypes[i];
|
||||
if (type == 0) continue;
|
||||
if ((field = tokens[i]) == null) JU.Logger.warn ("field == null in " + this.line);
|
||||
switch (type) {
|
||||
case -1:
|
||||
atom.atomSerial = JU.PT.parseInt (field);
|
||||
break;
|
||||
case 1:
|
||||
atom.elementSymbol = field;
|
||||
atom.atomName = field + atom.atomSerial;
|
||||
break;
|
||||
case 2:
|
||||
this.strAtomicNumbers += field + " ";
|
||||
break;
|
||||
case 3:
|
||||
atom.formalCharge = this.parseIntStr (field);
|
||||
break;
|
||||
case 5:
|
||||
atom.partialCharge = this.parseFloatStr (field);
|
||||
break;
|
||||
case 4:
|
||||
this.setAtomCoordTokens (atom, tokens, i);
|
||||
i += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Float.isNaN (atom.x) || Float.isNaN (atom.y) || Float.isNaN (atom.z)) {
|
||||
JU.Logger.warn ("atom " + atom.atomName + " has invalid/unknown coordinates");
|
||||
} else {
|
||||
this.nAtoms++;
|
||||
this.asc.addAtomWithMappedSerialNumber (atom);
|
||||
}}
|
||||
});
|
||||
Clazz.defineMethod (c$, "processBondObject",
|
||||
function () {
|
||||
this.rd ();
|
||||
this.parseLineParameters (J.adapter.readers.quantum.CsfReader.bondFields, J.adapter.readers.quantum.CsfReader.bondFieldMap);
|
||||
for (; this.rd () != null; ) {
|
||||
if (this.line.startsWith ("property_flags:")) break;
|
||||
var thisBondID = null;
|
||||
var tokens = this.getTokens ();
|
||||
for (var i = 0; i < this.fieldCount; ++i) {
|
||||
var field = tokens[i];
|
||||
switch (this.fieldTypes[i]) {
|
||||
case -1:
|
||||
thisBondID = "bond" + field;
|
||||
break;
|
||||
case 1:
|
||||
var order = 1;
|
||||
if (field.equals ("single")) order = 1;
|
||||
else if (field.equals ("double")) order = 2;
|
||||
else if (field.equals ("triple")) order = 3;
|
||||
else JU.Logger.warn ("unknown CSF bond order: " + field);
|
||||
var bond = new J.adapter.smarter.Bond (-1, -1, 1);
|
||||
bond.order = order;
|
||||
if (this.connectors == null) {
|
||||
if (this.htBonds == null) this.htBonds = new java.util.Hashtable ();
|
||||
this.htBonds.put (thisBondID, bond);
|
||||
} else {
|
||||
this.setBond (bond, this.connectors.get (thisBondID));
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "processVibrationObject",
|
||||
function () {
|
||||
var vibData = Clazz.newFloatArray (this.nVibrations, this.nAtoms * 3, 0);
|
||||
var energies = new Array (this.nVibrations);
|
||||
this.rd ();
|
||||
while (this.line != null && this.parseLineParameters (J.adapter.readers.quantum.CsfReader.vibFields, J.adapter.readers.quantum.CsfReader.vibFieldMap) > 0) {
|
||||
while (this.rd () != null && !this.line.startsWith ("property_flags:")) {
|
||||
var tokens = this.getTokens ();
|
||||
var thisvib = -1;
|
||||
for (var i = 0; i < this.fieldCount; ++i) {
|
||||
var field = tokens[i];
|
||||
switch (this.fieldTypes[i]) {
|
||||
case -1:
|
||||
thisvib = this.parseIntStr (field) - 1;
|
||||
break;
|
||||
case 1:
|
||||
this.fillCsfArray ("normalMode", tokens, i, vibData[thisvib], false);
|
||||
break;
|
||||
case 2:
|
||||
energies[thisvib] = field;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < this.nVibrations; i++) {
|
||||
if (!this.doGetVibration (i + 1)) continue;
|
||||
this.asc.cloneAtomSetWithBonds (false);
|
||||
this.asc.setAtomSetFrequency (null, null, energies[i], null);
|
||||
var ipt = 0;
|
||||
var baseAtom = this.nAtoms * (i + 1);
|
||||
for (var iAtom = 0; iAtom < this.nAtoms; iAtom++) this.asc.addVibrationVector (baseAtom + iAtom, vibData[i][ipt++], vibData[i][ipt++], vibData[i][ipt++]);
|
||||
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "processMolecularOrbitalObject",
|
||||
function () {
|
||||
if (this.nSlaters == 0 && this.nGaussians == 0 || !this.doReadMolecularOrbitals) {
|
||||
this.rd ();
|
||||
return;
|
||||
}this.nOrbitals = (this.nSlaters + this.nGaussians);
|
||||
JU.Logger.info ("Reading CSF data for " + this.nOrbitals + " molecular orbitals");
|
||||
var energy = Clazz.newFloatArray (this.nOrbitals, 0);
|
||||
var occupancy = Clazz.newFloatArray (this.nOrbitals, 0);
|
||||
var list = Clazz.newFloatArray (this.nOrbitals, this.nOrbitals, 0);
|
||||
var listCompressed = null;
|
||||
var coefIndices = null;
|
||||
var ipt = 0;
|
||||
var isCompressed = false;
|
||||
this.rd ();
|
||||
while (this.line != null && this.parseLineParameters (J.adapter.readers.quantum.CsfReader.moFields, J.adapter.readers.quantum.CsfReader.moFieldMap) > 0) while (this.rd () != null && !this.line.startsWith ("property_flags:")) {
|
||||
var tokens = this.getTokens ();
|
||||
for (var i = 0; i < this.fieldCount; ++i) {
|
||||
switch (this.fieldTypes[i]) {
|
||||
case -1:
|
||||
ipt = this.parseIntStr (tokens[i]) - 1;
|
||||
break;
|
||||
case 1:
|
||||
energy[ipt] = this.parseFloatStr (tokens[i]);
|
||||
break;
|
||||
case 2:
|
||||
occupancy[ipt] = this.parseFloatStr (tokens[i]);
|
||||
break;
|
||||
case 3:
|
||||
this.fillCsfArray ("eig_vec", tokens, i, list[ipt], false);
|
||||
break;
|
||||
case 4:
|
||||
isCompressed = true;
|
||||
if (listCompressed == null) listCompressed = Clazz.newFloatArray (this.nOrbitals, this.nOrbitals, 0);
|
||||
this.fillCsfArray ("eig_vec_compressed", tokens, i, listCompressed[ipt], false);
|
||||
break;
|
||||
case 5:
|
||||
if (coefIndices == null) coefIndices = Clazz.newIntArray (this.nOrbitals, this.nOrbitals, 0);
|
||||
this.fillCsfArray ("coef_indices", tokens, i, coefIndices[ipt], true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var iMo = 0; iMo < this.nOrbitals; iMo++) {
|
||||
if (isCompressed) {
|
||||
for (var i = 0; i < coefIndices[iMo].length; i++) {
|
||||
var pt = coefIndices[iMo][i] - 1;
|
||||
if (pt < 0) break;
|
||||
list[iMo][pt] = listCompressed[iMo][i];
|
||||
}
|
||||
}for (var i = 0; i < this.nOrbitals; i++) if (Math.abs (list[iMo][i]) < 1.0E-4) list[iMo][i] = 0;
|
||||
|
||||
var mo = new java.util.Hashtable ();
|
||||
mo.put ("energy", Float.$valueOf (energy[iMo]));
|
||||
mo.put ("occupancy", Float.$valueOf (occupancy[iMo]));
|
||||
mo.put ("coefficients", list[iMo]);
|
||||
this.setMO (mo);
|
||||
}
|
||||
this.setMOs ("eV");
|
||||
});
|
||||
Clazz.defineMethod (c$, "processBasisObject",
|
||||
function (sto_gto) {
|
||||
var atomNos = JU.PT.getTokens (this.strAtomicNumbers);
|
||||
this.atomicNumbers = Clazz.newIntArray (atomNos.length, 0);
|
||||
for (var i = 0; i < this.atomicNumbers.length; i++) this.atomicNumbers[i] = this.parseIntStr (atomNos[i]);
|
||||
|
||||
this.nOrbitals = (this.nSlaters + this.nGaussians);
|
||||
var isGaussian = (sto_gto.equals ("gto"));
|
||||
var zetas = JU.AU.newFloat2 (this.nOrbitals);
|
||||
var contractionCoefs = null;
|
||||
var types = new Array (this.nOrbitals);
|
||||
var shells = Clazz.newIntArray (this.nOrbitals, 0);
|
||||
var nZetas = 0;
|
||||
this.rd ();
|
||||
while (this.line != null && this.parseLineParameters (J.adapter.readers.quantum.CsfReader.moFields, J.adapter.readers.quantum.CsfReader.moFieldMap) > 0) {
|
||||
if (nZetas == 0) nZetas = this.getPropertyCount (sto_gto + "_exp");
|
||||
var ipt = 0;
|
||||
while (this.rd () != null && !this.line.startsWith ("property_flags:")) {
|
||||
var tokens = this.getTokens ();
|
||||
for (var i = 0; i < this.fieldCount; ++i) {
|
||||
var field = tokens[i];
|
||||
switch (this.fieldTypes[i]) {
|
||||
case -1:
|
||||
ipt = this.parseIntStr (field) - 1;
|
||||
break;
|
||||
case 6:
|
||||
types[ipt] = field;
|
||||
break;
|
||||
case 7:
|
||||
case 9:
|
||||
zetas[ipt] = Clazz.newFloatArray (nZetas, 0);
|
||||
this.fillCsfArray (sto_gto + "_exp", tokens, i, zetas[ipt], false);
|
||||
break;
|
||||
case 10:
|
||||
shells[ipt] = this.parseIntStr (field);
|
||||
break;
|
||||
case 8:
|
||||
if (contractionCoefs == null) contractionCoefs = Clazz.newFloatArray (this.nOrbitals, nZetas, 0);
|
||||
this.fillCsfArray ("contractions", tokens, i, contractionCoefs[ipt], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isGaussian) {
|
||||
var sdata = new JU.Lst ();
|
||||
var gdata = new JU.Lst ();
|
||||
var iShell = 0;
|
||||
var gaussianCount = 0;
|
||||
for (var ipt = 0; ipt < this.nGaussians; ipt++) {
|
||||
if (shells[ipt] != iShell) {
|
||||
iShell = shells[ipt];
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
var iAtom = this.asc.getAtomIndex (this.connectors.get (sto_gto + "_basis_fxn" + (ipt + 1))[0]);
|
||||
slater[0] = iAtom + 1;
|
||||
slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (types[ipt].substring (0, 1));
|
||||
var nZ = 0;
|
||||
while (++nZ < nZetas && zetas[ipt][nZ] != 0) {
|
||||
}
|
||||
slater[2] = gaussianCount;
|
||||
slater[3] = nZ;
|
||||
sdata.addLast (slater);
|
||||
gaussianCount += nZ;
|
||||
for (var i = 0; i < nZ; i++) gdata.addLast ( Clazz.newFloatArray (-1, [zetas[ipt][i], contractionCoefs[ipt][i]]));
|
||||
|
||||
}}
|
||||
var garray = JU.AU.newFloat2 (gaussianCount);
|
||||
for (var i = 0; i < gaussianCount; i++) garray[i] = gdata.get (i);
|
||||
|
||||
this.moData.put ("shells", sdata);
|
||||
this.moData.put ("gaussians", garray);
|
||||
} else {
|
||||
for (var ipt = 0; ipt < this.nSlaters; ipt++) {
|
||||
var iAtom = this.asc.getAtomIndex (this.connectors.get (sto_gto + "_basis_fxn" + (ipt + 1))[0]);
|
||||
for (var i = 0; i < nZetas; i++) {
|
||||
if (zetas[ipt][i] == 0) break;
|
||||
this.createSphericalSlaterByType (iAtom, this.atomicNumbers[iAtom], types[ipt], zetas[ipt][i] * (i == 0 ? 1 : -1), contractionCoefs == null ? 1 : contractionCoefs[ipt][i]);
|
||||
}
|
||||
}
|
||||
this.setSlaters (true, false);
|
||||
}}, "~S");
|
||||
Clazz.defineStatics (c$,
|
||||
"objCls1", 1,
|
||||
"objID1", 2,
|
||||
"objCls2", 3,
|
||||
"objID2", 4,
|
||||
"connectorFields", Clazz.newArray (-1, ["objCls1", "objID1", "objCls2", "objID2"]),
|
||||
"connectorFieldMap", Clazz.newByteArray (-1, [1, 2, 3, 4]),
|
||||
"ID", -1,
|
||||
"SYM", 1,
|
||||
"ANUM", 2,
|
||||
"CHRG", 3,
|
||||
"XYZ", 4,
|
||||
"PCHRG", 5,
|
||||
"atomFields", Clazz.newArray (-1, ["ID", "sym", "anum", "chrg", "xyz_coordinates", "pchrg"]),
|
||||
"atomFieldMap", Clazz.newByteArray (-1, [-1, 1, 2, 3, 4, 5]),
|
||||
"BTYPE", 1,
|
||||
"bondFields", Clazz.newArray (-1, ["ID", "type"]),
|
||||
"bondFieldMap", Clazz.newByteArray (-1, [-1, 1]),
|
||||
"NORMAL_MODE", 1,
|
||||
"VIB_ENERGY", 2,
|
||||
"DIPOLE", 3,
|
||||
"vibFields", Clazz.newArray (-1, ["ID", "normalMode", "Energy", "transitionDipole"]),
|
||||
"vibFieldMap", Clazz.newByteArray (-1, [-1, 1, 2, 3]),
|
||||
"EIG_VAL", 1,
|
||||
"MO_OCC", 2,
|
||||
"EIG_VEC", 3,
|
||||
"EIG_VEC_COMPRESSED", 4,
|
||||
"COEF_INDICES", 5,
|
||||
"BFXN_ANGL", 6,
|
||||
"STO_EXP", 7,
|
||||
"CONTRACTIONS", 8,
|
||||
"GTO_EXP", 9,
|
||||
"SHELL", 10,
|
||||
"moFields", Clazz.newArray (-1, ["ID", "eig_val", "mo_occ", "eig_vec", "eig_vec_compressed", "coef_indices", "bfxn_ang", "sto_exp", "contractions", "gto_exp", "shell"]),
|
||||
"moFieldMap", Clazz.newByteArray (-1, [-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
|
||||
});
|
||||
@@ -0,0 +1,172 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.SlaterReader", "java.util.Hashtable"], "J.adapter.readers.quantum.DgridReader", ["java.lang.Float", "JU.PT", "$.SB", "J.quantum.SlaterData", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.title = null;
|
||||
this.htExponents = null;
|
||||
this.htFuncMap = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "DgridReader", J.adapter.readers.quantum.SlaterReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.htExponents = new java.util.Hashtable ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf (":title") == 0) {
|
||||
this.title = this.rd ().substring (2);
|
||||
return true;
|
||||
}if (this.line.indexOf ("basis: CARTESIAN STO") >= 0) {
|
||||
this.readSlaterBasis ();
|
||||
return true;
|
||||
}if (this.line.indexOf (":atom") == 0) {
|
||||
this.readCoordinates ();
|
||||
return true;
|
||||
}if (this.line.indexOf (" MO DATA ") >= 0) {
|
||||
if (this.doReadMolecularOrbitals) this.readMolecularOrbitals ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCoordinates",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetName (this.title);
|
||||
this.discardLinesUntilContains ("----");
|
||||
while (this.rd () != null && !this.line.startsWith (":-----")) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length < 5) break;
|
||||
this.setAtomCoordScaled (null, tokens, 2, 0.5291772).elementSymbol = tokens[0];
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSlaterBasis",
|
||||
function () {
|
||||
this.discardLinesUntilContains (":-");
|
||||
var ch = 'a';
|
||||
while (this.rd () != null && this.line.indexOf (":-") < 0) {
|
||||
var atomSymbol = this.line.substring (3, 6).trim ();
|
||||
var xyz = this.line.substring (19, 21);
|
||||
var code = atomSymbol + xyz;
|
||||
if (this.htExponents.get (code) == null) {
|
||||
ch = 'a';
|
||||
} else {
|
||||
code += "_" + ($c$ = ch, ch = String.fromCharCode (ch.charCodeAt (0) + 1), $c$);
|
||||
}var exp = this.line.substring (34);
|
||||
this.htExponents.put (code, Float.$valueOf (this.parseFloatStr (exp)));
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbitals",
|
||||
function () {
|
||||
this.htFuncMap = new java.util.Hashtable ();
|
||||
this.readLines (3);
|
||||
while (this.line != null && this.line.indexOf (":") != 0) {
|
||||
this.discardLinesUntilContains ("sym: ");
|
||||
var symmetry = this.line.substring (4, 10).trim ();
|
||||
if (symmetry.indexOf ("_FC") >= 0) break;
|
||||
var data = new JU.SB ();
|
||||
data.append (this.line.substring (15));
|
||||
while (this.rd () != null && this.line.length >= 15) data.append (this.line);
|
||||
|
||||
var tokens = JU.PT.getTokens (data.toString ());
|
||||
var nFuncs = Clazz.doubleToInt (tokens.length / 2);
|
||||
var ptSlater = Clazz.newIntArray (nFuncs, 0);
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = 0, pt = 0; i < tokens.length; ) {
|
||||
var iAtom = this.parseIntStr (tokens[i++]) - 1;
|
||||
var code = tokens[i++];
|
||||
var key = iAtom + "_" + code;
|
||||
if (this.htFuncMap.containsKey (key)) {
|
||||
ptSlater[pt++] = this.htFuncMap.get (key).intValue ();
|
||||
} else {
|
||||
var n = this.slaters.size ();
|
||||
ptSlater[pt++] = n;
|
||||
this.htFuncMap.put (key, Integer.$valueOf (n));
|
||||
this.addSlater (this.createSlaterData (iAtom + 1, atoms[iAtom].elementSymbol, code), n);
|
||||
}}
|
||||
this.discardLinesUntilContains (":-");
|
||||
this.rd ();
|
||||
while (this.line != null && this.line.length >= 20) {
|
||||
var iOrb = this.parseIntRange (this.line, 0, 10);
|
||||
var energy = this.parseFloatRange (this.line, 10, 20);
|
||||
var cData = new JU.SB ();
|
||||
cData.append (this.line.substring (20));
|
||||
while (this.rd () != null && this.line.length >= 10) {
|
||||
if (this.line.charAt (3) != ' ') break;
|
||||
cData.append (this.line);
|
||||
}
|
||||
var list = Clazz.newFloatArray (this.slaters.size (), 0);
|
||||
tokens = JU.PT.getTokens (cData.toString ());
|
||||
if (tokens.length != nFuncs) JU.Logger.error ("DgridReader: number of coefficients (" + tokens.length + ") does not equal number of functions (" + nFuncs + ")");
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var pt = ptSlater[i];
|
||||
list[pt] = this.parseFloatStr (tokens[i]);
|
||||
}
|
||||
var mo = new java.util.Hashtable ();
|
||||
mo.put ("energy", Float.$valueOf (energy));
|
||||
mo.put ("coefficients", list);
|
||||
mo.put ("symmetry", symmetry + "_" + iOrb);
|
||||
this.setMO (mo);
|
||||
}
|
||||
}
|
||||
this.discardLinesUntilContains (": # symmetry");
|
||||
this.rd ();
|
||||
for (var i = 0; i < this.orbitals.size (); i++) {
|
||||
this.rd ();
|
||||
var occupancy = this.parseFloatRange (this.line, 31, 45) + this.parseFloatRange (this.line, 47, 61);
|
||||
this.orbitals.get (i).put ("occupancy", Float.$valueOf (occupancy));
|
||||
}
|
||||
this.sortOrbitals ();
|
||||
this.setSlaters (true, true);
|
||||
this.setMOs ("eV");
|
||||
});
|
||||
Clazz.defineMethod (c$, "createSlaterData",
|
||||
function (iAtom, atomSymbol, xyz) {
|
||||
var ch;
|
||||
var abc = ' ';
|
||||
var type = ' ';
|
||||
var exp = 1;
|
||||
var el = 0;
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var z = 0;
|
||||
for (var i = xyz.length; --i >= 0; ) {
|
||||
switch (ch = xyz.charAt (i)) {
|
||||
case '_':
|
||||
type = abc;
|
||||
break;
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
exp = ch.charCodeAt (0) - 48;
|
||||
break;
|
||||
case 'x':
|
||||
x = exp;
|
||||
el += exp;
|
||||
exp = 1;
|
||||
break;
|
||||
case 'y':
|
||||
y = exp;
|
||||
el += exp;
|
||||
exp = 1;
|
||||
break;
|
||||
case 'z':
|
||||
z = exp;
|
||||
el += exp;
|
||||
exp = 1;
|
||||
break;
|
||||
case 's':
|
||||
case 'p':
|
||||
case 'd':
|
||||
case 'f':
|
||||
default:
|
||||
abc = ch;
|
||||
}
|
||||
}
|
||||
var r = (exp - el - 1);
|
||||
var code = atomSymbol + xyz.substring (0, 2);
|
||||
if (type != ' ') code += "_" + type;
|
||||
var f = this.htExponents.get (code);
|
||||
var zeta = 0;
|
||||
if (f == null) JU.Logger.error ("Exponent for " + code + " not found");
|
||||
else zeta = f.floatValue ();
|
||||
return new J.quantum.SlaterData (iAtom, x, y, z, r, zeta, 1);
|
||||
}, "~N,~S,~S");
|
||||
});
|
||||
@@ -0,0 +1,254 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MOReader"], "J.adapter.readers.quantum.GamessReader", ["java.lang.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "J.adapter.readers.quantum.BasisFunctionReader", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.atomNames = null;
|
||||
this.calcOptions = null;
|
||||
this.isTypeSet = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "GamessReader", J.adapter.readers.quantum.MOReader);
|
||||
Clazz.defineMethod (c$, "readEnergy",
|
||||
function () {
|
||||
var tokens = JU.PT.getTokens (this.line.substring (this.line.indexOf ("ENERGY")));
|
||||
if (tokens.length < 3) return;
|
||||
var strEnergy = tokens[2];
|
||||
var e = this.parseFloatStr (strEnergy);
|
||||
if (!Float.isNaN (e)) this.asc.setAtomSetEnergy (strEnergy, e);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readGaussianBasis",
|
||||
function (initiator, terminator) {
|
||||
var gdata = new JU.Lst ();
|
||||
this.gaussianCount = 0;
|
||||
var nGaussians = 0;
|
||||
this.shellCount = 0;
|
||||
var thisShell = "0";
|
||||
var tokens;
|
||||
this.discardLinesUntilContains (initiator);
|
||||
this.rd ();
|
||||
var slater = null;
|
||||
var shellsByAtomType = new java.util.Hashtable ();
|
||||
var slatersByAtomType = new JU.Lst ();
|
||||
var atomType = null;
|
||||
while (this.rd () != null && this.line.indexOf (terminator) < 0) {
|
||||
if (this.line.indexOf ("(") >= 0) this.line = J.adapter.readers.quantum.GamessReader.fixBasisLine (this.line);
|
||||
tokens = this.getTokens ();
|
||||
switch (tokens.length) {
|
||||
case 1:
|
||||
if (atomType != null) {
|
||||
if (slater != null) {
|
||||
slater[2] = nGaussians;
|
||||
slatersByAtomType.addLast (slater);
|
||||
slater = null;
|
||||
}shellsByAtomType.put (atomType, slatersByAtomType);
|
||||
}slatersByAtomType = new JU.Lst ();
|
||||
atomType = tokens[0];
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
if (!tokens[0].equals (thisShell)) {
|
||||
if (slater != null) {
|
||||
slater[2] = nGaussians;
|
||||
slatersByAtomType.addLast (slater);
|
||||
}thisShell = tokens[0];
|
||||
this.shellCount++;
|
||||
slater = Clazz.newIntArray (-1, [J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (this.fixShellTag (tokens[1])), this.gaussianCount, 0]);
|
||||
nGaussians = 0;
|
||||
}++nGaussians;
|
||||
++this.gaussianCount;
|
||||
gdata.addLast (tokens);
|
||||
}
|
||||
}
|
||||
if (slater != null) {
|
||||
slater[2] = nGaussians;
|
||||
slatersByAtomType.addLast (slater);
|
||||
}if (atomType != null) shellsByAtomType.put (atomType, slatersByAtomType);
|
||||
this.gaussians = JU.AU.newFloat2 (this.gaussianCount);
|
||||
for (var i = 0; i < this.gaussianCount; i++) {
|
||||
tokens = gdata.get (i);
|
||||
this.gaussians[i] = Clazz.newFloatArray (tokens.length - 3, 0);
|
||||
for (var j = 3; j < tokens.length; j++) this.gaussians[i][j - 3] = this.parseFloatStr (tokens[j]);
|
||||
|
||||
}
|
||||
var ac = this.atomNames.size ();
|
||||
if (this.shells == null && ac > 0) {
|
||||
this.shells = new JU.Lst ();
|
||||
for (var i = 0; i < ac; i++) {
|
||||
atomType = this.atomNames.get (i);
|
||||
var slaters = shellsByAtomType.get (atomType);
|
||||
if (slaters == null) {
|
||||
JU.Logger.error ("slater for atom " + i + " atomType " + atomType + " was not found in listing. Ignoring molecular orbitals");
|
||||
return;
|
||||
}for (var j = 0; j < slaters.size (); j++) {
|
||||
slater = slaters.get (j);
|
||||
this.shells.addLast ( Clazz.newIntArray (-1, [i + 1, slater[0], slater[1] + 1, slater[2]]));
|
||||
}
|
||||
}
|
||||
}if (this.debugging) {
|
||||
JU.Logger.debug (this.shellCount + " slater shells read");
|
||||
JU.Logger.debug (this.gaussianCount + " gaussian primitives read");
|
||||
}}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
this.discardLinesUntilContains ("FREQUENCY:");
|
||||
var haveFreq = false;
|
||||
while (this.line != null && this.line.indexOf ("FREQUENCY:") >= 0) {
|
||||
var frequencyCount = 0;
|
||||
var tokens = this.getTokens ();
|
||||
var frequencies = Clazz.newFloatArray (tokens.length, 0);
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var frequency = this.parseFloatStr (tokens[i]);
|
||||
if (tokens[i].equals ("I")) frequencies[frequencyCount - 1] = -frequencies[frequencyCount - 1];
|
||||
if (Float.isNaN (frequency)) continue;
|
||||
frequencies[frequencyCount++] = frequency;
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug ((this.vibrationNumber + 1) + " frequency=" + frequency);
|
||||
}}
|
||||
var red_masses = null;
|
||||
var intensities = null;
|
||||
this.rd ();
|
||||
if (this.line.indexOf ("MASS") >= 0) {
|
||||
red_masses = this.getTokens ();
|
||||
this.rd ();
|
||||
}if (this.line.indexOf ("INTENS") >= 0) {
|
||||
intensities = this.getTokens ();
|
||||
}var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var iAtom0 = this.asc.ac;
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
for (var i = 0; i < frequencyCount; i++) {
|
||||
ignore[i] = !this.doGetVibration (++this.vibrationNumber);
|
||||
if (ignore[i]) continue;
|
||||
if (haveFreq) {
|
||||
this.asc.cloneLastAtomSet ();
|
||||
} else {
|
||||
haveFreq = true;
|
||||
iAtom0 -= ac;
|
||||
}this.asc.setAtomSetFrequency (null, null, "" + frequencies[i], null);
|
||||
if (red_masses != null) this.asc.setAtomSetModelProperty ("ReducedMass", red_masses[red_masses.length - frequencyCount + i] + " AMU");
|
||||
if (intensities != null) this.asc.setAtomSetModelProperty ("IRIntensity", intensities[intensities.length - frequencyCount + i] + " D^2/AMU-Angstrom^2");
|
||||
}
|
||||
this.discardLinesUntilBlank ();
|
||||
this.fillFrequencyData (iAtom0, ac, ac, ignore, false, 20, 12, null, 0);
|
||||
this.readLines (13);
|
||||
}
|
||||
});
|
||||
c$.fixBasisLine = Clazz.defineMethod (c$, "fixBasisLine",
|
||||
function (line) {
|
||||
var pt;
|
||||
var pt1;
|
||||
line = line.$replace (')', ' ');
|
||||
while ((pt = line.indexOf ("(")) >= 0) {
|
||||
pt1 = pt;
|
||||
while (line.charAt (--pt1) == ' ') {
|
||||
}
|
||||
while (line.charAt (--pt1) != ' ') {
|
||||
}
|
||||
line = line.substring (0, ++pt1) + line.substring (pt + 1);
|
||||
}
|
||||
return line;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "setCalculationType",
|
||||
function () {
|
||||
if (this.calcOptions == null || this.isTypeSet) return;
|
||||
this.isTypeSet = true;
|
||||
var SCFtype = this.calcOptions.get ("contrl_options_SCFTYP");
|
||||
var Runtype = this.calcOptions.get ("contrl_options_RUNTYP");
|
||||
var igauss = this.calcOptions.get ("basis_options_IGAUSS");
|
||||
var gbasis = this.calcOptions.get ("basis_options_GBASIS");
|
||||
var DFunc = !"0".equals (this.calcOptions.get ("basis_options_NDFUNC"));
|
||||
var PFunc = !"0".equals (this.calcOptions.get ("basis_options_NPFUNC"));
|
||||
var FFunc = !"0".equals (this.calcOptions.get ("basis_options_NFFUNC"));
|
||||
var DFTtype = this.calcOptions.get ("contrl_options_DFTTYP");
|
||||
var perturb = this.parseIntStr (this.calcOptions.get ("contrl_options_MPLEVL"));
|
||||
var CItype = this.calcOptions.get ("contrl_options_CITYP");
|
||||
var CCtype = this.calcOptions.get ("contrl_options_CCTYP");
|
||||
if (igauss == null && SCFtype == null) return;
|
||||
if (this.calculationType.equals ("?")) this.calculationType = "";
|
||||
if (igauss != null) {
|
||||
if ("0".equals (igauss)) {
|
||||
var recognized = false;
|
||||
if (this.calculationType.length > 0) this.calculationType += " ";
|
||||
if (gbasis.startsWith ("ACC")) this.calculationType += "aug-cc-p";
|
||||
if (gbasis.startsWith ("CC")) this.calculationType += "cc-p";
|
||||
if ((gbasis.startsWith ("ACC") || gbasis.startsWith ("CC")) && gbasis.endsWith ("C")) this.calculationType += "C";
|
||||
if (gbasis.indexOf ("CCD") >= 0) {
|
||||
this.calculationType += "VDZ";
|
||||
recognized = true;
|
||||
}if (gbasis.indexOf ("CCT") >= 0) {
|
||||
this.calculationType += "VTZ";
|
||||
recognized = true;
|
||||
}if (gbasis.indexOf ("CCQ") >= 0) {
|
||||
this.calculationType += "VQZ";
|
||||
recognized = true;
|
||||
}if (gbasis.indexOf ("CC5") >= 0) {
|
||||
this.calculationType += "V5Z";
|
||||
recognized = true;
|
||||
}if (gbasis.indexOf ("CC6") >= 0) {
|
||||
this.calculationType += "V6Z";
|
||||
recognized = true;
|
||||
}if (!recognized) this.calculationType += gbasis;
|
||||
} else {
|
||||
if (this.calculationType.length > 0) this.calculationType += " ";
|
||||
this.calculationType += igauss + "-" + JU.PT.rep (gbasis, "N", "");
|
||||
if ("T".equals (this.calcOptions.get ("basis_options_DIFFSP"))) {
|
||||
if ("T".equals (this.calcOptions.get ("basis_options_DIFFS"))) this.calculationType += "+";
|
||||
this.calculationType += "+";
|
||||
}this.calculationType += "G";
|
||||
if (DFunc || PFunc || FFunc) {
|
||||
this.calculationType += "(";
|
||||
if (FFunc) {
|
||||
this.calculationType += "f";
|
||||
if (DFunc || PFunc) this.calculationType += ",";
|
||||
}if (DFunc) {
|
||||
this.calculationType += "d";
|
||||
if (PFunc) this.calculationType += ",";
|
||||
}if (PFunc) this.calculationType += "p";
|
||||
this.calculationType += ")";
|
||||
}}if (DFTtype != null && DFTtype.indexOf ("NONE") < 0) {
|
||||
if (this.calculationType.length > 0) this.calculationType += " ";
|
||||
this.calculationType += DFTtype;
|
||||
}if (CItype != null && CItype.indexOf ("NONE") < 0) {
|
||||
if (this.calculationType.length > 0) this.calculationType += " ";
|
||||
this.calculationType += CItype;
|
||||
}if (CCtype != null && CCtype.indexOf ("NONE") < 0) {
|
||||
if (this.calculationType.length > 0) this.calculationType += " ";
|
||||
this.calculationType += CCtype;
|
||||
}if (perturb > 0) {
|
||||
if (this.calculationType.length > 0) this.calculationType += " ";
|
||||
this.calculationType += "MP" + perturb;
|
||||
}if (SCFtype != null) {
|
||||
if (this.calculationType.length > 0) this.calculationType += " ";
|
||||
this.calculationType += SCFtype + " " + Runtype;
|
||||
}}});
|
||||
Clazz.defineMethod (c$, "readControlInfo",
|
||||
function () {
|
||||
this.readCalculationInfo ("contrl_options_");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBasisInfo",
|
||||
function () {
|
||||
this.readCalculationInfo ("basis_options_");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCalculationInfo",
|
||||
function (type) {
|
||||
if (this.calcOptions == null) {
|
||||
this.calcOptions = new java.util.Hashtable ();
|
||||
this.asc.setInfo ("calculationOptions", this.calcOptions);
|
||||
}while (this.rd () != null && (this.line = this.line.trim ()).length > 0) {
|
||||
if (this.line.indexOf ("=") < 0) continue;
|
||||
var tokens = JU.PT.getTokens (JU.PT.rep (this.line, "=", " = ") + " ?");
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
if (!tokens[i].equals ("=")) continue;
|
||||
try {
|
||||
var key = type + tokens[i - 1];
|
||||
var value = (key.equals ("basis_options_SPLIT3") ? tokens[++i] + " " + tokens[++i] + " " + tokens[++i] : tokens[++i]);
|
||||
if (this.debugging) JU.Logger.debug (key + " = " + value);
|
||||
this.calcOptions.put (key, value);
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.GamessReader"], "J.adapter.readers.quantum.GamessUKReader", ["java.lang.Float", "JU.Lst", "$.PT"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.symmetries = null;
|
||||
this.occupancies = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "GamessUKReader", J.adapter.readers.quantum.GamessReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf ("BASIS OPTIONS") >= 0) {
|
||||
this.readBasisInfo ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("$CONTRL OPTIONS") >= 0) {
|
||||
this.readControlInfo ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("contracted primitive functions") >= 0) {
|
||||
this.readGaussianBasis ("======================================================", "======");
|
||||
return false;
|
||||
}if (this.line.indexOf ("molecular geometry") >= 0) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.atomNames = new JU.Lst ();
|
||||
this.readAtomsInBohrCoordinates ();
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.indexOf ("FREQUENCY_INFO_WOULD_BE_HERE") >= 0) {
|
||||
return true;
|
||||
}if (this.line.indexOf ("SYMMETRY ASSIGNMENT") >= 0) {
|
||||
this.readOrbitalSymmetryAndOccupancy ();
|
||||
return false;
|
||||
}if (this.line.indexOf ("- ALPHA SET -") >= 0) this.alphaBeta = "alpha";
|
||||
else if (this.line.indexOf ("- BETA SET -") >= 0) this.alphaBeta = "beta";
|
||||
else if (this.line.indexOf ("eigenvectors") >= 0) {
|
||||
this.readMolecularOrbitals (3);
|
||||
this.setOrbitalSymmetryAndOccupancy ();
|
||||
return false;
|
||||
}return this.checkNboLine ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "readAtomsInBohrCoordinates",
|
||||
function () {
|
||||
this.discardLinesUntilContains ("*****");
|
||||
this.discardLinesUntilContains ("atom");
|
||||
this.discardLinesUntilContains ("*****");
|
||||
this.asc.newAtomSet ();
|
||||
while (this.rd () != null && this.line.indexOf ("*****") < 0) {
|
||||
if (this.line.charAt (14) == ' ') continue;
|
||||
var tokens = this.getTokens ();
|
||||
var atomicNumber = Clazz.floatToInt (this.parseFloatStr (tokens[2]));
|
||||
var atom = this.setAtomCoordScaled (null, tokens, 3, 0.5291772);
|
||||
atom.elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (atomicNumber);
|
||||
this.atomNames.addLast (atom.atomName = tokens[1]);
|
||||
}
|
||||
});
|
||||
Clazz.overrideMethod (c$, "fixShellTag",
|
||||
function (tag) {
|
||||
return tag.substring (1).toUpperCase ();
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readOrbitalSymmetryAndOccupancy",
|
||||
function () {
|
||||
this.readLines (4);
|
||||
this.symmetries = new JU.Lst ();
|
||||
this.occupancies = new JU.Lst ();
|
||||
while (this.rd () != null && this.line.indexOf ("====") < 0) {
|
||||
var tokens = JU.PT.getTokens (this.line.substring (20));
|
||||
this.symmetries.addLast (tokens[0] + " " + tokens[1]);
|
||||
this.occupancies.addLast (Float.$valueOf (this.parseFloatStr (tokens[5])));
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "setOrbitalSymmetryAndOccupancy",
|
||||
function () {
|
||||
if (this.symmetries.size () < this.orbitals.size ()) return;
|
||||
for (var i = this.orbitals.size (); --i >= 0; ) {
|
||||
var mo = this.orbitals.get (i);
|
||||
mo.put ("symmetry", this.symmetries.get (i));
|
||||
mo.put ("occupancy", this.occupancies.get (i));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,187 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.GamessReader"], "J.adapter.readers.quantum.GamessUSReader", ["java.lang.Float", "JU.Lst", "$.PT", "$.V3", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.lowdenCharges = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "GamessUSReader", J.adapter.readers.quantum.GamessReader);
|
||||
Clazz.defineMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.lowdenCharges = this.checkAndRemoveFilterKey ("CHARGE=LOW");
|
||||
Clazz.superCall (this, J.adapter.readers.quantum.GamessUSReader, "initializeReader", []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.startsWith (" $DATA")) return this.readInputDeck ();
|
||||
if (this.line.indexOf ("***************") >= 0) JU.Logger.info (this.rd ());
|
||||
var isBohr;
|
||||
if (this.line.indexOf ("FINAL ENERGY IS") >= 0 || this.line.indexOf ("TOTAL ENERGY = ") >= 0 || this.line.indexOf ("FINAL RHF ENERGY IS") >= 0) this.readEnergy ();
|
||||
if (this.line.indexOf ("BASIS OPTIONS") >= 0) {
|
||||
this.readBasisInfo ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("$CONTRL OPTIONS") >= 0) {
|
||||
this.readControlInfo ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("ATOMIC BASIS SET") >= 0) {
|
||||
this.readGaussianBasis ("SHELL TYPE", "TOTAL");
|
||||
return false;
|
||||
}if ((isBohr = this.line.indexOf ("COORDINATES (BOHR)") >= 0) || this.line.indexOf ("COORDINATES OF ALL ATOMS ARE (ANGS)") >= 0) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.atomNames = new JU.Lst ();
|
||||
if (isBohr) this.readAtomsInBohrCoordinates ();
|
||||
else this.readAtomsInAngstromCoordinates ();
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.indexOf ("FREQUENCIES IN CM") >= 0) {
|
||||
this.readFrequencies ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("SUMMARY OF THE EFFECTIVE FRAGMENT") >= 0) {
|
||||
this.readEFPInBohrCoordinates ();
|
||||
return false;
|
||||
}if (this.line.indexOf (" TOTAL MULLIKEN AND LOWDIN ATOMIC POPULATIONS") >= 0) {
|
||||
this.readPartialCharges ();
|
||||
return false;
|
||||
}if (this.line.indexOf ("ELECTROSTATIC MOMENTS") >= 0) {
|
||||
this.readDipoleMoment ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("- ALPHA SET -") >= 0) this.alphaBeta = "alpha";
|
||||
else if (this.line.indexOf ("- BETA SET -") >= 0) this.alphaBeta = "beta";
|
||||
else if (this.line.indexOf (" EIGENVECTORS") >= 0 || this.line.indexOf (" INITIAL GUESS ORBITALS") >= 0 || this.line.indexOf (" MCSCF OPTIMIZED ORBITALS") >= 0 || this.line.indexOf (" MCSCF NATURAL ORBITALS") >= 0 || this.line.indexOf (" MOLECULAR ORBITALS") >= 0 && this.line.indexOf (" MOLECULAR ORBITALS LOCALIZED BY THE POPULATION METHOD") < 0) {
|
||||
if (!this.filterMO ()) return true;
|
||||
this.readMolecularOrbitals (1);
|
||||
return false;
|
||||
}if (this.line.indexOf ("EDMISTON-RUEDENBERG ENERGY LOCALIZED ORBITALS") >= 0 || this.line.indexOf (" THE PIPEK-MEZEY POPULATION LOCALIZED ORBITALS ARE") >= 0) {
|
||||
if (!this.filterMO ()) return true;
|
||||
this.readMolecularOrbitals (0);
|
||||
return false;
|
||||
}if (this.line.indexOf (" NATURAL ORBITALS IN ATOMIC ORBITAL BASIS") >= 0) {
|
||||
if (!this.filterMO ()) return true;
|
||||
this.readMolecularOrbitals (2);
|
||||
return false;
|
||||
}return this.checkNboLine ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readInputDeck",
|
||||
function () {
|
||||
this.readLines (2);
|
||||
this.asc.newAtomSet ();
|
||||
while (this.rd ().indexOf ("$END") < 0) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length > 4) this.addAtomXYZSymName (tokens, 2, tokens[0], null).elementNumber = this.parseIntStr (tokens[1]);
|
||||
}
|
||||
return (this.continuing = false);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbitals",
|
||||
function (headerType) {
|
||||
this.setCalculationType ();
|
||||
Clazz.superCall (this, J.adapter.readers.quantum.GamessUSReader, "readMolecularOrbitals", [headerType]);
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readEFPInBohrCoordinates",
|
||||
function () {
|
||||
var acInFirstModel = this.asc.ac;
|
||||
this.discardLinesUntilContains ("MULTIPOLE COORDINATES");
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
while (this.rd () != null && this.line.length >= 72) {
|
||||
var atomName = this.line.substring (1, 2);
|
||||
if (atomName.charAt (0) == 'Z') atomName = this.line.substring (2, 3);
|
||||
else if (this.parseFloatRange (this.line, 67, 73) == 0) continue;
|
||||
var x = this.parseFloatRange (this.line, 8, 25);
|
||||
var y = this.parseFloatRange (this.line, 25, 40);
|
||||
var z = this.parseFloatRange (this.line, 40, 56);
|
||||
if (Float.isNaN (x) || Float.isNaN (y) || Float.isNaN (z)) break;
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.atomName = atomName + (++acInFirstModel);
|
||||
this.setAtomCoordXYZ (atom, x * 0.5291772, y * 0.5291772, z * 0.5291772);
|
||||
this.atomNames.addLast (atomName);
|
||||
}
|
||||
});
|
||||
Clazz.overrideMethod (c$, "readAtomsInBohrCoordinates",
|
||||
function () {
|
||||
this.rd ();
|
||||
var atomName;
|
||||
this.asc.newAtomSet ();
|
||||
var n = 0;
|
||||
while (this.rd () != null && (atomName = this.parseTokenRange (this.line, 1, 11)) != null) {
|
||||
var x = this.parseFloatRange (this.line, 17, 37);
|
||||
var y = this.parseFloatRange (this.line, 37, 57);
|
||||
var z = this.parseFloatRange (this.line, 57, 77);
|
||||
if (Float.isNaN (x) || Float.isNaN (y) || Float.isNaN (z)) break;
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (this.parseIntRange (this.line, 11, 14));
|
||||
atom.atomName = atom.elementSymbol + (++n);
|
||||
this.setAtomCoordXYZ (atom, x * 0.5291772, y * 0.5291772, z * 0.5291772);
|
||||
this.atomNames.addLast (atomName);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtomsInAngstromCoordinates",
|
||||
function () {
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
var atomName;
|
||||
this.asc.newAtomSet ();
|
||||
var n = 0;
|
||||
while (this.rd () != null && (atomName = this.parseTokenRange (this.line, 1, 11)) != null) {
|
||||
var x = this.parseFloatRange (this.line, 16, 31);
|
||||
var y = this.parseFloatRange (this.line, 31, 46);
|
||||
var z = this.parseFloatRange (this.line, 46, 61);
|
||||
if (Float.isNaN (x) || Float.isNaN (y) || Float.isNaN (z)) break;
|
||||
var atom = this.asc.addNewAtom ();
|
||||
this.setAtomCoordXYZ (atom, x, y, z);
|
||||
atom.elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (this.parseIntRange (this.line, 11, 14));
|
||||
atom.atomName = atom.elementSymbol + (++n);
|
||||
this.atomNames.addLast (atomName);
|
||||
}
|
||||
if (this.line.indexOf ("COORDINATES OF FRAGMENT MULTIPOLE CENTERS (ANGS)") >= 0) {
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
while (this.rd () != null && (atomName = this.parseTokenRange (this.line, 1, 2)) != null) {
|
||||
if (this.parseTokenRange (this.line, 1, 2).equals ("Z")) atomName = this.parseTokenRange (this.line, 2, 3);
|
||||
else if (this.parseTokenRange (this.line, 1, 9).equals ("FRAGNAME")) continue;
|
||||
else atomName = this.parseTokenRange (this.line, 1, 2);
|
||||
var x = this.parseFloatRange (this.line, 16, 31);
|
||||
var y = this.parseFloatRange (this.line, 31, 46);
|
||||
var z = this.parseFloatRange (this.line, 46, 61);
|
||||
if (Float.isNaN (x) || Float.isNaN (y) || Float.isNaN (z)) break;
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.atomName = atomName + (++n);
|
||||
this.setAtomCoordXYZ (atom, x, y, z);
|
||||
this.atomNames.addLast (atomName);
|
||||
}
|
||||
}});
|
||||
Clazz.overrideMethod (c$, "fixShellTag",
|
||||
function (tag) {
|
||||
return tag;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readPartialCharges",
|
||||
function () {
|
||||
var tokens = null;
|
||||
var searchstr = (this.lowdenCharges ? "LOW.POP." : "MULL.POP.");
|
||||
while (this.rd () != null && ("".equals (this.line.trim ()) || this.line.indexOf ("ATOM") >= 0)) {
|
||||
tokens = this.getTokens ();
|
||||
}
|
||||
var poploc = 0;
|
||||
for (; ++poploc < tokens.length; ) if (searchstr.equals (tokens[poploc])) break;
|
||||
|
||||
if (++poploc >= tokens.length || !"CHARGE".equals (tokens[poploc++])) return;
|
||||
var atoms = this.asc.atoms;
|
||||
var startAtom = this.asc.getLastAtomSetAtomIndex ();
|
||||
var endAtom = this.asc.ac;
|
||||
for (var i = startAtom; i < endAtom && this.rd () != null; ++i) atoms[i].partialCharge = this.parseFloatStr (JU.PT.getTokens (this.prevline)[poploc]);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "readDipoleMoment",
|
||||
function () {
|
||||
var tokens = null;
|
||||
this.rd ();
|
||||
while (this.line != null && ("".equals (this.line.trim ()) || this.line.indexOf ("DX") < 0)) {
|
||||
this.rd ();
|
||||
}
|
||||
tokens = this.getTokens ();
|
||||
if (tokens.length != 5) return;
|
||||
if ("DX".equals (tokens[0]) && "DY".equals (tokens[1]) && "DZ".equals (tokens[2])) {
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
var dipole = JU.V3.new3 (this.parseFloatStr (tokens[0]), this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]));
|
||||
JU.Logger.info ("Molecular dipole for model " + this.asc.atomSetCount + " = " + dipole);
|
||||
this.asc.setCurrentModelInfo ("dipole", dipole);
|
||||
}});
|
||||
});
|
||||
@@ -0,0 +1,256 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.GaussianReader"], "J.adapter.readers.quantum.GaussianFchkReader", ["java.lang.Double", "$.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "$.V3", "J.adapter.readers.quantum.BasisFunctionReader", "J.adapter.smarter.Bond", "JU.Escape", "$.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.fileData = null;
|
||||
this.atomCount = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "GaussianFchkReader", J.adapter.readers.quantum.GaussianReader);
|
||||
Clazz.defineMethod (c$, "initializeReader",
|
||||
function () {
|
||||
Clazz.superCall (this, J.adapter.readers.quantum.GaussianFchkReader, "initializeReader", []);
|
||||
this.energyUnits = "";
|
||||
this.fileData = new java.util.Hashtable ();
|
||||
this.fileData.put ("title", this.rd ().trim ());
|
||||
this.calculationType = JU.PT.rep (this.rd (), " ", " ");
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setCurrentModelInfo ("fileData", this.fileData);
|
||||
this.readAllData ();
|
||||
this.readAtoms ();
|
||||
this.readBonds ();
|
||||
this.readDipoleMoment ();
|
||||
this.readPartialCharges ();
|
||||
this.readBasis ();
|
||||
this.readMolecularObitals ();
|
||||
this.checkForFreq ();
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "checkForFreq",
|
||||
function () {
|
||||
var n = this.fileData.get ("Vib-NDim");
|
||||
if (n == null) {
|
||||
this.readFrequencies ("NumFreq", false);
|
||||
return;
|
||||
}try {
|
||||
var nModes = n.intValue ();
|
||||
var vibE2 = this.fileData.get ("Vib-E2");
|
||||
var modes = this.fileData.get ("Vib-Modes");
|
||||
var frequencies = this.fillFloat (vibE2, 0, nModes);
|
||||
var red_masses = this.fillFloat (vibE2, nModes, nModes);
|
||||
var frc_consts = this.fillFloat (vibE2, nModes * 2, nModes);
|
||||
var intensities = this.fillFloat (vibE2, nModes * 3, nModes);
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var ignore = Clazz.newBooleanArray (nModes, false);
|
||||
var fpt = 0;
|
||||
for (var i = 0; i < nModes; ++i) {
|
||||
ignore[i] = !this.doGetVibration (++this.vibrationNumber);
|
||||
if (ignore[i]) continue;
|
||||
var iAtom0 = this.asc.ac;
|
||||
this.asc.cloneAtomSetWithBonds (true);
|
||||
var name = this.asc.setAtomSetFrequency ("Calculation " + this.calculationNumber, null, "" + frequencies[i], null);
|
||||
this.appendLoadNote ("model " + this.asc.atomSetCount + ": " + name);
|
||||
this.namedSets.set (this.asc.iSet);
|
||||
this.asc.setAtomSetModelProperty ("ReducedMass", red_masses[i] + " AMU");
|
||||
this.asc.setAtomSetModelProperty ("ForceConstant", frc_consts[i] + " mDyne/A");
|
||||
this.asc.setAtomSetModelProperty ("IRIntensity", intensities[i] + " KM/Mole");
|
||||
for (var iAtom = 0; iAtom < ac; iAtom++) {
|
||||
this.asc.addVibrationVectorWithSymmetry (iAtom0 + iAtom, modes[fpt++], modes[fpt++], modes[fpt++], false);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
JU.Logger.error ("Could not read Vib-E2 section: " + e.getMessage ());
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "fillFloat",
|
||||
function (f0, i, n) {
|
||||
var f = Clazz.newFloatArray (n, 0);
|
||||
for (var i1 = 0, ilast = i + n; i < ilast; i++, i1++) f[i1] = f0[i];
|
||||
|
||||
return f;
|
||||
}, "~A,~N,~N");
|
||||
Clazz.defineMethod (c$, "readAllData",
|
||||
function () {
|
||||
while ((this.line == null ? this.rd () : this.line) != null) {
|
||||
if (this.line.length < 40) {
|
||||
if (this.line.indexOf ("NumAtom") == 0) {
|
||||
return;
|
||||
}continue;
|
||||
}var name = JU.PT.rep (this.line.substring (0, 40).trim (), " ", "");
|
||||
var type = this.line.charAt (43);
|
||||
var isArray = (this.line.indexOf ("N=") >= 0);
|
||||
var v = this.line.substring (50).trim ();
|
||||
JU.Logger.info (name + " = " + v + " " + isArray);
|
||||
var o = null;
|
||||
if (isArray) {
|
||||
switch (type) {
|
||||
case 'I':
|
||||
case 'R':
|
||||
o = this.fillFloatArray (null, 0, Clazz.newFloatArray (this.parseIntStr (v), 0));
|
||||
this.line = null;
|
||||
break;
|
||||
default:
|
||||
v = this.rd ().trim ();
|
||||
while (this.rd () != null && this.line.indexOf (" N= ") < 0) v += " " + this.line.trim ();
|
||||
|
||||
o = v;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (type) {
|
||||
case 'I':
|
||||
o = Integer.$valueOf (this.parseIntStr (v));
|
||||
break;
|
||||
case 'R':
|
||||
o = Double.$valueOf (Double.parseDouble (v));
|
||||
break;
|
||||
case 'C':
|
||||
case 'L':
|
||||
o = v;
|
||||
break;
|
||||
}
|
||||
this.line = null;
|
||||
}if (o != null) this.fileData.put (name, o);
|
||||
}
|
||||
});
|
||||
Clazz.overrideMethod (c$, "readAtoms",
|
||||
function () {
|
||||
var atomNumbers = this.fileData.get ("Atomicnumbers");
|
||||
var data = this.fileData.get ("Currentcartesiancoordinates");
|
||||
var e = "" + this.fileData.get ("TotalEnergy");
|
||||
this.asc.setAtomSetEnergy (e, this.parseFloatStr (e));
|
||||
this.atomCount = atomNumbers.length;
|
||||
var f = 0.5291772;
|
||||
for (var i = 0, pt = 0; i < this.atomCount; i++) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.elementNumber = Clazz.floatToShort (atomNumbers[i]);
|
||||
if (atom.elementNumber < 0) atom.elementNumber = 0;
|
||||
this.setAtomCoordXYZ (atom, data[pt++] * f, data[pt++] * f, data[pt++] * f);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBonds",
|
||||
function () {
|
||||
try {
|
||||
var nBond = this.fileData.get ("NBond");
|
||||
var iBond = this.fileData.get ("IBond");
|
||||
if (nBond.length == 0) return;
|
||||
var rBond = this.fileData.get ("RBond");
|
||||
var mxBond = Clazz.doubleToInt (rBond.length / nBond.length);
|
||||
for (var ia = 0, pt = 0; ia < this.atomCount; ia++) for (var j = 0; j < mxBond; j++, pt++) {
|
||||
var ib = Clazz.floatToInt (iBond[pt]) - 1;
|
||||
if (ib <= ia) continue;
|
||||
var order = rBond[pt];
|
||||
var iorder = (order == 1.5 ? 515 : Clazz.floatToInt (order));
|
||||
this.asc.addBond ( new J.adapter.smarter.Bond (ia, ib, iorder));
|
||||
}
|
||||
|
||||
this.addJmolScript ("connect 1.1 {_H} {*} ");
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
JU.Logger.info ("GaussianFchkReader -- bonding ignored");
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.overrideMethod (c$, "readDipoleMoment",
|
||||
function () {
|
||||
var data = this.fileData.get ("DipoleMoment");
|
||||
if (data == null) return;
|
||||
var dipole = JU.V3.new3 (data[0], data[1], data[2]);
|
||||
JU.Logger.info ("Molecular dipole for model " + this.asc.atomSetCount + " = " + dipole);
|
||||
this.asc.setCurrentModelInfo ("dipole", dipole);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "readPartialCharges",
|
||||
function () {
|
||||
var data = this.fileData.get ("Mulliken Charges");
|
||||
if (data == null) return;
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = 0; i < this.atomCount; ++i) {
|
||||
var c = data[i];
|
||||
atoms[i].partialCharge = c;
|
||||
if (Math.abs (c) > 0.8) atoms[i].formalCharge = Math.round (c);
|
||||
}
|
||||
JU.Logger.info ("Mulliken charges found for Model " + this.asc.atomSetCount);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "readBasis",
|
||||
function () {
|
||||
var types = this.fileData.get ("Shelltypes");
|
||||
this.gaussianCount = 0;
|
||||
this.shellCount = 0;
|
||||
if (types == null) return;
|
||||
this.shellCount = types.length;
|
||||
this.shells = new JU.Lst ();
|
||||
var pps = this.fileData.get ("Numberofprimitivespershell");
|
||||
var atomMap = this.fileData.get ("Shelltoatommap");
|
||||
var exps = this.fileData.get ("Primitiveexponents");
|
||||
var coefs = this.fileData.get ("Contractioncoefficients");
|
||||
var spcoefs = this.fileData.get ("P(S=P)Contractioncoefficients");
|
||||
this.gaussians = JU.AU.newFloat2 (exps.length);
|
||||
for (var i = 0; i < this.shellCount; i++) {
|
||||
var oType = J.adapter.readers.quantum.GaussianFchkReader.AO_TYPES[Clazz.floatToInt (types[i]) + 3];
|
||||
var nGaussians = Clazz.floatToInt (pps[i]);
|
||||
var iatom = Clazz.floatToInt (atomMap[i]);
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
slater[0] = iatom;
|
||||
if (oType.equals ("F7") || oType.equals ("D5")) slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagIDSpherical (oType.substring (0, 1));
|
||||
else slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (oType);
|
||||
slater[2] = this.gaussianCount + 1;
|
||||
slater[3] = nGaussians;
|
||||
if (this.debugging) JU.Logger.debug ("Slater " + this.shells.size () + " " + JU.Escape.eAI (slater));
|
||||
this.shells.addLast (slater);
|
||||
for (var j = 0; j < nGaussians; j++) {
|
||||
var g = this.gaussians[this.gaussianCount] = Clazz.newFloatArray (3, 0);
|
||||
g[0] = exps[this.gaussianCount];
|
||||
g[1] = coefs[this.gaussianCount];
|
||||
if (spcoefs != null) g[2] = spcoefs[this.gaussianCount];
|
||||
this.gaussianCount++;
|
||||
}
|
||||
}
|
||||
JU.Logger.info (this.shellCount + " slater shells read");
|
||||
JU.Logger.info (this.gaussianCount + " gaussian primitives read");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularObitals",
|
||||
function () {
|
||||
if (this.shells == null) return;
|
||||
var nElec = (this.fileData.get ("Numberofelectrons")).intValue ();
|
||||
var nAlpha = (this.fileData.get ("Numberofalphaelectrons")).intValue ();
|
||||
var nBeta = (this.fileData.get ("Numberofbetaelectrons")).intValue ();
|
||||
var aenergies = this.fileData.get ("AlphaOrbitalEnergies");
|
||||
var benergies = this.fileData.get ("BetaOrbitalEnergies");
|
||||
var acoefs = this.fileData.get ("AlphaMOcoefficients");
|
||||
var bcoefs = this.fileData.get ("BetaMOcoefficients");
|
||||
if (acoefs == null) return;
|
||||
var occ = (bcoefs == null ? 2 : 1);
|
||||
var n = (bcoefs == null ? nElec : nAlpha);
|
||||
this.getOrbitals (aenergies, acoefs, occ, n);
|
||||
if (bcoefs != null) this.getOrbitals (benergies, bcoefs, occ, nBeta);
|
||||
this.setMOData (false);
|
||||
});
|
||||
Clazz.defineMethod (c$, "getOrbitals",
|
||||
function (e, c, occ, nElec) {
|
||||
var nOrb = e.length;
|
||||
var nCoef = c.length;
|
||||
nCoef /= nOrb;
|
||||
this.alphaBeta = (occ == 2 ? "" : this.alphaBeta.equals ("alpha") ? "beta" : "alpha");
|
||||
var pt = 0;
|
||||
var n = 0;
|
||||
for (var i = 0; i < nOrb; i++) {
|
||||
var coefs = Clazz.newFloatArray (nCoef, 0);
|
||||
for (var j = 0; j < nCoef; j++) coefs[j] = c[pt++];
|
||||
|
||||
var mo = new java.util.Hashtable ();
|
||||
mo.put ("coefficients", coefs);
|
||||
mo.put ("occupancy", Float.$valueOf (occ));
|
||||
n += occ;
|
||||
if (n >= nElec) occ = 0;
|
||||
mo.put ("energy", Float.$valueOf (e[i]));
|
||||
mo.put ("type", this.alphaBeta);
|
||||
this.setMO (mo);
|
||||
}
|
||||
}, "~A,~A,~N,~N");
|
||||
Clazz.defineStatics (c$,
|
||||
"AO_TYPES", Clazz.newArray (-1, ["F7", "D5", "L", "S", "P", "D", "F", "G", "H"]));
|
||||
});
|
||||
@@ -0,0 +1,345 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MOReader", "JU.BS"], "J.adapter.readers.quantum.GaussianReader", ["java.lang.Exception", "$.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "$.V3", "J.adapter.readers.quantum.BasisFunctionReader", "J.adapter.smarter.SmarterJmolAdapter", "J.quantum.QS", "JU.Escape", "$.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.energyString = "";
|
||||
this.energyKey = "";
|
||||
this.calculationNumber = 1;
|
||||
this.scanPoint = -1;
|
||||
this.equivalentAtomSets = 0;
|
||||
this.stepNumber = 0;
|
||||
this.moModelSet = -1;
|
||||
this.namedSets = null;
|
||||
this.isHighPrecision = false;
|
||||
this.haveHighPrecision = false;
|
||||
this.allowHighPrecision = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "GaussianReader", J.adapter.readers.quantum.MOReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.namedSets = new JU.BS ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.allowHighPrecision = !this.checkAndRemoveFilterKey ("NOHP");
|
||||
Clazz.superCall (this, J.adapter.readers.quantum.GaussianReader, "initializeReader", []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.startsWith (" Step number")) {
|
||||
this.equivalentAtomSets = 0;
|
||||
this.stepNumber++;
|
||||
var scanPointIndex = this.line.indexOf ("scan point");
|
||||
if (scanPointIndex > 0) {
|
||||
this.scanPoint = this.parseIntAt (this.line, scanPointIndex + 10);
|
||||
} else {
|
||||
this.scanPoint = -1;
|
||||
}return true;
|
||||
}if (this.line.indexOf ("-- Stationary point found") > 0) {
|
||||
if (this.scanPoint >= 0) this.scanPoint++;
|
||||
return true;
|
||||
}if (this.line.indexOf ("Input orientation:") >= 0 || this.line.indexOf ("Z-Matrix orientation:") >= 0 || this.line.indexOf ("Standard orientation:") >= 0) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) {
|
||||
return this.checkLastModel ();
|
||||
}this.equivalentAtomSets++;
|
||||
JU.Logger.info (this.asc.atomSetCount + " model " + this.modelNumber + " step " + this.stepNumber + " equivalentAtomSet " + this.equivalentAtomSets + " calculation " + this.calculationNumber + " scan point " + this.scanPoint + this.line);
|
||||
this.readAtoms ();
|
||||
return false;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.startsWith (" Energy=")) {
|
||||
this.setEnergy ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" SCF Done:")) {
|
||||
this.readSCFDone ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" Harmonic frequencies")) {
|
||||
this.readFrequencies (":", true);
|
||||
return true;
|
||||
}if (this.line.startsWith (" Total atomic charges:") || this.line.startsWith (" Mulliken atomic charges:")) {
|
||||
this.readPartialCharges ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" Dipole moment")) {
|
||||
this.readDipoleMoment ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" Standard basis:") || this.line.startsWith (" General basis read from")) {
|
||||
this.energyUnits = "";
|
||||
this.calculationType = this.line.substring (this.line.indexOf (":") + 1).trim ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" AO basis set")) {
|
||||
this.readBasis ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Molecular Orbital Coefficients") >= 0 || this.line.indexOf ("Natural Orbital Coefficients") >= 0 || this.line.indexOf ("Natural Transition Orbitals") >= 0) {
|
||||
if (!this.filterMO ()) return true;
|
||||
this.readMolecularOrbitals ();
|
||||
JU.Logger.info (this.orbitals.size () + " molecular orbitals read");
|
||||
return true;
|
||||
}if (this.line.startsWith (" Normal termination of Gaussian")) {
|
||||
++this.calculationNumber;
|
||||
this.equivalentAtomSets = 0;
|
||||
return true;
|
||||
}if (this.line.startsWith (" Mulliken atomic spin densities:")) {
|
||||
this.getSpinDensities (11);
|
||||
return true;
|
||||
}if (this.line.startsWith (" Mulliken charges and spin densities:")) {
|
||||
this.getSpinDensities (21);
|
||||
return true;
|
||||
}return this.checkNboLine ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "getSpinDensities",
|
||||
function (pt) {
|
||||
this.rd ();
|
||||
var data = Clazz.newFloatArray (this.asc.getLastAtomSetAtomCount (), 0);
|
||||
for (var i = 0; i < data.length; i++) data[i] = this.parseFloatStr (this.rd ().substring (pt, pt + 10));
|
||||
|
||||
this.asc.setAtomProperties ("spin", data, -1, false);
|
||||
this.appendLoadNote (data.length + " spin densities loaded into model " + (this.asc.iSet + 1));
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readSCFDone",
|
||||
function () {
|
||||
var tokens = JU.PT.getTokensAt (this.line, 11);
|
||||
if (tokens.length < 4) return;
|
||||
this.energyKey = tokens[0];
|
||||
this.asc.setAtomSetEnergy (tokens[2], this.parseFloatStr (tokens[2]));
|
||||
this.energyString = tokens[2] + " " + tokens[3];
|
||||
this.setNames (this.energyKey + " = " + this.energyString, this.namedSets, this.equivalentAtomSets);
|
||||
this.setProps (this.energyKey, this.energyString, this.equivalentAtomSets);
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
if (tokens.length > 2) {
|
||||
this.setProps (tokens[0], tokens[2], this.equivalentAtomSets);
|
||||
if (tokens.length > 5) this.setProps (tokens[3], tokens[5], this.equivalentAtomSets);
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
}if (tokens.length > 2) this.setProps (tokens[0], tokens[2], this.equivalentAtomSets);
|
||||
});
|
||||
Clazz.defineMethod (c$, "setProps",
|
||||
function (key, value, n) {
|
||||
for (var i = this.asc.iSet; --n >= 0 && i >= 0; --i) this.asc.setAtomSetModelPropertyForSet (key, value, i);
|
||||
|
||||
}, "~S,~S,~N");
|
||||
Clazz.defineMethod (c$, "setNames",
|
||||
function (atomSetName, namedSets, n) {
|
||||
for (var i = this.asc.iSet; --n >= 0 && i >= 0; --i) if (namedSets == null || !namedSets.get (i)) this.asc.setModelInfoForSet ("name", atomSetName, i);
|
||||
|
||||
}, "~S,JU.BS,~N");
|
||||
Clazz.defineMethod (c$, "setEnergy",
|
||||
function () {
|
||||
var tokens = this.getTokens ();
|
||||
this.energyKey = "Energy";
|
||||
this.energyString = tokens[1];
|
||||
this.setNames ("Energy = " + tokens[1], this.namedSets, this.equivalentAtomSets);
|
||||
this.asc.setAtomSetEnergy (this.energyString, this.parseFloatStr (this.energyString));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
this.haveHighPrecision = false;
|
||||
if (this.energyKey.length != 0) this.asc.setAtomSetName (this.energyKey + " = " + this.energyString);
|
||||
this.asc.setAtomSetEnergy (this.energyString, this.parseFloatStr (this.energyString));
|
||||
var path = this.getTokens ()[0];
|
||||
this.readLines (4);
|
||||
var tokens;
|
||||
while (this.rd () != null && !this.line.startsWith (" --")) {
|
||||
tokens = this.getTokens ();
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.elementNumber = this.parseIntStr (tokens[1]);
|
||||
if (atom.elementNumber < 0) atom.elementNumber = 0;
|
||||
this.setAtomCoordTokens (atom, tokens, tokens.length - 3);
|
||||
}
|
||||
this.asc.setAtomSetModelProperty (".PATH", "Calculation " + this.calculationNumber + (this.scanPoint >= 0 ? (J.adapter.smarter.SmarterJmolAdapter.PATH_SEPARATOR + "Scan Point " + this.scanPoint) : "") + J.adapter.smarter.SmarterJmolAdapter.PATH_SEPARATOR + path);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBasis",
|
||||
function () {
|
||||
this.shells = new JU.Lst ();
|
||||
var gdata = new JU.Lst ();
|
||||
var ac = 0;
|
||||
this.gaussianCount = 0;
|
||||
this.shellCount = 0;
|
||||
var lastAtom = "";
|
||||
var tokens;
|
||||
var doSphericalD = (this.calculationType != null && (this.calculationType.indexOf ("5D") > 0));
|
||||
var doSphericalF = (this.calculationType != null && (this.calculationType.indexOf ("7F") > 0));
|
||||
var isGeneral = (this.line.indexOf ("general basis input") >= 0);
|
||||
if (isGeneral) {
|
||||
while (this.rd () != null && this.line.length > 0) {
|
||||
this.shellCount++;
|
||||
tokens = this.getTokens ();
|
||||
ac++;
|
||||
while (this.rd ().indexOf ("****") < 0) {
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
slater[0] = ac;
|
||||
tokens = this.getTokens ();
|
||||
var oType = tokens[0];
|
||||
if (doSphericalF && oType.indexOf ("F") >= 0 || doSphericalD && oType.indexOf ("D") >= 0) slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagIDSpherical (oType);
|
||||
else slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (oType);
|
||||
var nGaussians = this.parseIntStr (tokens[1]);
|
||||
slater[2] = this.gaussianCount + 1;
|
||||
slater[3] = nGaussians;
|
||||
if (this.debugging) JU.Logger.debug ("Slater " + this.shells.size () + " " + JU.Escape.eAI (slater));
|
||||
this.shells.addLast (slater);
|
||||
this.gaussianCount += nGaussians;
|
||||
for (var i = 0; i < nGaussians; i++) {
|
||||
this.rd ();
|
||||
this.line = JU.PT.rep (this.line, "D ", "D+");
|
||||
tokens = this.getTokens ();
|
||||
if (this.debugging) JU.Logger.debug ("Gaussians " + (i + 1) + " " + JU.Escape.eAS (tokens, true));
|
||||
gdata.addLast (tokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (this.rd () != null && this.line.startsWith (" Atom")) {
|
||||
this.shellCount++;
|
||||
tokens = this.getTokens ();
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
if (!tokens[1].equals (lastAtom)) ac++;
|
||||
lastAtom = tokens[1];
|
||||
slater[0] = ac;
|
||||
var oType = tokens[4];
|
||||
if (doSphericalF && oType.indexOf ("F") >= 0 || doSphericalD && oType.indexOf ("D") >= 0) slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagIDSpherical (oType);
|
||||
else slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (oType);
|
||||
var nGaussians = this.parseIntStr (tokens[5]);
|
||||
slater[2] = this.gaussianCount + 1;
|
||||
slater[3] = nGaussians;
|
||||
this.shells.addLast (slater);
|
||||
this.gaussianCount += nGaussians;
|
||||
for (var i = 0; i < nGaussians; i++) {
|
||||
gdata.addLast (JU.PT.getTokens (this.rd ()));
|
||||
}
|
||||
}
|
||||
}if (ac == 0) ac = 1;
|
||||
this.gaussians = JU.AU.newFloat2 (this.gaussianCount);
|
||||
for (var i = 0; i < this.gaussianCount; i++) {
|
||||
tokens = gdata.get (i);
|
||||
this.gaussians[i] = Clazz.newFloatArray (tokens.length, 0);
|
||||
for (var j = 0; j < tokens.length; j++) this.gaussians[i][j] = this.parseFloatStr (tokens[j]);
|
||||
|
||||
}
|
||||
JU.Logger.info (this.shellCount + " slater shells read");
|
||||
JU.Logger.info (this.gaussianCount + " gaussian primitives read");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbitals",
|
||||
function () {
|
||||
if (this.shells == null) return;
|
||||
var mos = JU.AU.createArrayOfHashtable (5);
|
||||
var data = JU.AU.createArrayOfArrayList (5);
|
||||
var nThisLine = 0;
|
||||
var isNOtype = this.line.contains ("Natural Orbital");
|
||||
while (this.rd () != null && this.line.toUpperCase ().indexOf ("DENS") < 0) {
|
||||
var tokens;
|
||||
if (this.line.indexOf ("eta Molecular Orbital Coefficients") >= 0) {
|
||||
this.addMOData (nThisLine, data, mos);
|
||||
nThisLine = 0;
|
||||
if (!this.filterMO ()) break;
|
||||
}if (this.line.indexOf (" ") == 0) {
|
||||
this.addMOData (nThisLine, data, mos);
|
||||
if (isNOtype) {
|
||||
tokens = this.getTokens ();
|
||||
nThisLine = tokens.length;
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
} else {
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
nThisLine = tokens.length;
|
||||
}for (var i = 0; i < nThisLine; i++) {
|
||||
mos[i] = new java.util.Hashtable ();
|
||||
data[i] = new JU.Lst ();
|
||||
var sym;
|
||||
if (isNOtype) {
|
||||
mos[i].put ("occupancy", Float.$valueOf (JU.PT.parseFloat (tokens[i + 2])));
|
||||
} else {
|
||||
sym = tokens[i];
|
||||
mos[i].put ("symmetry", sym);
|
||||
if (sym.indexOf ("O") >= 0) mos[i].put ("occupancy", Float.$valueOf (2));
|
||||
else if (sym.indexOf ("V") >= 0) mos[i].put ("occupancy", Float.$valueOf (0));
|
||||
}}
|
||||
if (isNOtype) continue;
|
||||
this.line = this.rd ().substring (21);
|
||||
tokens = this.getTokens ();
|
||||
if (tokens.length != nThisLine) tokens = J.adapter.smarter.AtomSetCollectionReader.getStrings (this.line, nThisLine, 10);
|
||||
for (var i = 0; i < nThisLine; i++) {
|
||||
mos[i].put ("energy", Float.$valueOf (JU.PT.fVal (tokens[i])));
|
||||
}
|
||||
continue;
|
||||
} else if (this.line.length < 21 || (this.line.charAt (5) != ' ' && !JU.PT.isDigit (this.line.charAt (5)))) {
|
||||
continue;
|
||||
}try {
|
||||
this.line = JU.PT.rep (this.line, " 0 ", "0 ");
|
||||
tokens = this.getTokens ();
|
||||
var type = tokens[tokens.length - nThisLine - 1].substring (1);
|
||||
if (JU.PT.isDigit (type.charAt (0))) type = type.substring (1);
|
||||
if (!J.quantum.QS.isQuantumBasisSupported (type.charAt (0)) && "XYZ".indexOf (type.charAt (0)) >= 0) type = (type.length == 2 ? "D" : "F") + type;
|
||||
if (!J.quantum.QS.isQuantumBasisSupported (type.charAt (0))) continue;
|
||||
tokens = J.adapter.smarter.AtomSetCollectionReader.getStrings (this.line.substring (this.line.length - 10 * nThisLine), nThisLine, 10);
|
||||
for (var i = 0; i < nThisLine; i++) data[i].addLast (tokens[i]);
|
||||
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
JU.Logger.error ("Error reading Gaussian file Molecular Orbitals at line: " + this.line);
|
||||
break;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.addMOData (nThisLine, data, mos);
|
||||
this.setMOData (this.moModelSet != this.asc.atomSetCount);
|
||||
this.moModelSet = this.asc.atomSetCount;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function (key, mustHave) {
|
||||
this.discardLinesUntilContains2 (key, ":");
|
||||
if (this.line == null && mustHave) throw ( new Exception ("No frequencies encountered"));
|
||||
while ((this.line = this.rd ()) != null && this.line.length > 15) {
|
||||
var symmetries = JU.PT.getTokens (this.rd ());
|
||||
this.discardLinesUntilContains (" Frequencies");
|
||||
this.isHighPrecision = (this.line.indexOf ("---") > 0);
|
||||
if (this.isHighPrecision ? !this.allowHighPrecision : this.haveHighPrecision) return;
|
||||
if (this.isHighPrecision && !this.haveHighPrecision) {
|
||||
this.appendLoadNote ("high precision vibrational modes enabled. Use filter 'NOHP' to disable.");
|
||||
this.haveHighPrecision = true;
|
||||
}var width = (this.isHighPrecision ? 22 : 15);
|
||||
var frequencies = JU.PT.getTokensAt (this.line, width);
|
||||
var red_masses = JU.PT.getTokensAt (this.discardLinesUntilContains (this.isHighPrecision ? "Reduced masses" : "Red. masses"), width);
|
||||
var frc_consts = JU.PT.getTokensAt (this.discardLinesUntilContains (this.isHighPrecision ? "Force constants" : "Frc consts"), width);
|
||||
var intensities = JU.PT.getTokensAt (this.discardLinesUntilContains (this.isHighPrecision ? "IR Intensities" : "IR Inten"), width);
|
||||
var iAtom0 = this.asc.ac;
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var frequencyCount = frequencies.length;
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
for (var i = 0; i < frequencyCount; ++i) {
|
||||
ignore[i] = !this.doGetVibration (++this.vibrationNumber);
|
||||
if (ignore[i]) continue;
|
||||
this.asc.cloneAtomSetWithBonds (true);
|
||||
var name = this.asc.setAtomSetFrequency ("Calculation " + this.calculationNumber, symmetries[i], frequencies[i], null);
|
||||
this.appendLoadNote ("model " + this.asc.atomSetCount + ": " + name);
|
||||
this.namedSets.set (this.asc.iSet);
|
||||
this.asc.setAtomSetModelProperty ("ReducedMass", red_masses[i] + " AMU");
|
||||
this.asc.setAtomSetModelProperty ("ForceConstant", frc_consts[i] + " mDyne/A");
|
||||
this.asc.setAtomSetModelProperty ("IRIntensity", intensities[i] + " KM/Mole");
|
||||
}
|
||||
this.discardLinesUntilContains (" Atom ");
|
||||
if (this.isHighPrecision) this.fillFrequencyData (iAtom0, ac, ac, ignore, false, 23, 10, null, 0);
|
||||
else this.fillFrequencyData (iAtom0, ac, ac, ignore, true, 0, 0, null, 0);
|
||||
}
|
||||
}, "~S,~B");
|
||||
Clazz.defineMethod (c$, "readDipoleMoment",
|
||||
function () {
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
if (tokens.length != 8) return;
|
||||
var dipole = JU.V3.new3 (this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[3]), this.parseFloatStr (tokens[5]));
|
||||
JU.Logger.info ("Molecular dipole for model " + this.asc.atomSetCount + " = " + dipole);
|
||||
this.asc.setCurrentModelInfo ("dipole", dipole);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPartialCharges",
|
||||
function () {
|
||||
this.rd ();
|
||||
var ac = this.asc.ac;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = i0; i < ac; ++i) {
|
||||
while (atoms[i].elementNumber == 0) ++i;
|
||||
|
||||
var charge = this.parseFloatStr (JU.PT.getTokens (this.rd ())[2]);
|
||||
atoms[i].partialCharge = charge;
|
||||
}
|
||||
JU.Logger.info ("Mulliken charges found for Model " + this.asc.atomSetCount);
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"STD_ORIENTATION_ATOMIC_NUMBER_OFFSET", 1);
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.quantum.GaussianWfnReader", null, function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.quantum, "GaussianWfnReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.continuing = false;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,396 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MOReader"], "J.adapter.readers.quantum.GenNBOReader", ["java.lang.Boolean", "$.Exception", "$.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "$.Rdr", "$.SB", "J.adapter.readers.quantum.NBOParser", "J.quantum.QS", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.isOutputFile = false;
|
||||
this.nboType = "";
|
||||
this.nOrbitals0 = 0;
|
||||
this.is47File = false;
|
||||
this.isOpenShell = false;
|
||||
this.alphaOnly = false;
|
||||
this.betaOnly = false;
|
||||
this.nAOs = 0;
|
||||
this.topoType = "A";
|
||||
this.nStructures = 0;
|
||||
this.nboParser = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "GenNBOReader", J.adapter.readers.quantum.MOReader);
|
||||
Clazz.defineMethod (c$, "initializeReader",
|
||||
function () {
|
||||
var line1 = this.rd ().trim ();
|
||||
this.is47File = (line1.indexOf ("$GENNBO") >= 0 || line1.indexOf ("$NBO") >= 0);
|
||||
this.alphaOnly = this.is47File || this.checkFilterKey ("ALPHA");
|
||||
this.betaOnly = !this.is47File && this.checkFilterKey ("BETA");
|
||||
if (this.is47File) {
|
||||
this.readData47 ();
|
||||
return;
|
||||
}var isOK;
|
||||
var line2 = this.rd ();
|
||||
this.line = line1 + line2;
|
||||
this.isOutputFile = (line2.indexOf ("****") >= 0);
|
||||
if (this.isOutputFile) {
|
||||
isOK = this.getFile31 ();
|
||||
Clazz.superCall (this, J.adapter.readers.quantum.GenNBOReader, "initializeReader", []);
|
||||
this.moData.put ("isNormalized", Boolean.TRUE);
|
||||
} else if (line2.indexOf ("s in the AO basis:") >= 0) {
|
||||
this.nboType = line2.substring (1, line2.indexOf ("s"));
|
||||
this.asc.setCollectionName (line1 + ": " + this.nboType + "s");
|
||||
isOK = this.getFile31 ();
|
||||
} else {
|
||||
this.nboType = "AO";
|
||||
this.asc.setCollectionName (line1 + ": " + this.nboType + "s");
|
||||
isOK = this.readData31 (line1);
|
||||
}if (!isOK) JU.Logger.error ("Unimplemented shell type -- no orbitals available: " + this.line);
|
||||
if (this.isOutputFile) return;
|
||||
if (isOK) this.readMOs ();
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.appendLoadNote ("NBO type " + this.nboType);
|
||||
if (this.isOpenShell) this.asc.setCurrentModelInfo ("isOpenShell", Boolean.TRUE);
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMOs",
|
||||
function () {
|
||||
this.nOrbitals0 = this.orbitals.size ();
|
||||
this.getFile46 ();
|
||||
if (this.betaOnly) {
|
||||
this.discardLinesUntilContains ("BETA");
|
||||
this.filterMO ();
|
||||
}var isAO = this.nboType.equals ("AO");
|
||||
var isNBO = !isAO && !this.nboType.equals ("MO");
|
||||
this.nOrbitals = this.orbitals.size ();
|
||||
if (this.nOrbitals == 0) return;
|
||||
this.line = null;
|
||||
if (!isNBO) this.nOrbitals = this.nOrbitals0 + this.nAOs;
|
||||
for (var i = this.nOrbitals0; i < this.nOrbitals; i++) {
|
||||
var mo = this.orbitals.get (i);
|
||||
var coefs = Clazz.newFloatArray (this.nAOs, 0);
|
||||
mo.put ("coefficients", coefs);
|
||||
if (!isAO) {
|
||||
if (this.line == null) {
|
||||
while (this.rd () != null && Float.isNaN (this.parseFloatStr (this.line))) {
|
||||
this.filterMO ();
|
||||
}
|
||||
} else {
|
||||
this.line = null;
|
||||
}this.fillFloatArray (this.line, 0, coefs);
|
||||
if (Float.isNaN (coefs[0])) System.out.println ("testing gennboreader");
|
||||
this.line = null;
|
||||
} else {
|
||||
coefs[i] = 1;
|
||||
}}
|
||||
if (this.nboType.equals ("NBO")) {
|
||||
var occupancies = Clazz.newFloatArray (this.nOrbitals - this.nOrbitals0, 0);
|
||||
this.fillFloatArray (null, 0, occupancies);
|
||||
for (var i = this.nOrbitals0; i < this.nOrbitals; i++) {
|
||||
var mo = this.orbitals.get (i);
|
||||
mo.put ("occupancy", Float.$valueOf (occupancies[i - this.nOrbitals0]));
|
||||
}
|
||||
}this.moData.put (this.nboType + "_coefs", this.orbitals);
|
||||
this.setMOData (false);
|
||||
this.moData.put ("isNormalized", Boolean.TRUE);
|
||||
this.moData.put ("nboType", this.nboType);
|
||||
JU.Logger.info ((this.orbitals.size () - this.nOrbitals0) + " orbitals read");
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf ("SECOND ORDER PERTURBATION THEORY ANALYSIS") >= 0 && !this.orbitalsRead) {
|
||||
this.nboType = "NBO";
|
||||
var data = this.getFileData (".37");
|
||||
if (data == null) return true;
|
||||
var readerSave = this.reader;
|
||||
this.reader = JU.Rdr.getBR (data);
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
this.readMOs ();
|
||||
this.reader = readerSave;
|
||||
this.orbitalsRead = false;
|
||||
return true;
|
||||
}if (this.line.indexOf ("$NRTSTRA") >= 0) {
|
||||
this.getStructures ("NRTSTRA");
|
||||
return true;
|
||||
}if (this.line.indexOf ("$NRTSTRB") >= 0) {
|
||||
this.getStructures ("NRTSTRB");
|
||||
return true;
|
||||
}if (this.line.indexOf ("$NRTSTR") >= 0) {
|
||||
this.getStructures ("NRTSTR");
|
||||
return true;
|
||||
}if (this.line.indexOf (" TOPO ") >= 0) {
|
||||
this.getStructures ("TOPO" + this.topoType);
|
||||
this.topoType = "B";
|
||||
return true;
|
||||
}if (this.line.indexOf ("$CHOOSE") >= 0) {
|
||||
this.getStructures ("CHOOSE");
|
||||
return true;
|
||||
}return this.checkNboLine ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "getStructures",
|
||||
function (type) {
|
||||
if (this.nboParser == null) this.nboParser = new J.adapter.readers.quantum.NBOParser ();
|
||||
var structures = this.getStructureList ();
|
||||
var sb = new JU.SB ();
|
||||
while (!this.rd ().trim ().equals ("$END")) sb.append (this.line).append ("\n");
|
||||
|
||||
this.nStructures = this.nboParser.getStructures (sb.toString (), type, structures);
|
||||
this.appendLoadNote (this.nStructures + " NBO " + type + " resonance structures");
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getStructureList",
|
||||
function () {
|
||||
var structures = this.asc.getAtomSetAuxiliaryInfo (this.asc.iSet).get ("nboStructures");
|
||||
if (structures == null) this.asc.setCurrentModelInfo ("nboStructures", structures = new JU.Lst ());
|
||||
return structures;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getFileData",
|
||||
function (ext) {
|
||||
var fileName = this.htParams.get ("fullPathName");
|
||||
var pt = fileName.lastIndexOf (".");
|
||||
if (pt < 0) pt = fileName.length;
|
||||
fileName = fileName.substring (0, pt);
|
||||
this.moData.put ("nboRoot", fileName);
|
||||
fileName += ext;
|
||||
var data = this.vwr.getFileAsString3 (fileName, false, null);
|
||||
JU.Logger.info (data.length + " bytes read from " + fileName);
|
||||
if (data.length == 0 || data.indexOf ("java.io.FileNotFound") >= 0 && this.nboType !== "AO") throw new Exception (" supplemental file " + fileName + " was not found");
|
||||
return data;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getFile31",
|
||||
function () {
|
||||
var data = this.getFileData (".31");
|
||||
var readerSave = this.reader;
|
||||
this.reader = JU.Rdr.getBR (data);
|
||||
return (this.readData31 (null) && (this.reader = readerSave) != null);
|
||||
});
|
||||
Clazz.defineMethod (c$, "getFile46",
|
||||
function () {
|
||||
var data = this.getFileData (".46");
|
||||
var readerSave = this.reader;
|
||||
this.reader = JU.Rdr.getBR (data);
|
||||
this.readData46 ();
|
||||
this.reader = readerSave;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readData47",
|
||||
function () {
|
||||
this.allowNoOrbitals = true;
|
||||
this.discardLinesUntilContains ("$COORD");
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetName (this.rd ().trim ());
|
||||
while (this.rd ().indexOf ("$END") < 0) {
|
||||
var tokens = this.getTokens ();
|
||||
this.addAtomXYZSymName (tokens, 2, null, null).elementNumber = this.parseIntStr (tokens[0]);
|
||||
}
|
||||
this.discardLinesUntilContains ("$BASIS");
|
||||
var centers = this.getIntData ();
|
||||
var labels = this.getIntData ();
|
||||
this.discardLinesUntilContains ("NSHELL =");
|
||||
this.shellCount = this.parseIntAt (this.line, 10);
|
||||
this.gaussianCount = this.parseIntAt (this.rd (), 10);
|
||||
this.rd ();
|
||||
var ncomp = this.getIntData ();
|
||||
var nprim = this.getIntData ();
|
||||
var nptr = this.getIntData ();
|
||||
this.shells = new JU.Lst ();
|
||||
this.gaussians = JU.AU.newFloat2 (this.gaussianCount);
|
||||
for (var i = 0; i < this.gaussianCount; i++) this.gaussians[i] = Clazz.newFloatArray (6, 0);
|
||||
|
||||
this.nOrbitals = 0;
|
||||
var ptCenter = 0;
|
||||
var l = this.line;
|
||||
for (var i = 0; i < this.shellCount; i++) {
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
var nc = ncomp[i];
|
||||
slater[0] = centers[ptCenter];
|
||||
this.line = "";
|
||||
for (var ii = 0; ii < nc; ii++) this.line += labels[ptCenter++] + " ";
|
||||
|
||||
if (!this.fillSlater (slater, nc, nptr[i] - 1, nprim[i])) return;
|
||||
}
|
||||
this.line = l;
|
||||
this.getAlphasAndExponents ();
|
||||
this.nboType = "AO";
|
||||
this.readMOs ();
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getIntData",
|
||||
function () {
|
||||
while (this.line.indexOf ("=") < 0) this.rd ();
|
||||
|
||||
var s = this.line.substring (this.line.indexOf ("=") + 1);
|
||||
this.line = "";
|
||||
while (this.rd ().indexOf ("=") < 0 && this.line.indexOf ("$") < 0) s += this.line;
|
||||
|
||||
var tokens = JU.PT.getTokens (s);
|
||||
var f = Clazz.newIntArray (tokens.length, 0);
|
||||
for (var i = f.length; --i >= 0; ) f[i] = this.parseIntStr (tokens[i]);
|
||||
|
||||
return f;
|
||||
});
|
||||
Clazz.defineMethod (c$, "fillSlater",
|
||||
function (slater, n, pt, ng) {
|
||||
this.nOrbitals += n;
|
||||
switch (n) {
|
||||
case 1:
|
||||
slater[1] = 0;
|
||||
break;
|
||||
case 3:
|
||||
if (!this.getDFMap ("P", this.line, 1, J.adapter.readers.quantum.GenNBOReader.$P_LIST, 3)) return false;
|
||||
slater[1] = 1;
|
||||
break;
|
||||
case 4:
|
||||
if (!this.getDFMap ("SP", this.line, 2, J.adapter.readers.quantum.GenNBOReader.SP_LIST, 1)) return false;
|
||||
slater[1] = 2;
|
||||
break;
|
||||
case 5:
|
||||
if (!this.getDFMap ("DS", this.line, 3, J.adapter.readers.quantum.GenNBOReader.$DS_LIST, 3)) return false;
|
||||
slater[1] = 3;
|
||||
break;
|
||||
case 6:
|
||||
if (!this.getDFMap ("DC", this.line, 4, J.adapter.readers.quantum.GenNBOReader.$DC_LIST, 3)) return false;
|
||||
slater[1] = 4;
|
||||
break;
|
||||
case 7:
|
||||
if (!this.getDFMap ("FS", this.line, 5, J.adapter.readers.quantum.GenNBOReader.$FS_LIST, 3)) return false;
|
||||
slater[1] = 5;
|
||||
break;
|
||||
case 10:
|
||||
if (!this.getDFMap ("FC", this.line, 6, J.adapter.readers.quantum.GenNBOReader.$FC_LIST, 3)) return false;
|
||||
slater[1] = 6;
|
||||
break;
|
||||
}
|
||||
slater[2] = pt + 1;
|
||||
slater[3] = ng;
|
||||
this.shells.addLast (slater);
|
||||
return true;
|
||||
}, "~A,~N,~N,~N");
|
||||
Clazz.defineMethod (c$, "getAlphasAndExponents",
|
||||
function () {
|
||||
for (var j = 0; j < 5; j++) {
|
||||
if (this.line.indexOf ("=") < 0) this.rd ();
|
||||
if (this.line.indexOf ("$END") >= 0) break;
|
||||
this.line = this.line.substring (this.line.indexOf ("=") + 1);
|
||||
var temp = this.fillFloatArray (this.line, 0, Clazz.newFloatArray (this.gaussianCount, 0));
|
||||
for (var i = 0; i < this.gaussianCount; i++) {
|
||||
this.gaussians[i][j] = temp[i];
|
||||
if (j > 1) this.gaussians[i][5] += temp[i];
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < this.gaussianCount; i++) {
|
||||
if (this.gaussians[i][1] == 0) this.gaussians[i][1] = this.gaussians[i][5];
|
||||
}
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (this.shells.size () + " slater shells read");
|
||||
JU.Logger.debug (this.gaussians.length + " gaussian primitives read");
|
||||
}});
|
||||
Clazz.defineMethod (c$, "readData31",
|
||||
function (line1) {
|
||||
if (line1 == null) {
|
||||
line1 = this.rd ();
|
||||
this.rd ();
|
||||
}this.rd ();
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
var ac = this.parseIntStr (tokens[0]);
|
||||
this.shellCount = this.parseIntStr (tokens[1]);
|
||||
this.gaussianCount = this.parseIntStr (tokens[2]);
|
||||
this.rd ();
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetName (this.nboType + "s: " + line1.trim ());
|
||||
this.asc.setCurrentModelInfo ("nboType", this.nboType);
|
||||
for (var i = 0; i < ac; i++) {
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
var z = this.parseIntStr (tokens[0]);
|
||||
if (z < 0) continue;
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.elementNumber = z;
|
||||
this.setAtomCoordTokens (atom, tokens, 1);
|
||||
}
|
||||
this.shells = new JU.Lst ();
|
||||
this.gaussians = JU.AU.newFloat2 (this.gaussianCount);
|
||||
for (var i = 0; i < this.gaussianCount; i++) this.gaussians[i] = Clazz.newFloatArray (6, 0);
|
||||
|
||||
this.rd ();
|
||||
this.nOrbitals = 0;
|
||||
for (var i = 0; i < this.shellCount; i++) {
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
slater[0] = this.parseIntStr (tokens[0]);
|
||||
var n = this.parseIntStr (tokens[1]);
|
||||
var pt = this.parseIntStr (tokens[2]) - 1;
|
||||
var ng = this.parseIntStr (tokens[3]);
|
||||
this.line = this.rd ().trim ();
|
||||
if (!this.fillSlater (slater, n, pt, ng)) return false;
|
||||
}
|
||||
this.rd ();
|
||||
this.getAlphasAndExponents ();
|
||||
return true;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readData46",
|
||||
function () {
|
||||
var map = new java.util.Hashtable ();
|
||||
var tokens = new Array (0);
|
||||
this.rd ();
|
||||
this.nAOs = this.nOrbitals;
|
||||
while (this.line != null && this.line.length > 0) {
|
||||
tokens = JU.PT.getTokens (this.line);
|
||||
var type = tokens[0];
|
||||
this.isOpenShell = (tokens.length == 3);
|
||||
var ab = (this.isOpenShell ? tokens[1] : "");
|
||||
var count = tokens[tokens.length - 1];
|
||||
var key = (ab.equals ("BETA") ? "beta_" : "") + type;
|
||||
if (this.parseIntStr (count) != this.nOrbitals) {
|
||||
JU.Logger.error ("file 46 number of orbitals (" + count + ") does not match nOrbitals: " + this.nOrbitals);
|
||||
return;
|
||||
}var sb = new JU.SB ();
|
||||
while (this.rd () != null && this.line.length > 4 && " NA NB AO NH".indexOf (this.line.substring (1, 4)) < 0) sb.append (this.line);
|
||||
|
||||
sb.appendC (' ');
|
||||
var data = JU.PT.rep (sb.toString (), " )", ")");
|
||||
sb = new JU.SB ();
|
||||
for (var i = 0, n = data.length - 1; i < n; i++) {
|
||||
var c = data.charAt (i);
|
||||
switch (c) {
|
||||
case '(':
|
||||
case '-':
|
||||
if (data.charAt (i + 1) == ' ') i++;
|
||||
break;
|
||||
case ' ':
|
||||
if (JU.PT.isDigit (data.charAt (i + 1)) || data.charAt (i + 1) == '(') continue;
|
||||
break;
|
||||
}
|
||||
sb.appendC (c);
|
||||
}
|
||||
tokens = JU.PT.getTokens (sb.toString ());
|
||||
map.put (key, tokens);
|
||||
}
|
||||
var type = this.nboType;
|
||||
if (type.charAt (0) == 'P') type = type.substring (1);
|
||||
if (type.equals ("NLMO")) type = "NBO";
|
||||
tokens = map.get ((this.betaOnly ? "beta_" : "") + type);
|
||||
this.moData.put ("nboLabelMap", map);
|
||||
if (tokens == null) {
|
||||
tokens = new Array (this.nAOs);
|
||||
for (var i = 0; i < this.nAOs; i++) tokens[i] = this.nboType + (i + 1);
|
||||
|
||||
map.put (this.nboType, tokens);
|
||||
if (this.isOpenShell) map.put ("beta_" + this.nboType, tokens);
|
||||
}this.moData.put ("nboLabels", tokens);
|
||||
var addBetaSet = (this.isOpenShell && !this.betaOnly && !this.is47File);
|
||||
if (addBetaSet) this.nOrbitals *= 2;
|
||||
for (var i = 0; i < this.nOrbitals; i++) this.setMO ( new java.util.Hashtable ());
|
||||
|
||||
var qs = new J.quantum.QS ();
|
||||
qs.setNboLabels (tokens, this.nAOs, this.orbitals, this.nOrbitals0, this.nboType);
|
||||
if (addBetaSet) {
|
||||
this.moData.put ("firstBeta", Integer.$valueOf (this.nAOs));
|
||||
qs.setNboLabels (map.get ("beta_" + type), this.nAOs, this.orbitals, this.nOrbitals0 + this.nAOs, this.nboType);
|
||||
}var structures = this.getStructureList ();
|
||||
J.adapter.readers.quantum.NBOParser.getStructures46 (map.get ("NBO"), "alpha", structures, this.asc.ac);
|
||||
J.adapter.readers.quantum.NBOParser.getStructures46 (map.get ("beta_NBO"), "beta", structures, this.asc.ac);
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"$P_LIST", "101 102 103",
|
||||
"SP_LIST", "1 101 102 103",
|
||||
"$DS_LIST", "255 252 253 254 251",
|
||||
"$DC_LIST", "201 204 206 202 203 205",
|
||||
"$FS_LIST", "351 352 353 354 355 356 357",
|
||||
"$FC_LIST", "301 307 310 304 302 303 306 309 308 305");
|
||||
});
|
||||
@@ -0,0 +1,249 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MOReader"], "J.adapter.readers.quantum.JaguarReader", ["java.lang.Boolean", "$.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "J.adapter.readers.quantum.BasisFunctionReader", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.moCount = 0;
|
||||
this.lumoEnergy = 3.4028235E38;
|
||||
this.haveLine = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "JaguarReader", J.adapter.readers.quantum.MOReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.startsWith (" Input geometry:") || this.line.startsWith (" Symmetrized geometry:") || this.line.startsWith (" final geometry:")) {
|
||||
this.readAtoms ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" Atomic charges from electrostatic potential:")) {
|
||||
this.readCharges ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" number of basis functions....")) {
|
||||
this.moCount = this.parseIntAt (this.line, 32);
|
||||
return true;
|
||||
}if (this.line.startsWith (" basis set:")) {
|
||||
this.moData.put ("energyUnits", "");
|
||||
this.moData.put ("calculationType", this.calculationType = this.line.substring (13).trim ());
|
||||
if ("sto-3g".equals (this.calculationType)) {
|
||||
JU.Logger.error ("STO-3G not supported for Jaguar -- unusual SP basis definition.");
|
||||
}return true;
|
||||
}if (this.line.indexOf ("XXXXXShell information") >= 0) {
|
||||
this.readUnnormalizedBasis ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Normalized coefficients") >= 0) {
|
||||
if (!"sto-3g".equals (this.calculationType)) this.readBasisNormalized ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" LUMO energy:")) {
|
||||
this.lumoEnergy = this.parseFloatStr (this.line.substring (13));
|
||||
return true;
|
||||
}if (this.line.indexOf ("final wvfn") >= 0) {
|
||||
if (this.shells != null) this.readJaguarMolecularOrbitals ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" harmonic frequencies in")) {
|
||||
this.readFrequencies ();
|
||||
this.continuing = false;
|
||||
return false;
|
||||
}return this.checkNboLine ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
this.discardPreviousAtoms ();
|
||||
this.readLines (2);
|
||||
while (this.rd () != null && this.line.length >= 60 && this.line.charAt (2) != ' ') {
|
||||
var tokens = this.getTokens ();
|
||||
var atomName = tokens[0];
|
||||
if (atomName.length < 2) return;
|
||||
var ch2 = atomName.charAt (1);
|
||||
var elementSymbol = (ch2 >= 'a' && ch2 <= 'z' ? atomName.substring (0, 2) : atomName.substring (0, 1));
|
||||
this.addAtomXYZSymName (tokens, 1, elementSymbol, atomName);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCharges",
|
||||
function () {
|
||||
var iAtom = 0;
|
||||
while (this.rd () != null && this.line.indexOf ("sum") < 0) {
|
||||
if (this.line.indexOf ("Charge") < 0) continue;
|
||||
var tokens = this.getTokens ();
|
||||
for (var i = 1; i < tokens.length; i++) this.asc.atoms[iAtom++].partialCharge = this.parseFloatStr (tokens[i]);
|
||||
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readUnnormalizedBasis",
|
||||
function () {
|
||||
var lastAtom = "";
|
||||
var iAtom = 0;
|
||||
var sdata = Clazz.newIntArray (this.moCount, 4, 0);
|
||||
var sgdata = JU.AU.createArrayOfArrayList (this.moCount);
|
||||
var tokens;
|
||||
this.gaussianCount = 0;
|
||||
this.discardLinesUntilContains ("--------");
|
||||
while (this.rd () != null && (tokens = this.getTokens ()).length == 9) {
|
||||
var jCont = this.parseIntStr (tokens[2]);
|
||||
if (jCont > 0) {
|
||||
if (!tokens[0].equals (lastAtom)) iAtom++;
|
||||
lastAtom = tokens[0];
|
||||
var iFunc = this.parseIntStr (tokens[5]);
|
||||
var iType = this.parseIntStr (tokens[4]);
|
||||
if (iType <= 2) iType--;
|
||||
if (sgdata[iFunc] == null) {
|
||||
sdata[iFunc][0] = iAtom;
|
||||
sdata[iFunc][1] = iType;
|
||||
sdata[iFunc][2] = 0;
|
||||
sdata[iFunc][3] = 0;
|
||||
sgdata[iFunc] = new JU.Lst ();
|
||||
}var factor = 1;
|
||||
sgdata[iFunc].addLast ( Clazz.newFloatArray (-1, [this.parseFloatStr (tokens[6]), this.parseFloatStr (tokens[8]) * factor]));
|
||||
this.gaussianCount += jCont;
|
||||
for (var i = jCont - 1; --i >= 0; ) {
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
sgdata[iFunc].addLast ( Clazz.newFloatArray (-1, [this.parseFloatStr (tokens[6]), this.parseFloatStr (tokens[8]) * factor]));
|
||||
}
|
||||
}}
|
||||
var garray = JU.AU.newFloat2 (this.gaussianCount);
|
||||
var sarray = new JU.Lst ();
|
||||
this.gaussianCount = 0;
|
||||
for (var i = 0; i < this.moCount; i++) if (sgdata[i] != null) {
|
||||
var n = sgdata[i].size ();
|
||||
sdata[i][2] = this.gaussianCount;
|
||||
sdata[i][3] = n;
|
||||
for (var j = 0; j < n; j++) {
|
||||
garray[this.gaussianCount++] = sgdata[i].get (j);
|
||||
}
|
||||
sarray.addLast (sdata[i]);
|
||||
}
|
||||
this.moData.put ("shells", sarray);
|
||||
this.moData.put ("gaussians", garray);
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (sarray.size () + " slater shells read");
|
||||
JU.Logger.debug (this.gaussianCount + " gaussian primitives read");
|
||||
}});
|
||||
Clazz.defineMethod (c$, "readBasisNormalized",
|
||||
function () {
|
||||
var lastAtom = "";
|
||||
var iAtom = 0;
|
||||
var id;
|
||||
var iFunc = 0;
|
||||
var iFuncLast = -1;
|
||||
var sarray = new JU.Lst ();
|
||||
var gdata = new JU.Lst ();
|
||||
this.gaussianCount = 0;
|
||||
var sdata = null;
|
||||
this.discardLinesUntilContains ("--------");
|
||||
while (this.rd () != null && this.line.length > 3) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 4) {
|
||||
id = tokens[0];
|
||||
continue;
|
||||
}if (!tokens[0].equals (lastAtom)) iAtom++;
|
||||
lastAtom = tokens[0];
|
||||
id = tokens[2];
|
||||
var iType = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (id);
|
||||
iFunc = this.parseIntStr (tokens[3]) - 1;
|
||||
var gPtr = gdata.size ();
|
||||
if (iFunc == iFuncLast) {
|
||||
sdata[3]++;
|
||||
} else if (iFunc < iFuncLast) {
|
||||
for (var i = gdata.size (); --i >= 0; ) {
|
||||
if (gdata.get (i)[2] == iFunc) {
|
||||
gPtr = i + 1;
|
||||
break;
|
||||
}}
|
||||
for (var i = sarray.size (); --i >= 0; ) {
|
||||
if (sarray.get (i)[4] == iFunc) {
|
||||
sarray.get (i)[3]++;
|
||||
while (++i < sarray.size ()) {
|
||||
sarray.get (i)[2]++;
|
||||
}
|
||||
break;
|
||||
}}
|
||||
} else {
|
||||
sdata = Clazz.newIntArray (-1, [iAtom, iType, this.gaussianCount + 1, 1, iFunc]);
|
||||
sarray.addLast (sdata);
|
||||
iFuncLast = iFunc;
|
||||
}this.gaussianCount++;
|
||||
var z = this.parseFloatStr (tokens[4]);
|
||||
var rCoef = this.parseFloatStr (tokens[5]);
|
||||
if (id.equals ("XX")) rCoef *= 1.7320508;
|
||||
gdata.add (gPtr, Clazz.newFloatArray (-1, [z, rCoef, iFunc]));
|
||||
}
|
||||
var garray = JU.AU.newFloat2 (this.gaussianCount);
|
||||
for (var i = gdata.size (); --i >= 0; ) garray[i] = gdata.get (i);
|
||||
|
||||
this.moData.put ("shells", this.shells = sarray);
|
||||
this.moData.put ("gaussians", garray);
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (sarray.size () + " slater shells read");
|
||||
JU.Logger.debug (this.gaussianCount + " gaussian primitives read");
|
||||
}this.moData.put ("isNormalized", Boolean.TRUE);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readJaguarMolecularOrbitals",
|
||||
function () {
|
||||
var dataBlock = new Array (this.moCount);
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
var nMo = 0;
|
||||
while (this.line != null) {
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
if (this.line == null || this.line.indexOf ("eigenvalues-") < 0) break;
|
||||
var eigenValues = this.getTokens ();
|
||||
var n = eigenValues.length - 1;
|
||||
this.fillDataBlock (dataBlock, 0);
|
||||
var occ = 2;
|
||||
for (var iOrb = 0; iOrb < n; iOrb++) {
|
||||
var coefs = Clazz.newFloatArray (this.moCount, 0);
|
||||
var mo = new java.util.Hashtable ();
|
||||
var energy = this.parseFloatStr (eigenValues[iOrb + 1]);
|
||||
mo.put ("energy", Float.$valueOf (energy));
|
||||
if (Math.abs (energy - this.lumoEnergy) < 0.0001) {
|
||||
this.moData.put ("HOMO", Integer.$valueOf (nMo));
|
||||
this.lumoEnergy = 3.4028235E38;
|
||||
occ = 0;
|
||||
}mo.put ("occupancy", Float.$valueOf (occ));
|
||||
nMo++;
|
||||
for (var i = 0, pt = 0; i < this.moCount; i++) {
|
||||
coefs[pt++] = this.parseFloatStr (dataBlock[i][iOrb + 3]);
|
||||
}
|
||||
mo.put ("coefficients", coefs);
|
||||
this.setMO (mo);
|
||||
}
|
||||
}
|
||||
this.moData.put ("mos", this.orbitals);
|
||||
this.finalizeMOData (this.moData);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
this.discardLinesUntilStartsWith (" frequencies ");
|
||||
while (this.line != null && this.line.startsWith (" frequencies ")) {
|
||||
var iAtom0 = this.asc.ac;
|
||||
var frequencies = this.getTokens ();
|
||||
var frequencyCount = frequencies.length - 1;
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
var symmetries = null;
|
||||
var intensities = null;
|
||||
while (this.line != null && this.line.charAt (2) != ' ') {
|
||||
if (this.line.indexOf ("symmetries") >= 0) symmetries = this.getTokens ();
|
||||
else if (this.line.indexOf ("intensities") >= 0) intensities = this.getTokens ();
|
||||
this.rd ();
|
||||
}
|
||||
for (var i = 0; i < frequencyCount; i++) {
|
||||
ignore[i] = !this.doGetVibration (++this.vibrationNumber);
|
||||
if (ignore[i]) continue;
|
||||
this.asc.cloneFirstAtomSet (0);
|
||||
this.asc.setAtomSetFrequency (null, symmetries == null ? null : symmetries[i + 1], frequencies[i + 1], null);
|
||||
if (intensities != null) this.asc.setAtomSetModelProperty ("IRIntensity", intensities[i + 1] + " km/mol");
|
||||
}
|
||||
this.haveLine = true;
|
||||
this.fillFrequencyData (iAtom0, ac, ac, ignore, false, 0, 0, null, 0);
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "rd",
|
||||
function () {
|
||||
if (!this.haveLine) return Clazz.superCall (this, J.adapter.readers.quantum.JaguarReader, "rd", []);
|
||||
this.haveLine = false;
|
||||
return this.line;
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"ROOT3", 1.73205080756887729);
|
||||
});
|
||||
@@ -0,0 +1,316 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.BasisFunctionReader"], "J.adapter.readers.quantum.MOReader", ["java.lang.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "J.quantum.QS", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.shellCount = 0;
|
||||
this.gaussianCount = 0;
|
||||
this.gaussians = null;
|
||||
this.energyUnits = "";
|
||||
this.moTypes = null;
|
||||
this.getNBOs = false;
|
||||
this.getNBOCharges = false;
|
||||
this.haveNboCharges = false;
|
||||
this.haveNboOrbitals = false;
|
||||
this.orbitalsRead = false;
|
||||
this.lastMoData = null;
|
||||
this.allowNoOrbitals = false;
|
||||
this.HEADER_GAMESS_UK_MO = 3;
|
||||
this.HEADER_GAMESS_OCCUPANCIES = 2;
|
||||
this.HEADER_GAMESS_ORIGINAL = 1;
|
||||
this.HEADER_NONE = 0;
|
||||
this.haveCoeffMap = false;
|
||||
this.iMo0 = 1;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "MOReader", J.adapter.readers.quantum.BasisFunctionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.line = "\nNBOs";
|
||||
this.getNBOs = (this.filter != null && this.filterMO ());
|
||||
this.line = "\nNBOCHARGES";
|
||||
this.getNBOCharges = (this.filter != null && this.filterMO ());
|
||||
this.checkAndRemoveFilterKey ("NBOCHARGES");
|
||||
});
|
||||
Clazz.defineMethod (c$, "checkAndRemoveFilterKey",
|
||||
function (key) {
|
||||
if (!this.checkFilterKey (key)) return false;
|
||||
this.filter = JU.PT.rep (this.filter, key, "");
|
||||
if (this.filter.length < 3) this.filter = null;
|
||||
return true;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "checkNboLine",
|
||||
function () {
|
||||
if (this.getNBOs) {
|
||||
if (this.line.indexOf ("(Occupancy) Bond orbital/ Coefficients/ Hybrids") >= 0) {
|
||||
this.getNboTypes ();
|
||||
return false;
|
||||
}if (this.line.indexOf ("NBOs in the AO basis:") >= 0) {
|
||||
this.readMolecularOrbitals (0);
|
||||
return false;
|
||||
}if (this.line.indexOf (" SECOND ORDER PERTURBATION THEORY ANALYSIS") >= 0) {
|
||||
this.readSecondOrderData ();
|
||||
return false;
|
||||
}}if (this.getNBOCharges && this.line.indexOf ("Summary of Natural Population Analysis:") >= 0) {
|
||||
this.getNboCharges ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getNboCharges",
|
||||
function () {
|
||||
if (this.haveNboCharges) return;
|
||||
this.discardLinesUntilContains ("----");
|
||||
this.discardLinesUntilContains ("----");
|
||||
this.haveNboCharges = true;
|
||||
var ac = this.asc.ac;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = i0; i < ac; ++i) {
|
||||
while (atoms[i].elementNumber == 0) ++i;
|
||||
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
var charge;
|
||||
if (tokens == null || tokens.length < 3 || Float.isNaN (charge = this.parseFloatStr (tokens[2]))) {
|
||||
JU.Logger.info ("Error reading NBO charges: " + this.line);
|
||||
return;
|
||||
}atoms[i].partialCharge = charge;
|
||||
if (this.debugging) JU.Logger.debug ("Atom " + i + " using NBOcharge: " + charge);
|
||||
}
|
||||
JU.Logger.info ("Using NBO charges for Model " + this.asc.atomSetCount);
|
||||
});
|
||||
Clazz.defineMethod (c$, "getNboTypes",
|
||||
function () {
|
||||
this.moTypes = new JU.Lst ();
|
||||
this.iMo0 = (this.orbitals == null ? 0 : this.orbitals.size ()) + 1;
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
var n = 0;
|
||||
var pt = 0;
|
||||
while (this.line != null && (pt = this.line.indexOf (".")) >= 0 && pt < 10) {
|
||||
if (this.parseIntRange (this.line, 0, pt) != n + 1) break;
|
||||
this.moTypes.add (n++, this.line.substring (pt + 1, Math.min (40, this.line.length)).trim ());
|
||||
while (this.rd () != null && this.line.startsWith (" ")) {
|
||||
}
|
||||
}
|
||||
JU.Logger.info (n + " natural bond AO basis functions found");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbitals",
|
||||
function (headerType) {
|
||||
if (this.ignoreMOs) {
|
||||
this.rd ();
|
||||
return;
|
||||
}this.dfCoefMaps = null;
|
||||
if (this.haveNboOrbitals) {
|
||||
this.orbitals = new JU.Lst ();
|
||||
this.alphaBeta = "";
|
||||
}this.haveNboOrbitals = true;
|
||||
this.orbitalsRead = true;
|
||||
var mos = null;
|
||||
var data = null;
|
||||
var dCoeffLabels = "";
|
||||
var fCoeffLabels = "";
|
||||
var pCoeffLabels = "";
|
||||
var ptOffset = -1;
|
||||
var fieldSize = 0;
|
||||
var nThisLine = 0;
|
||||
this.rd ();
|
||||
var moCount = 0;
|
||||
var nBlank = 0;
|
||||
var haveMOs = false;
|
||||
if (this.line.indexOf ("---") >= 0) this.rd ();
|
||||
while (this.rd () != null) {
|
||||
var tokens = this.getTokens ();
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (tokens.length + " --- " + this.line);
|
||||
}if (this.line.indexOf ("end") >= 0) break;
|
||||
if (this.line.indexOf (" ALPHA SET ") >= 0) {
|
||||
this.alphaBeta = "alpha";
|
||||
if (this.rd () == null) break;
|
||||
} else if (this.line.indexOf (" BETA SET ") >= 0) {
|
||||
if (haveMOs) break;
|
||||
this.alphaBeta = "beta";
|
||||
if (this.rd () == null) break;
|
||||
}var str = this.line.toUpperCase ();
|
||||
if (str.length == 0 || str.indexOf ("--") >= 0 || str.indexOf (".....") >= 0 || str.indexOf ("NBO BASIS") >= 0 || str.indexOf ("CI EIGENVECTORS WILL BE LABELED") >= 0 || str.indexOf ("LZ VALUE") >= 0 || str.indexOf (" THIS LOCALIZATION HAD") >= 0) {
|
||||
if (!this.haveCoeffMap) {
|
||||
this.haveCoeffMap = true;
|
||||
var isOK = true;
|
||||
if (pCoeffLabels.length > 0) isOK = this.getDFMap ("P", pCoeffLabels, 1, "(PX) (PY) (PZ)", 4);
|
||||
if (dCoeffLabels.length > 0) {
|
||||
if (dCoeffLabels.indexOf ("X") >= 0) isOK = this.getDFMap ("DC", dCoeffLabels, 4, "DXX DYY DZZ DXY DXZ DYZ", 2);
|
||||
else if (dCoeffLabels.indexOf ("(D6)") >= 0) isOK = this.getDFMap ("DC", dCoeffLabels, 4, "(D1) (D4) (D6) (D2) (D3) (D5)", 4);
|
||||
else isOK = this.getDFMap ("DS", dCoeffLabels, 3, "(D5) (D2) (D3) (D4) (D1)", 4);
|
||||
}if (fCoeffLabels.length > 0) {
|
||||
if (fCoeffLabels.indexOf ("X") >= 0) isOK = this.getDFMap ("FC", fCoeffLabels, 6, "XXX YYY ZZZ XYY XXY XXZ XZZ YZZ YYZ XYZ", 2);
|
||||
else if (fCoeffLabels.indexOf ("(F10)") >= 0) isOK = this.getDFMap ("FC", fCoeffLabels, 6, J.adapter.readers.quantum.MOReader.FC_LIST, 5);
|
||||
else isOK = this.getDFMap ("FS", fCoeffLabels, 5, "(F1) (F2) (F3) (F4) (F5) (F6) (F7)", 4);
|
||||
}if (!isOK) {
|
||||
}}if (str.length == 0) nBlank++;
|
||||
else nBlank = 0;
|
||||
if (nBlank == 2) break;
|
||||
if (str.indexOf ("LZ VALUE") >= 0) this.discardLinesUntilBlank ();
|
||||
for (var iMo = 0; iMo < nThisLine; iMo++) {
|
||||
var coefs = Clazz.newFloatArray (data[iMo].size (), 0);
|
||||
var iCoeff = 0;
|
||||
while (iCoeff < coefs.length) {
|
||||
coefs[iCoeff] = this.parseFloatStr (data[iMo].get (iCoeff));
|
||||
iCoeff++;
|
||||
}
|
||||
haveMOs = true;
|
||||
this.addCoef (mos[iMo], coefs, null, NaN, NaN, moCount++);
|
||||
}
|
||||
nThisLine = 0;
|
||||
if (this.line.length == 0) continue;
|
||||
break;
|
||||
}nBlank = 0;
|
||||
if (nThisLine == 0) {
|
||||
nThisLine = tokens.length;
|
||||
if (tokens[0].equals ("AO")) {
|
||||
nThisLine--;
|
||||
ptOffset = 16;
|
||||
fieldSize = 8;
|
||||
}if (mos == null || nThisLine > mos.length) {
|
||||
mos = JU.AU.createArrayOfHashtable (nThisLine);
|
||||
data = JU.AU.createArrayOfArrayList (nThisLine);
|
||||
}for (var i = 0; i < nThisLine; i++) {
|
||||
mos[i] = new java.util.Hashtable ();
|
||||
data[i] = new JU.Lst ();
|
||||
}
|
||||
this.getMOHeader (headerType, tokens, mos, nThisLine);
|
||||
continue;
|
||||
}var nSkip = tokens.length - nThisLine;
|
||||
var type = tokens[nSkip - 1];
|
||||
var ch;
|
||||
if (type.charAt (0) == '(') {
|
||||
ch = type.charAt (1);
|
||||
if (!this.haveCoeffMap) {
|
||||
switch (ch) {
|
||||
case 'p':
|
||||
pCoeffLabels += " " + type.toUpperCase ();
|
||||
break;
|
||||
case 'd':
|
||||
dCoeffLabels += " " + J.adapter.readers.quantum.BasisFunctionReader.canonicalizeQuantumSubshellTag (type.toUpperCase ());
|
||||
break;
|
||||
case 'f':
|
||||
fCoeffLabels += " " + J.adapter.readers.quantum.BasisFunctionReader.canonicalizeQuantumSubshellTag (type.toUpperCase ());
|
||||
break;
|
||||
case 's':
|
||||
}
|
||||
}} else {
|
||||
var nChar = type.length;
|
||||
ch = (nChar < 4 ? 'S' : nChar == 4 ? 'G' : nChar == 5 ? 'H' : '?');
|
||||
if (!this.haveCoeffMap && nChar == 3) fCoeffLabels += " " + J.adapter.readers.quantum.BasisFunctionReader.canonicalizeQuantumSubshellTag (type.toUpperCase ());
|
||||
else if (!this.haveCoeffMap && nChar == 2) dCoeffLabels += " " + J.adapter.readers.quantum.BasisFunctionReader.canonicalizeQuantumSubshellTag (type.toUpperCase ());
|
||||
}if (J.quantum.QS.isQuantumBasisSupported (ch)) {
|
||||
if (ptOffset < 0) {
|
||||
for (var i = 0; i < nThisLine; i++) data[i].addLast (tokens[i + nSkip]);
|
||||
|
||||
} else {
|
||||
var pt = ptOffset;
|
||||
for (var i = 0; i < nThisLine; i++, pt += fieldSize) data[i].addLast (this.line.substring (pt, pt + fieldSize).trim ());
|
||||
|
||||
}}this.line = "";
|
||||
}
|
||||
this.energyUnits = "a.u.";
|
||||
this.setMOData (!this.alphaBeta.equals ("alpha"));
|
||||
this.haveCoeffMap = false;
|
||||
this.dfCoefMaps = null;
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "addCoef",
|
||||
function (mo, coefs, type, energy, occ, moCount) {
|
||||
mo.put ("coefficients", coefs);
|
||||
if (this.moTypes != null) {
|
||||
type = this.moTypes.get (moCount % this.moTypes.size ());
|
||||
occ = (type.indexOf ("*") >= 0 ? 0 : 2);
|
||||
} else if (this.alphaBeta.length > 0) {
|
||||
type = this.alphaBeta;
|
||||
}if (type != null) mo.put ("type", type);
|
||||
if (!Float.isNaN (energy)) mo.put ("energy", Float.$valueOf (energy));
|
||||
if (!Float.isNaN (occ)) mo.put ("occupancy", Float.$valueOf (occ));
|
||||
this.setMO (mo);
|
||||
}, "java.util.Map,~A,~S,~N,~N,~N");
|
||||
Clazz.defineMethod (c$, "getMOHeader",
|
||||
function (headerType, tokens, mos, nThisLine) {
|
||||
this.rd ();
|
||||
switch (headerType) {
|
||||
default:
|
||||
case 0:
|
||||
return;
|
||||
case 3:
|
||||
for (var i = 0; i < nThisLine; i++) mos[i].put ("energy", Float.$valueOf (JU.PT.fVal (tokens[i])));
|
||||
|
||||
this.readLines (5);
|
||||
return;
|
||||
case 1:
|
||||
tokens = this.getTokens ();
|
||||
if (tokens.length == 0) tokens = JU.PT.getTokens (this.rd ());
|
||||
for (var i = 0; i < nThisLine; i++) {
|
||||
mos[i].put ("energy", Float.$valueOf (JU.PT.fVal (tokens[i])));
|
||||
}
|
||||
this.rd ();
|
||||
break;
|
||||
case 2:
|
||||
var haveSymmetry = (this.line.length > 0 || this.rd () != null);
|
||||
tokens = this.getTokens ();
|
||||
for (var i = 0; i < nThisLine; i++) mos[i].put ("occupancy", Float.$valueOf (tokens[i].charAt (0) == '-' ? 2.0 : this.parseFloatStr (tokens[i])));
|
||||
|
||||
this.rd ();
|
||||
if (!haveSymmetry) return;
|
||||
}
|
||||
if (this.line.length > 0) {
|
||||
tokens = this.getTokens ();
|
||||
for (var i = 0; i < nThisLine; i++) mos[i].put ("symmetry", tokens[i]);
|
||||
|
||||
}}, "~N,~A,~A,~N");
|
||||
Clazz.defineMethod (c$, "addMOData",
|
||||
function (nColumns, data, mos) {
|
||||
for (var i = 0; i < nColumns; i++) {
|
||||
var coefs = Clazz.newFloatArray (data[i].size (), 0);
|
||||
for (var j = coefs.length; --j >= 0; ) coefs[j] = this.parseFloatStr (data[i].get (j));
|
||||
|
||||
mos[i].put ("coefficients", coefs);
|
||||
this.setMO (mos[i]);
|
||||
}
|
||||
}, "~N,~A,~A");
|
||||
Clazz.defineMethod (c$, "setMOData",
|
||||
function (clearOrbitals) {
|
||||
if (this.shells != null && this.gaussians != null && (this.allowNoOrbitals || this.orbitals.size () != 0)) {
|
||||
this.moData.put ("calculationType", this.calculationType);
|
||||
this.moData.put ("energyUnits", this.energyUnits);
|
||||
this.moData.put ("shells", this.shells);
|
||||
this.moData.put ("gaussians", this.gaussians);
|
||||
this.moData.put ("mos", this.orbitals);
|
||||
this.finalizeMOData (this.lastMoData = this.moData);
|
||||
}if (clearOrbitals) {
|
||||
this.clearOrbitals ();
|
||||
}}, "~B");
|
||||
Clazz.defineMethod (c$, "readSecondOrderData",
|
||||
function () {
|
||||
this.readLines (5);
|
||||
if (this.lastMoData == null || this.moTypes == null) return;
|
||||
var ht = new java.util.Hashtable ();
|
||||
for (var i = this.moTypes.size (); --i >= 0; ) ht.put (JU.PT.rep (this.moTypes.get (i).substring (10), " ", ""), Integer.$valueOf (i + this.iMo0));
|
||||
|
||||
var strSecondOrderData = new JU.Lst ();
|
||||
while (this.rd () != null && this.line.indexOf ("NBO") < 0) {
|
||||
if (this.line.length < 5 || this.line.charAt (4) != '.') continue;
|
||||
strSecondOrderData.addLast ( Clazz.newArray (-1, [JU.PT.rep (this.line.substring (5, 27).trim (), " ", ""), JU.PT.rep (this.line.substring (32, 54).trim (), " ", ""), this.line.substring (55, 62).trim (), this.line.substring (71).trim ()]));
|
||||
}
|
||||
var secondOrderData = Clazz.newFloatArray (strSecondOrderData.size (), 4, 0);
|
||||
this.lastMoData.put ("secondOrderData", secondOrderData);
|
||||
this.lastMoData = null;
|
||||
var IMO;
|
||||
for (var i = strSecondOrderData.size (); --i >= 0; ) {
|
||||
var a = strSecondOrderData.get (i);
|
||||
IMO = ht.get (a[0]);
|
||||
if (IMO != null) secondOrderData[i][0] = IMO.intValue ();
|
||||
IMO = ht.get (a[1]);
|
||||
if (IMO != null) secondOrderData[i][1] = IMO.intValue ();
|
||||
secondOrderData[i][2] = this.parseFloatStr (a[2]);
|
||||
secondOrderData[i][3] = this.parseFloatStr (a[3]);
|
||||
}
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"P_LIST", "(PX) (PY) (PZ)",
|
||||
"DS_LIST", "(D5) (D2) (D3) (D4) (D1)",
|
||||
"DC_LIST", "(D1) (D4) (D6) (D2) (D3) (D5)",
|
||||
"FS_LIST", "(F1) (F2) (F3) (F4) (F5) (F6) (F7)",
|
||||
"FC_LIST", "(F1) (F2) (F10) (F4) (F2) (F3) (F6) (F9) (F8) (F5)");
|
||||
});
|
||||
@@ -0,0 +1,372 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MopacSlaterReader", "JU.BS"], "J.adapter.readers.quantum.MoldenReader", ["java.lang.Exception", "$.Float", "java.util.Arrays", "$.Hashtable", "JU.AU", "$.Lst", "$.PT", "J.adapter.readers.quantum.BasisFunctionReader", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.loadGeometries = false;
|
||||
this.loadVibrations = false;
|
||||
this.vibOnly = false;
|
||||
this.optOnly = false;
|
||||
this.doSort = true;
|
||||
this.orbitalType = "";
|
||||
this.modelAtomCount = 0;
|
||||
this.bsAtomOK = null;
|
||||
this.bsBadIndex = null;
|
||||
this.nSPDF = null;
|
||||
this.haveEnergy = true;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "MoldenReader", J.adapter.readers.quantum.MopacSlaterReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.bsAtomOK = new JU.BS ();
|
||||
this.bsBadIndex = new JU.BS ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.vibOnly = this.checkFilterKey ("VIBONLY");
|
||||
this.optOnly = this.checkFilterKey ("OPTONLY");
|
||||
this.doSort = !this.checkFilterKey ("NOSORT");
|
||||
this.loadGeometries = !this.vibOnly && this.desiredVibrationNumber < 0 && !this.checkFilterKey ("NOOPT");
|
||||
this.loadVibrations = !this.optOnly && this.desiredModelNumber < 0 && !this.checkFilterKey ("NOVIB");
|
||||
if (this.checkFilterKey ("ALPHA")) this.filter = "alpha";
|
||||
else if (this.checkFilterKey ("BETA")) this.filter = "beta";
|
||||
else this.filter = this.getFilter ("SYM=");
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (!this.line.contains ("[")) return true;
|
||||
this.line = this.line.toUpperCase ().trim ();
|
||||
if (!this.line.startsWith ("[")) return true;
|
||||
JU.Logger.info (this.line);
|
||||
if (this.line.indexOf ("[ATOMS]") == 0) {
|
||||
this.readAtoms ();
|
||||
this.modelAtomCount = this.asc.atomSetAtomCounts[0];
|
||||
if (this.asc.atomSetCount == 1 && this.moData != null) this.finalizeMOData (this.moData);
|
||||
return false;
|
||||
}if (this.line.indexOf ("[GTO]") == 0) return this.readGaussianBasis ();
|
||||
if (this.line.indexOf ("[STO]") == 0) return this.readSlaterBasis ();
|
||||
if (this.line.indexOf ("[MO]") == 0) return (!this.doReadMolecularOrbitals || this.readMolecularOrbitals ());
|
||||
if (this.line.indexOf ("[FREQ]") == 0) return (!this.loadVibrations || this.readFreqsAndModes ());
|
||||
if (this.line.indexOf ("[GEOCONV]") == 0) return (!this.loadGeometries || this.readGeometryOptimization ());
|
||||
if (this.checkOrbitalType (this.line)) return true;
|
||||
if (this.checkSymmetry ()) return false;
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "checkSymmetry",
|
||||
function () {
|
||||
if (this.line.startsWith ("[SPACEGROUP]")) {
|
||||
this.setSpaceGroupName (this.rd ());
|
||||
this.rd ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("[OPERATORS]")) {
|
||||
while (this.rd () != null && this.line.indexOf ("[") < 0) if (this.line.length > 0) {
|
||||
JU.Logger.info ("adding operator " + this.line);
|
||||
this.setSymmetryOperator (this.line);
|
||||
}
|
||||
return true;
|
||||
}if (this.line.startsWith ("[CELL]")) {
|
||||
this.rd ();
|
||||
JU.Logger.info ("setting cell dimensions " + this.line);
|
||||
this.next[0] = 0;
|
||||
for (var i = 0; i < 6; i++) this.setUnitCellItem (i, this.parseFloat ());
|
||||
|
||||
this.rd ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("[CELLAXES]")) {
|
||||
var f = Clazz.newFloatArray (9, 0);
|
||||
this.fillFloatArray (null, 0, f);
|
||||
this.addExplicitLatticeVector (0, f, 0);
|
||||
this.addExplicitLatticeVector (1, f, 3);
|
||||
this.addExplicitLatticeVector (2, f, 6);
|
||||
return true;
|
||||
}return false;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
if (!this.bsBadIndex.isEmpty ()) try {
|
||||
var ilast = 0;
|
||||
var atoms = this.asc.atoms;
|
||||
var nAtoms = this.asc.ac;
|
||||
this.bsAtomOK.set (nAtoms);
|
||||
var n = this.shells.size ();
|
||||
for (var i = 0; i < n; i++) {
|
||||
var iatom = this.shells.get (i)[0];
|
||||
if (iatom != 2147483647) {
|
||||
ilast = atoms[iatom - 1].elementNumber;
|
||||
continue;
|
||||
}for (var j = this.bsAtomOK.nextClearBit (0); j >= 0; j = this.bsAtomOK.nextClearBit (j + 1)) {
|
||||
if (atoms[j].elementNumber == ilast) {
|
||||
this.shells.get (i)[0] = j + 1;
|
||||
JU.Logger.info ("MoldenReader assigning shells starting with " + i + " for ** to atom " + (j + 1) + " z " + ilast);
|
||||
for (; ++i < n && !this.bsBadIndex.get (i) && this.shells.get (i)[0] == 2147483647; ) this.shells.get (i)[0] = j + 1;
|
||||
|
||||
i--;
|
||||
this.bsAtomOK.set (j);
|
||||
break;
|
||||
}}
|
||||
}
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
JU.Logger.error ("Molden reader could not assign shells -- abandoning MOs");
|
||||
this.asc.setCurrentModelInfo ("moData", null);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
var coordUnit = JU.PT.getTokens (this.line.$replace (']', ' '))[1];
|
||||
var isFractional = (coordUnit.indexOf ("FRACTIONAL") >= 0);
|
||||
var isAU = (!isFractional && coordUnit.indexOf ("ANGS") < 0);
|
||||
if (isAU && coordUnit.indexOf ("AU") < 0) JU.Logger.error ("Molden atom line does not indicate units ANGS, AU, or FRACTIONAL -- AU assumed: " + this.line);
|
||||
this.setFractionalCoordinates (isFractional);
|
||||
var f = (isAU ? 0.5291772 : 1);
|
||||
while (this.rd () != null && this.line.indexOf ('[') < 0) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length < 6) continue;
|
||||
var atom = this.setAtomCoordScaled (null, tokens, 3, f);
|
||||
atom.atomName = tokens[0];
|
||||
atom.elementNumber = this.parseIntStr (tokens[2]);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSlaterBasis",
|
||||
function () {
|
||||
this.nCoef = 0;
|
||||
while (this.rd () != null && this.line.indexOf ("[") < 0) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length < 7) continue;
|
||||
this.addSlater (this.parseIntStr (tokens[0]), this.parseIntStr (tokens[1]), this.parseIntStr (tokens[2]), this.parseIntStr (tokens[3]), this.parseIntStr (tokens[4]), this.parseFloatStr (tokens[5]), this.parseFloatStr (tokens[6]));
|
||||
this.nCoef++;
|
||||
}
|
||||
this.setSlaters (false, false);
|
||||
return false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readGaussianBasis",
|
||||
function () {
|
||||
this.shells = new JU.Lst ();
|
||||
var gdata = new JU.Lst ();
|
||||
var atomIndex = 0;
|
||||
var gaussianPtr = 0;
|
||||
this.nCoef = 0;
|
||||
this.nSPDF = Clazz.newIntArray (12, 0);
|
||||
this.discardLinesUntilNonBlank ();
|
||||
while (this.line != null && !((this.line = this.line.trim ()).length == 0 || this.line.charAt (0) == '[')) {
|
||||
var tokens = this.getTokens ();
|
||||
atomIndex = this.parseIntStr (tokens[0]) - 1;
|
||||
if (atomIndex == 2147483647) {
|
||||
this.bsBadIndex.set (this.shells.size ());
|
||||
} else {
|
||||
this.bsAtomOK.set (atomIndex);
|
||||
}while (this.rd () != null && (this.line = this.line.trim ()).length > 0 && this.line.charAt (0) != '[') {
|
||||
tokens = this.getTokens ();
|
||||
var shellLabel = tokens[0].toUpperCase ();
|
||||
var type = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (shellLabel);
|
||||
var nPrimitives = this.parseIntStr (tokens[1]);
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
this.nSPDF[type]++;
|
||||
slater[0] = atomIndex + 1;
|
||||
slater[1] = type;
|
||||
slater[2] = gaussianPtr + 1;
|
||||
slater[3] = nPrimitives;
|
||||
var n = this.getDfCoefMaps ()[type].length;
|
||||
this.nCoef += n;
|
||||
for (var ip = nPrimitives; --ip >= 0; ) {
|
||||
var primTokens = JU.PT.getTokens (this.rd ());
|
||||
var nTokens = primTokens.length;
|
||||
var orbData = Clazz.newFloatArray (nTokens, 0);
|
||||
for (var d = 0; d < nTokens; d++) orbData[d] = this.parseFloatStr (primTokens[d]);
|
||||
|
||||
gdata.addLast (orbData);
|
||||
gaussianPtr++;
|
||||
}
|
||||
this.shells.addLast (slater);
|
||||
}
|
||||
if (this.line.length > 0 && this.line.charAt (0) == '[') break;
|
||||
this.rd ();
|
||||
}
|
||||
var garray = JU.AU.newFloat2 (gaussianPtr);
|
||||
for (var i = 0; i < gaussianPtr; i++) {
|
||||
garray[i] = gdata.get (i);
|
||||
}
|
||||
this.moData.put ("shells", this.shells);
|
||||
this.moData.put ("gaussians", garray);
|
||||
JU.Logger.info (this.shells.size () + " slater shells read");
|
||||
JU.Logger.info (garray.length + " gaussian primitives read");
|
||||
JU.Logger.info (this.nCoef + " MO coefficients expected for orbital type " + this.orbitalType);
|
||||
this.asc.setCurrentModelInfo ("moData", this.moData);
|
||||
return false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbitals",
|
||||
function () {
|
||||
while (this.checkOrbitalType (this.rd ())) {
|
||||
}
|
||||
this.fixOrbitalType ();
|
||||
var tokens = this.getMoTokens (this.line);
|
||||
while (tokens != null && tokens.length > 0 && tokens[0].indexOf ('[') < 0) {
|
||||
var mo = new java.util.Hashtable ();
|
||||
var data = new JU.Lst ();
|
||||
var energy = NaN;
|
||||
var occupancy = NaN;
|
||||
var symmetry = null;
|
||||
var key;
|
||||
while (this.parseIntStr (key = tokens[0]) == -2147483648) {
|
||||
if (key.startsWith ("Ene")) {
|
||||
energy = this.parseFloatStr (tokens[1]);
|
||||
} else if (key.startsWith ("Occup")) {
|
||||
occupancy = this.parseFloatStr (tokens[1]);
|
||||
} else if (key.startsWith ("Sym")) {
|
||||
symmetry = tokens[1];
|
||||
} else if (key.startsWith ("Spin")) {
|
||||
this.alphaBeta = tokens[1].toLowerCase ();
|
||||
}tokens = this.getMoTokens (null);
|
||||
}
|
||||
var pt = 0;
|
||||
while (tokens != null && tokens.length > 0 && this.parseIntStr (tokens[0]) != -2147483648) {
|
||||
if (tokens.length != 2) throw new Exception ("invalid MO coefficient specification");
|
||||
var i = this.parseIntStr (tokens[0]);
|
||||
while (i > ++pt) data.addLast ("0");
|
||||
|
||||
data.addLast (tokens[1]);
|
||||
tokens = this.getMoTokens (null);
|
||||
}
|
||||
if (this.orbitalType.equals ("") && data.size () < this.nCoef) {
|
||||
JU.Logger.info ("too few orbital coefficients for 6D");
|
||||
this.checkOrbitalType ("[5D]");
|
||||
}while (++pt <= this.nCoef) {
|
||||
data.addLast ("0");
|
||||
}
|
||||
var coefs = Clazz.newFloatArray (this.nCoef, 0);
|
||||
for (var i = data.size (); --i >= 0; ) coefs[i] = this.parseFloatStr (data.get (i));
|
||||
|
||||
var l = this.line;
|
||||
this.line = "" + symmetry;
|
||||
if (this.filterMO ()) {
|
||||
mo.put ("coefficients", coefs);
|
||||
if (Float.isNaN (energy)) {
|
||||
this.haveEnergy = false;
|
||||
} else {
|
||||
mo.put ("energy", Float.$valueOf (energy));
|
||||
}if (!Float.isNaN (occupancy)) mo.put ("occupancy", Float.$valueOf (occupancy));
|
||||
if (symmetry != null) mo.put ("symmetry", symmetry);
|
||||
if (this.alphaBeta.length > 0) mo.put ("type", this.alphaBeta);
|
||||
this.setMO (mo);
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (coefs.length + " coefficients in MO " + this.orbitals.size ());
|
||||
}}this.line = l;
|
||||
}
|
||||
if (this.debugging) JU.Logger.debug ("read " + this.orbitals.size () + " MOs");
|
||||
this.setMOs ("eV");
|
||||
if (this.haveEnergy && this.doSort) this.sortMOs ();
|
||||
return false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "sortMOs",
|
||||
function () {
|
||||
var list = this.orbitals.toArray ( new Array (this.orbitals.size ()));
|
||||
java.util.Arrays.sort (list, Clazz.innerTypeInstance (J.adapter.readers.quantum.BasisFunctionReader.MOEnergySorter, this, null));
|
||||
this.orbitals.clear ();
|
||||
for (var i = 0; i < list.length; i++) this.orbitals.addLast (list[i]);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "getMoTokens",
|
||||
function (line) {
|
||||
return (line == null && (line = this.rd ()) == null ? null : JU.PT.getTokens (line.$replace ('=', ' ')));
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "checkOrbitalType",
|
||||
function (line) {
|
||||
if (line.length > 3 && "5D 6D 7F 10 9G 15 11 21".indexOf (line.substring (1, 3)) >= 0) {
|
||||
if (this.orbitalType.indexOf (line) >= 0) return true;
|
||||
if (line.indexOf ("G") >= 0 || line.indexOf ("H") >= 0 || line.indexOf ("I") >= 0) this.appendLoadNote ("Unsupported orbital type ignored: " + line);
|
||||
this.orbitalType += line;
|
||||
JU.Logger.info ("Orbital type set to " + this.orbitalType);
|
||||
this.fixOrbitalType ();
|
||||
return true;
|
||||
}return false;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "fixOrbitalType",
|
||||
function () {
|
||||
if (this.orbitalType.contains ("5D")) {
|
||||
this.fixSlaterTypes (4, 3);
|
||||
this.fixSlaterTypes (6, 5);
|
||||
this.fixSlaterTypes (8, 7);
|
||||
this.fixSlaterTypes (10, 9);
|
||||
}if (this.orbitalType.contains ("10F")) {
|
||||
this.fixSlaterTypes (5, 6);
|
||||
this.fixSlaterTypes (7, 8);
|
||||
this.fixSlaterTypes (9, 10);
|
||||
}if (this.orbitalType.contains ("15G")) {
|
||||
this.fixSlaterTypes (7, 8);
|
||||
this.fixSlaterTypes (9, 10);
|
||||
}});
|
||||
Clazz.defineMethod (c$, "readFreqsAndModes",
|
||||
function () {
|
||||
var tokens;
|
||||
var frequencies = new JU.Lst ();
|
||||
while (this.rd () != null && this.line.indexOf ('[') < 0) {
|
||||
var f = this.getTokens ()[0];
|
||||
frequencies.addLast (f);
|
||||
}
|
||||
var nFreqs = frequencies.size ();
|
||||
this.skipTo ("[FR-COORD]");
|
||||
if (!this.vibOnly) this.readAtomSet ("frequency base geometry", true, true);
|
||||
this.skipTo ("[FR-NORM-COORD]");
|
||||
var haveVib = false;
|
||||
for (var nFreq = 0; nFreq < nFreqs; nFreq++) {
|
||||
this.skipTo ("vibration");
|
||||
this.doGetVibration (++this.vibrationNumber);
|
||||
if (haveVib) this.asc.cloneLastAtomSet ();
|
||||
haveVib = true;
|
||||
this.asc.setAtomSetFrequency (null, null, "" + JU.PT.dVal (frequencies.get (nFreq)), null);
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
for (var i = 0; i < this.modelAtomCount; i++) {
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
this.asc.addVibrationVector (i + i0, this.parseFloatStr (tokens[0]) * 0.5291772, this.parseFloatStr (tokens[1]) * 0.5291772, this.parseFloatStr (tokens[2]) * 0.5291772);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readGeometryOptimization",
|
||||
function () {
|
||||
var energies = new JU.Lst ();
|
||||
this.rd ();
|
||||
while (this.rd () != null && this.line.indexOf ("force") < 0) energies.addLast ("" + JU.PT.dVal (this.line.trim ()));
|
||||
|
||||
this.skipTo ("[GEOMETRIES] XYZ");
|
||||
var nGeom = energies.size ();
|
||||
var firstModel = (this.optOnly || this.desiredModelNumber >= 0 ? 0 : 1);
|
||||
this.modelNumber = firstModel;
|
||||
var haveModel = false;
|
||||
if (this.desiredModelNumber == 0 || this.desiredModelNumber == nGeom) this.desiredModelNumber = nGeom;
|
||||
else if (this.asc.atomSetCount > 0) this.finalizeMOData (this.moData);
|
||||
for (var i = 0; i < nGeom; i++) {
|
||||
this.readLines (2);
|
||||
if (this.doGetModel (++this.modelNumber, null)) {
|
||||
this.readAtomSet ("Step " + (this.modelNumber - firstModel) + "/" + nGeom + ": " + energies.get (i), false, !this.optOnly || haveModel);
|
||||
haveModel = true;
|
||||
} else {
|
||||
this.readLines (this.modelAtomCount);
|
||||
}}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "skipTo",
|
||||
function (key) {
|
||||
key = key.toUpperCase ();
|
||||
if (this.line == null || !this.line.toUpperCase ().contains (key)) while (this.rd () != null && this.line.toUpperCase ().indexOf (key) < 0) {
|
||||
}
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readAtomSet",
|
||||
function (atomSetName, isBohr, asClone) {
|
||||
if (asClone && this.desiredModelNumber < 0) this.asc.cloneFirstAtomSet (0);
|
||||
var f = (isBohr ? 0.5291772 : 1);
|
||||
this.asc.setAtomSetName (atomSetName);
|
||||
if (this.asc.ac == 0) {
|
||||
while (this.rd () != null && this.line.indexOf ('[') < 0) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 4) this.setAtomCoordScaled (null, tokens, 1, f).atomName = tokens[0];
|
||||
}
|
||||
this.modelAtomCount = this.asc.getLastAtomSetAtomCount ();
|
||||
return;
|
||||
}var atoms = this.asc.atoms;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
for (var i = 0; i < this.modelAtomCount; i++) this.setAtomCoordScaled (atoms[i + i0], JU.PT.getTokens (this.rd ()), 1, f);
|
||||
|
||||
}, "~S,~B,~B");
|
||||
});
|
||||
@@ -0,0 +1,135 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MopacSlaterReader"], "J.adapter.readers.quantum.MopacGraphfReader", ["java.lang.Float", "java.util.Hashtable", "JU.AU", "$.Lst"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.ac = 0;
|
||||
this.nCoefficients = 0;
|
||||
this.invMatrix = null;
|
||||
this.isNewFormat = false;
|
||||
this.orbitalData = null;
|
||||
this.orbitalInfo = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "MopacGraphfReader", J.adapter.readers.quantum.MopacSlaterReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.alphaBeta = "alpha";
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
this.readAtoms ();
|
||||
if (this.doReadMolecularOrbitals) {
|
||||
this.readSlaterBasis ();
|
||||
this.readMolecularOrbitals (false);
|
||||
if (this.readKeywords ()) this.readMolecularOrbitals (true);
|
||||
}this.continuing = false;
|
||||
return false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
this.ac = this.parseIntStr (this.line);
|
||||
this.atomicNumbers = Clazz.newIntArray (this.ac, 0);
|
||||
for (var i = 0; i < this.ac; i++) {
|
||||
this.rd ();
|
||||
this.atomicNumbers[i] = this.parseIntRange (this.line, 0, 4);
|
||||
var atom = this.asc.addNewAtom ();
|
||||
this.setAtomCoordXYZ (atom, this.parseFloatRange (this.line, 4, 17), this.parseFloatRange (this.line, 17, 29), this.parseFloatRange (this.line, 29, 41));
|
||||
if (this.line.length > 41) atom.partialCharge = this.parseFloatStr (this.line.substring (41));
|
||||
atom.elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (this.atomicNumbers[i]);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSlaterBasis",
|
||||
function () {
|
||||
this.nCoefficients = 0;
|
||||
var values = Clazz.newFloatArray (3, 0);
|
||||
for (var iAtom = 0; iAtom < this.ac; iAtom++) {
|
||||
J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (this.rd (), values, 3);
|
||||
var atomicNumber = this.atomicNumbers[iAtom];
|
||||
var zeta;
|
||||
if ((zeta = values[0]) != 0) {
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "S", zeta, 1);
|
||||
}if ((zeta = values[1]) != 0) {
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "Px", zeta, 1);
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "Py", zeta, 1);
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "Pz", zeta, 1);
|
||||
}if ((zeta = values[2]) != 0) {
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "Dx2-y2", zeta, 1);
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "Dxz", zeta, 1);
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "Dz2", zeta, 1);
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "Dyz", zeta, 1);
|
||||
this.createSphericalSlaterByType (iAtom, atomicNumber, "Dxy", zeta, 1);
|
||||
}}
|
||||
this.nCoefficients = this.slaters.size ();
|
||||
this.setSlaters (true, false);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbitals",
|
||||
function (isBeta) {
|
||||
if (isBeta) this.alphaBeta = "beta";
|
||||
var list = null;
|
||||
if (this.rd () == null) return;
|
||||
this.isNewFormat = (this.line.indexOf ("ORBITAL") >= 0);
|
||||
if (this.isNewFormat) {
|
||||
this.orbitalData = new JU.Lst ();
|
||||
if (this.line.length > 10) this.orbitalInfo = new JU.Lst ();
|
||||
} else {
|
||||
list = Clazz.newFloatArray (this.nCoefficients, this.nCoefficients, 0);
|
||||
}for (var iMo = 0; iMo < this.nCoefficients; iMo++) {
|
||||
if (iMo != 0) this.rd ();
|
||||
var data;
|
||||
if (this.isNewFormat) {
|
||||
if (this.line == null || this.line.indexOf ("ORBITAL") < 0 || this.line.indexOf ("ORBITAL_LIST") >= 0) break;
|
||||
this.orbitalData.addLast (data = Clazz.newFloatArray (this.nCoefficients, 0));
|
||||
if (this.orbitalInfo != null) this.orbitalInfo.addLast (this.line);
|
||||
this.rd ();
|
||||
} else {
|
||||
data = list[iMo];
|
||||
}this.fillFloatArray (this.line, 15, data);
|
||||
}
|
||||
if (this.invMatrix == null) {
|
||||
if (this.isNewFormat && this.line.indexOf ("MATRIX") < 0) this.rd ();
|
||||
this.invMatrix = JU.AU.newFloat2 (this.nCoefficients);
|
||||
for (var iMo = 0; iMo < this.nCoefficients; iMo++) this.fillFloatArray (null, 15, this.invMatrix[iMo] = Clazz.newFloatArray (iMo + 1, 0));
|
||||
|
||||
}this.nOrbitals = (this.orbitalData == null ? this.nCoefficients : this.orbitalData.size ());
|
||||
if (this.orbitalData != null) {
|
||||
list = JU.AU.newFloat2 (this.nOrbitals);
|
||||
for (var i = this.nOrbitals; --i >= 0; ) list[i] = this.orbitalData.get (i);
|
||||
|
||||
}var list2 = Clazz.newFloatArray (this.nOrbitals, this.nCoefficients, 0);
|
||||
for (var i = 0; i < this.nOrbitals; i++) for (var j = 0; j < this.nCoefficients; j++) {
|
||||
for (var k = 0; k < this.nCoefficients; k++) list2[i][j] += (list[i][k] * (k >= j ? this.invMatrix[k][j] : this.invMatrix[j][k]));
|
||||
|
||||
if (Math.abs (list2[i][j]) < 1.0E-4) list2[i][j] = 0;
|
||||
}
|
||||
|
||||
if (this.isNewFormat && this.orbitalInfo == null && this.line != null && this.line.indexOf ("ORBITAL_LIST") < 0) this.rd ();
|
||||
var values = Clazz.newFloatArray (2, 0);
|
||||
for (var iMo = 0; iMo < this.nOrbitals; iMo++) {
|
||||
var mo = new java.util.Hashtable ();
|
||||
if (this.orbitalInfo != null) {
|
||||
this.line = this.orbitalInfo.get (iMo);
|
||||
var tokens = this.getTokens ();
|
||||
mo.put ("energy", Float.$valueOf (this.parseFloatStr (tokens[3])));
|
||||
mo.put ("occupancy", Float.$valueOf (this.parseFloatStr (tokens[1])));
|
||||
} else if (this.rd () != null) {
|
||||
J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (this.line, values, 2);
|
||||
mo.put ("energy", Float.$valueOf (values[0]));
|
||||
mo.put ("occupancy", Float.$valueOf (values[1]));
|
||||
}mo.put ("coefficients", list2[iMo]);
|
||||
if (isBeta) mo.put ("type", "beta");
|
||||
this.line = "\n";
|
||||
if (this.filterMO ()) this.setMO (mo);
|
||||
}
|
||||
this.setMOs ("eV");
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "readKeywords",
|
||||
function () {
|
||||
if (this.rd () == null || this.line.indexOf (" Keywords:") < 0) return false;
|
||||
this.moData.put ("calculationType", this.calculationType = this.line.substring (11).trim ());
|
||||
var isUHF = (this.line.indexOf ("UHF") >= 0);
|
||||
if (isUHF) {
|
||||
for (var i = this.orbitals.size (); --i >= 0; ) {
|
||||
this.orbitals.get (i).put ("type", "alpha");
|
||||
}
|
||||
}return isUHF;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,69 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.SlaterReader"], "J.adapter.readers.quantum.MopacSlaterReader", null, function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.atomicNumbers = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "MopacSlaterReader", J.adapter.readers.quantum.SlaterReader);
|
||||
Clazz.defineMethod (c$, "createSphericalSlaterByType",
|
||||
function (iAtom, atomicNumber, type, zeta, coef) {
|
||||
var pt = "S Px Py Pz Dx2-y2Dxz Dz2 Dyz Dxy".indexOf (type);
|
||||
switch (pt) {
|
||||
case 0:
|
||||
this.addSlater (iAtom + 1, 0, 0, 0, J.adapter.readers.quantum.MopacSlaterReader.getNPQs (atomicNumber) - 1, zeta, coef);
|
||||
return;
|
||||
case 2:
|
||||
case 5:
|
||||
case 8:
|
||||
this.addSlater (iAtom + 1, pt == 2 ? 1 : 0, pt == 5 ? 1 : 0, pt == 8 ? 1 : 0, J.adapter.readers.quantum.MopacSlaterReader.getNPQp (atomicNumber) - 2, zeta, coef);
|
||||
return;
|
||||
}
|
||||
pt = (pt >> 2) * 3 - 9;
|
||||
this.addSlater (iAtom + 1, J.adapter.readers.quantum.MopacSlaterReader.sphericalDValues[pt++], J.adapter.readers.quantum.MopacSlaterReader.sphericalDValues[pt++], J.adapter.readers.quantum.MopacSlaterReader.sphericalDValues[pt++], J.adapter.readers.quantum.MopacSlaterReader.getNPQd (atomicNumber) - 3, zeta, coef);
|
||||
}, "~N,~N,~S,~N,~N");
|
||||
Clazz.defineMethod (c$, "scaleSlater",
|
||||
function (ex, ey, ez, er, zeta) {
|
||||
if (ex >= 0 && ey >= 0) {
|
||||
return Clazz.superCall (this, J.adapter.readers.quantum.MopacSlaterReader, "scaleSlater", [ex, ey, ez, er, zeta]);
|
||||
}var el = Math.abs (ex + ey + ez);
|
||||
if (el == 3) {
|
||||
return 0;
|
||||
}return J.adapter.readers.quantum.SlaterReader.getSlaterConstDSpherical (el + er + 1, Math.abs (zeta), ex, ey);
|
||||
}, "~N,~N,~N,~N,~N");
|
||||
c$.getNPQ = Clazz.defineMethod (c$, "getNPQ",
|
||||
function (atomicNumber) {
|
||||
return (atomicNumber < J.adapter.readers.quantum.MopacSlaterReader.principalQuantumNumber.length ? J.adapter.readers.quantum.MopacSlaterReader.principalQuantumNumber[atomicNumber] : 0);
|
||||
}, "~N");
|
||||
c$.getNPQs = Clazz.defineMethod (c$, "getNPQs",
|
||||
function (atomicNumber) {
|
||||
var n = J.adapter.readers.quantum.MopacSlaterReader.getNPQ (atomicNumber);
|
||||
switch (atomicNumber) {
|
||||
case 10:
|
||||
case 18:
|
||||
case 36:
|
||||
case 54:
|
||||
case 86:
|
||||
return n + 1;
|
||||
default:
|
||||
return n;
|
||||
}
|
||||
}, "~N");
|
||||
c$.getNPQp = Clazz.defineMethod (c$, "getNPQp",
|
||||
function (atomicNumber) {
|
||||
var n = J.adapter.readers.quantum.MopacSlaterReader.getNPQ (atomicNumber);
|
||||
switch (atomicNumber) {
|
||||
case 2:
|
||||
return n + 1;
|
||||
default:
|
||||
return n;
|
||||
}
|
||||
}, "~N");
|
||||
c$.getNPQd = Clazz.defineMethod (c$, "getNPQd",
|
||||
function (atomicNumber) {
|
||||
return (atomicNumber < J.adapter.readers.quantum.MopacSlaterReader.npqd.length ? J.adapter.readers.quantum.MopacSlaterReader.npqd[atomicNumber] : 0);
|
||||
}, "~N");
|
||||
Clazz.defineStatics (c$,
|
||||
"MIN_COEF", 0.0001,
|
||||
"sphericalDValues", Clazz.newIntArray (-1, [0, -2, 0, 1, 0, 1, -2, 0, 0, 0, 1, 1, 1, 1, 0]),
|
||||
"principalQuantumNumber", Clazz.newIntArray (-1, [0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]),
|
||||
"npqd", Clazz.newIntArray (-1, [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7]));
|
||||
});
|
||||
@@ -0,0 +1,392 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (null, "J.adapter.readers.quantum.NBOParser", ["java.util.Hashtable", "JU.Lst", "$.PT"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.vwr = null;
|
||||
this.haveBeta = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "NBOParser");
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
});
|
||||
Clazz.defineMethod (c$, "set",
|
||||
function (vwr) {
|
||||
this.vwr = vwr;
|
||||
return this;
|
||||
}, "JV.Viewer");
|
||||
Clazz.defineMethod (c$, "getAllStructures",
|
||||
function (output, list) {
|
||||
if (output == null) return null;
|
||||
if (list == null) list = new JU.Lst ();
|
||||
output = JU.PT.rep (output, "the $CHOOSE", "");
|
||||
this.getStructures (this.getBlock (output, "$CHOOSE"), "CHOOSE", list);
|
||||
this.getStructures (this.getBlock (output, "$NRTSTR"), "NRTSTR", list);
|
||||
this.getStructures (this.getBlock (output, "$NRTSTRA"), "NRTSTRA", list);
|
||||
this.getStructures (this.getBlock (output, "$NRTSTRB"), "NRTSTRB", list);
|
||||
this.getStructuresTOPO (this.getData (output, "TOPO matrix", "* Total *", 1), "RSA", list);
|
||||
this.getStructuresTOPO (this.getData (output, "TOPO matrix", "* Total *", 2), "RSB", list);
|
||||
return list;
|
||||
}, "~S,JU.Lst");
|
||||
Clazz.defineMethod (c$, "getBlock",
|
||||
function (output, key) {
|
||||
var pt = output.indexOf (key);
|
||||
var pt1 = output.indexOf ("$END", pt + 1);
|
||||
return (pt < 0 || pt1 < 0 ? null : output.substring (pt + key.length, pt1));
|
||||
}, "~S,~S");
|
||||
c$.getStructures46 = Clazz.defineMethod (c$, "getStructures46",
|
||||
function (tokens, type, structures, nAtoms) {
|
||||
if (tokens == null) return;
|
||||
var htData = new java.util.Hashtable ();
|
||||
structures.addLast (htData);
|
||||
var matrix = Clazz.newIntArray (nAtoms, nAtoms, 0);
|
||||
htData.put ("matrix", matrix);
|
||||
htData.put ("type", type);
|
||||
htData.put ("spin", type);
|
||||
htData.put ("index", Integer.$valueOf (0));
|
||||
for (var n = tokens.length, i = 0; i < n; i++) {
|
||||
var org = tokens[i];
|
||||
if (org.contains ("(ry)")) break;
|
||||
if (org.contains ("*") || org.contains ("(cr)")) continue;
|
||||
var isLP = org.endsWith ("(lp)");
|
||||
if (isLP || org.endsWith ("(lv)")) {
|
||||
var ia = J.adapter.readers.quantum.NBOParser.getAtomIndex (org.substring (0, org.length - 4));
|
||||
matrix[ia][ia] += (isLP ? 1 : 10);
|
||||
continue;
|
||||
}var names = JU.PT.split (org, "-");
|
||||
if (names.length == 3) {
|
||||
System.out.println ("NBOParser 3-center bonnd " + org + " ignored for Kekule structure");
|
||||
continue;
|
||||
}var ia = J.adapter.readers.quantum.NBOParser.getAtomIndex (names[0]);
|
||||
var ib = J.adapter.readers.quantum.NBOParser.getAtomIndex (names[1]);
|
||||
matrix[ia][ib]++;
|
||||
}
|
||||
J.adapter.readers.quantum.NBOParser.dumpMatrix (type, 0, matrix);
|
||||
}, "~A,~S,JU.Lst,~N");
|
||||
c$.getAtomIndex = Clazz.defineMethod (c$, "getAtomIndex",
|
||||
function (xx99) {
|
||||
for (var n = xx99.length, i = n, val = 0, pow = 1, ch = 0; --i >= 0; ) {
|
||||
if ((ch = xx99.charCodeAt (i)) < 48 || ch > 57) return val - 1;
|
||||
val += (ch - 48) * pow;
|
||||
pow *= 10;
|
||||
}
|
||||
return 0;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getStructuresTOPO",
|
||||
function (data, nrtType, list) {
|
||||
if (data == null || data.length == 0) return;
|
||||
var parts = JU.PT.split (data, "Resonance");
|
||||
if (parts.length < 2) return;
|
||||
var pt = parts[0].lastIndexOf (".");
|
||||
var nAtoms = JU.PT.parseInt (parts[0].substring (pt - 3, pt));
|
||||
if (nAtoms < 0) return;
|
||||
var tokens = JU.PT.getTokens (JU.PT.rep (JU.PT.rep (parts[0], ".", ".1"), "Atom", "-1"));
|
||||
var raw = Clazz.newFloatArray (tokens.length, 0);
|
||||
var n = JU.PT.parseFloatArrayInfested (tokens, raw);
|
||||
var table = Clazz.newIntArray (nAtoms, nAtoms, 0);
|
||||
var atom1 = -1;
|
||||
var atom2 = 0;
|
||||
var atom0 = 0;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var f = raw[i];
|
||||
if (f < 0) {
|
||||
atom1 = -1;
|
||||
continue;
|
||||
}if (f % 1 == 0) {
|
||||
if (atom1 == -1) {
|
||||
atom0 = Clazz.floatToInt (f);
|
||||
atom1 = -2;
|
||||
}if (atom1 < 0) continue;
|
||||
table[atom1][atom2++] = Clazz.floatToInt (f);
|
||||
} else {
|
||||
atom1 = Clazz.floatToInt (f - 1);
|
||||
atom2 = atom0 - 1;
|
||||
}}
|
||||
var matrix = null;
|
||||
tokens = parts[1].$plit ("\n");
|
||||
var s = "";
|
||||
for (var i = 3; i < tokens.length; i++) if (tokens[i].indexOf ("--") < 0) s += tokens[i].substring (10) + "\n";
|
||||
|
||||
s = s.$replace ('-', ' ');
|
||||
s = JU.PT.rep (s, ".", ".1");
|
||||
s = JU.PT.rep (s, "(", " -1 ");
|
||||
s = JU.PT.rep (s, ")", " -2 ");
|
||||
s = JU.PT.rep (s, ",", " -3 ");
|
||||
tokens = JU.PT.getTokens (s);
|
||||
raw = Clazz.newFloatArray (tokens.length, 0);
|
||||
n = JU.PT.parseFloatArrayInfested (tokens, raw);
|
||||
var htData = null;
|
||||
var dir = 1;
|
||||
atom1 = atom2 = -1;
|
||||
for (var i = 0, index = 0; i < n; i++) {
|
||||
var f = raw[i];
|
||||
var remain = f % 1;
|
||||
if (remain == 0) {
|
||||
var v = Clazz.floatToInt (f);
|
||||
switch (v) {
|
||||
case -1:
|
||||
dir = -1;
|
||||
atom1 = atom2 = -1;
|
||||
continue;
|
||||
case -2:
|
||||
break;
|
||||
case -3:
|
||||
if (atom1 < 0) continue;
|
||||
break;
|
||||
default:
|
||||
if (atom1 < 0) {
|
||||
atom1 = atom2 = v - 1;
|
||||
} else {
|
||||
atom2 = v - 1;
|
||||
}continue;
|
||||
}
|
||||
matrix[atom1][atom2] += dir;
|
||||
atom1 = atom2 = -1;
|
||||
dir = 1;
|
||||
} else {
|
||||
if (htData == null) matrix = table;
|
||||
J.adapter.readers.quantum.NBOParser.dumpMatrix (nrtType, index, matrix);
|
||||
if (raw[i + 2] == 0) break;
|
||||
list.addLast (htData = new java.util.Hashtable ());
|
||||
s = "" + (Clazz.floatToInt (f) * 100 + Clazz.doubleToInt ((remain - 0.0999999) * 1000));
|
||||
var len = s.length;
|
||||
s = (len == 2 ? "0" : "") + s.substring (0, len - 2) + "." + s.substring (len - 2);
|
||||
htData.put ("weight", s);
|
||||
htData.put ("index", Integer.$valueOf (index++));
|
||||
htData.put ("type", nrtType.toLowerCase ());
|
||||
htData.put ("spin", nrtType.indexOf ("B") >= 0 ? "beta" : "alpha");
|
||||
matrix = Clazz.newIntArray (nAtoms, nAtoms, 0);
|
||||
htData.put ("matrix", matrix);
|
||||
for (var j = 0; j < nAtoms; j++) for (var k = 0; k < nAtoms; k++) matrix[j][k] = table[j][k];
|
||||
|
||||
|
||||
}}
|
||||
}, "~S,~S,JU.Lst");
|
||||
c$.dumpMatrix = Clazz.defineMethod (c$, "dumpMatrix",
|
||||
function (nrtType, index, matrix) {
|
||||
System.out.println ("NBOParser matrix " + nrtType + " " + index);
|
||||
for (var j = 0, nAtoms = matrix.length; j < nAtoms; j++) System.out.println (JU.PT.toJSON (null, matrix[j]));
|
||||
|
||||
System.out.println ("-------------------");
|
||||
}, "~S,~N,~A");
|
||||
Clazz.defineMethod (c$, "getData",
|
||||
function (output, start, end, n) {
|
||||
var pt = 0;
|
||||
var pt1 = 0;
|
||||
for (var i = 0; i < n; i++) {
|
||||
pt = output.indexOf (start, pt1 + 1);
|
||||
pt1 = output.indexOf (end, pt + 1);
|
||||
}
|
||||
return (pt < 0 || pt1 < 0 ? null : output.substring (pt, pt1));
|
||||
}, "~S,~S,~S,~N");
|
||||
Clazz.defineMethod (c$, "getStructures",
|
||||
function (data, nrtType, list) {
|
||||
if (data == null || data.length == 0) return 0;
|
||||
var n = 0;
|
||||
try {
|
||||
var ignoreSTR = (data.indexOf ("ALPHA") >= 0);
|
||||
if (!ignoreSTR && !data.contains ("STR")) data = "STR " + data + " END";
|
||||
nrtType = nrtType.toLowerCase ();
|
||||
var spin = (nrtType.equals ("nrtstrb") ? "beta" : "alpha");
|
||||
if (nrtType.equals ("choose")) nrtType = null;
|
||||
var htData = null;
|
||||
var tokens = JU.PT.getTokens (data.$replace ('\r', ' ').$replace ('\n', ' ').$replace ('\t', ' '));
|
||||
var lastType = "";
|
||||
var index = 0;
|
||||
for (var i = 0, nt = tokens.length; i < nt; i++) {
|
||||
var tok = tokens[i];
|
||||
switch ("STR = ALPHABETA LONE BOND 3C".indexOf (tok)) {
|
||||
case 0:
|
||||
if (ignoreSTR) continue;
|
||||
tok = spin;
|
||||
case 10:
|
||||
case 15:
|
||||
list.addLast (htData = new java.util.Hashtable ());
|
||||
if (!lastType.equals (tok)) {
|
||||
lastType = tok;
|
||||
index = 0;
|
||||
}htData.put ("index", Integer.$valueOf (index++));
|
||||
htData.put ("spin", spin = tok.toLowerCase ());
|
||||
if (spin.equals ("beta")) this.haveBeta = true;
|
||||
htData.put ("type", nrtType == null ? "choose" + spin.substring (0, 1) : nrtType);
|
||||
n++;
|
||||
break;
|
||||
case 5:
|
||||
htData.put ("weight", tokens[++i]);
|
||||
break;
|
||||
case 20:
|
||||
var lone = new JU.Lst ();
|
||||
htData.put ("lone", lone);
|
||||
while (!(tok = tokens[++i]).equals ("END")) {
|
||||
var at1 = Integer.parseInt (tok);
|
||||
var nlp = Integer.parseInt (tokens[++i]);
|
||||
lone.addLast ( Clazz.newIntArray (-1, [nlp, at1]));
|
||||
}
|
||||
break;
|
||||
case 25:
|
||||
var bonds = new JU.Lst ();
|
||||
htData.put ("bond", bonds);
|
||||
while (!(tok = tokens[++i]).equals ("END")) {
|
||||
var order = "DTQ".indexOf (tok.charAt (0)) + 2;
|
||||
var at1 = Integer.parseInt (tokens[++i]);
|
||||
var at2 = Integer.parseInt (tokens[++i]);
|
||||
bonds.addLast ( Clazz.newIntArray (-1, [order, at1, at2]));
|
||||
}
|
||||
break;
|
||||
case 30:
|
||||
var threeCenter = new JU.Lst ();
|
||||
htData.put ("3c", threeCenter);
|
||||
while (!(tok = tokens[++i]).equals ("END")) {
|
||||
var order = "DTQ".indexOf (tok.charAt (0)) + 2;
|
||||
var at1 = Integer.parseInt (tokens[++i]);
|
||||
var at2 = Integer.parseInt (tokens[++i]);
|
||||
var at3 = Integer.parseInt (tokens[++i]);
|
||||
threeCenter.addLast ( Clazz.newIntArray (-1, [order, at1, at2, at3]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
e.printStackTrace ();
|
||||
list.clear ();
|
||||
return -1;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}, "~S,~S,JU.Lst");
|
||||
Clazz.defineMethod (c$, "isOpenShell",
|
||||
function () {
|
||||
return this.haveBeta;
|
||||
});
|
||||
c$.getStructureMap = Clazz.defineMethod (c$, "getStructureMap",
|
||||
function (structureList, type, index) {
|
||||
if (type == null || structureList == null) return null;
|
||||
type = type.toLowerCase ();
|
||||
var spin = (type.indexOf ("b") < 0 ? "alpha" : "beta");
|
||||
for (var i = 0; i < structureList.size (); i++) {
|
||||
var map = structureList.get (i);
|
||||
if (spin.equals (map.get ("spin")) && type.equals (map.get ("type")) && (index < 0 || index == (map.get ("index")).intValue ())) {
|
||||
return map;
|
||||
}}
|
||||
return null;
|
||||
}, "JU.Lst,~S,~N");
|
||||
Clazz.defineMethod (c$, "connectNBO",
|
||||
function (modelIndex, type) {
|
||||
try {
|
||||
if (type == null) type = "alpha";
|
||||
type = type.toLowerCase ();
|
||||
if (type.length == 0 || type.equals ("46")) type = "alpha";
|
||||
var map = this.vwr.ms.getModelAuxiliaryInfo (modelIndex);
|
||||
this.haveBeta = map.containsKey ("isOpenShell");
|
||||
var list = map.get ("nboStructures");
|
||||
if (list == null || list.size () == 0) return false;
|
||||
type = type.toLowerCase ();
|
||||
var index = type.indexOf ("_");
|
||||
if (index > 0) {
|
||||
if (list.size () <= 2) {
|
||||
var fname = map.get ("fileName");
|
||||
if (fname != null && !fname.endsWith (".nbo")) {
|
||||
fname = fname.substring (0, fname.lastIndexOf (".")) + ".nbo";
|
||||
this.getAllStructures (this.vwr.getAsciiFileOrNull (fname), list);
|
||||
}}var tokens = JU.PT.split (type, "_");
|
||||
index = JU.PT.parseInt (tokens[1]) - 1;
|
||||
type = tokens[0];
|
||||
} else {
|
||||
index = 0;
|
||||
}var structureMap = J.adapter.readers.quantum.NBOParser.getStructureMap (list, type, index);
|
||||
if (structureMap == null || !this.setJmolLewisStructure (structureMap, modelIndex, index + 1)) {
|
||||
return false;
|
||||
}map.put ("nboStructure", structureMap);
|
||||
} catch (e) {
|
||||
e.printStackTrace ();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, "~N,~S");
|
||||
Clazz.defineMethod (c$, "setJmolLewisStructure",
|
||||
function (structureMap, modelIndex, resNo) {
|
||||
if (structureMap == null || modelIndex < 0) return false;
|
||||
var type = structureMap.get ("type");
|
||||
System.out.println ("creating structure " + modelIndex + " " + type);
|
||||
var bonds = structureMap.get ("bond");
|
||||
var lonePairs = structureMap.get ("lone");
|
||||
var matrix = structureMap.get ("matrix");
|
||||
var lplv = structureMap.get ("lplv");
|
||||
var bondCounts = structureMap.get ("bondCounts");
|
||||
var needLP = (lplv == null);
|
||||
var bsAtoms = this.vwr.ms.getModelAtomBitSetIncludingDeleted (modelIndex, false);
|
||||
var atomCount = bsAtoms.cardinality ();
|
||||
var iatom0 = bsAtoms.nextSetBit (0);
|
||||
if (matrix != null && atomCount != matrix.length) return false;
|
||||
if (matrix != null) J.adapter.readers.quantum.NBOParser.dumpMatrix (type, resNo, matrix);
|
||||
if (needLP) {
|
||||
structureMap.put ("lplv", lplv = Clazz.newIntArray (atomCount, 0));
|
||||
structureMap.put ("bondCounts", bondCounts = Clazz.newIntArray (atomCount, 0));
|
||||
}if (needLP) {
|
||||
if (lonePairs != null) {
|
||||
for (var i = lonePairs.size (); --i >= 0; ) {
|
||||
var na = lonePairs.get (i);
|
||||
var nlp = na[0];
|
||||
var a1 = na[1] - 1;
|
||||
lplv[a1] = nlp;
|
||||
}
|
||||
} else if (matrix != null) {
|
||||
for (var i = atomCount; --i >= 0; ) {
|
||||
lplv[i] = matrix[i][i];
|
||||
}
|
||||
}}this.vwr.ms.deleteModelBonds (modelIndex);
|
||||
var mad = this.vwr.ms.getDefaultMadFromOrder (1);
|
||||
if (bonds != null) {
|
||||
for (var i = bonds.size (); --i >= 0; ) {
|
||||
var oab = bonds.get (i);
|
||||
var a1 = iatom0 + oab[1] - 1;
|
||||
var a2 = iatom0 + oab[2] - 1;
|
||||
var order = oab[0];
|
||||
if (needLP) {
|
||||
bondCounts[a1] += order;
|
||||
bondCounts[a2] += order;
|
||||
}this.vwr.ms.bondAtoms (this.vwr.ms.at[a1], this.vwr.ms.at[a2], order, mad, bsAtoms, 0, true, true);
|
||||
}
|
||||
} else if (matrix != null) {
|
||||
for (var i = 0; i < atomCount - 1; i++) {
|
||||
var m = matrix[i];
|
||||
for (var j = i + 1; j < atomCount; j++) {
|
||||
var order = m[j];
|
||||
if (order == 0) continue;
|
||||
System.out.println ("adding bond " + this.vwr.ms.at[i + iatom0] + " " + this.vwr.ms.at[j + iatom0]);
|
||||
this.vwr.ms.bondAtoms (this.vwr.ms.at[i + iatom0], this.vwr.ms.at[j + iatom0], order, mad, null, 0, false, true);
|
||||
if (needLP) {
|
||||
bondCounts[i] += order;
|
||||
bondCounts[j] += order;
|
||||
}}
|
||||
}
|
||||
}for (var i = 0, ia = bsAtoms.nextSetBit (0); ia >= 0; ia = bsAtoms.nextSetBit (ia + 1), i++) {
|
||||
var a = this.vwr.ms.at[ia];
|
||||
a.setValence (bondCounts[i]);
|
||||
a.setFormalCharge (0);
|
||||
var nH = this.vwr.ms.getMissingHydrogenCount (a, true);
|
||||
if (a.getElementNumber () == 6 && nH == 1) {
|
||||
if (bondCounts[i] == 3 && lplv[i] % 10 == 0 || bondCounts[i] == 2) nH -= 2;
|
||||
}a.setFormalCharge (-nH);
|
||||
}
|
||||
return true;
|
||||
}, "java.util.Map,~N,~N");
|
||||
Clazz.defineMethod (c$, "getNBOAtomLabel",
|
||||
function (a) {
|
||||
var name = a.getAtomName ();
|
||||
var modelIndex = a.getModelIndex ();
|
||||
var structureMap = this.vwr.ms.getModelAuxiliaryInfo (modelIndex).get ("nboStructure");
|
||||
if (this.vwr == null || structureMap == null) return name;
|
||||
var lplv = structureMap.get ("lplv");
|
||||
var i = a.i - this.vwr.ms.am[modelIndex].firstAtomIndex;
|
||||
var addFormalCharge = this.vwr.getBoolean (603979891);
|
||||
var charge = (addFormalCharge ? this.vwr.ms.at[i].getFormalCharge () : 0);
|
||||
if (lplv[i] == 0 && charge == 0) return name;
|
||||
if (lplv[i] % 10 > 0) name = "<sup>(" + (lplv[i] % 10) + ")</sup>" + name;
|
||||
if (lplv[i] >= 10) name = "*" + name;
|
||||
if (addFormalCharge) {
|
||||
if (charge != 0) name += "<sup>" + Math.abs (charge) + (charge > 0 ? "+" : charge < 0 ? "-" : "") + "</sup>";
|
||||
}return name;
|
||||
}, "JM.Atom");
|
||||
});
|
||||
@@ -0,0 +1,403 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MOReader", "java.util.Hashtable"], "J.adapter.readers.quantum.NWChemReader", ["java.lang.Character", "$.Float", "JU.AU", "$.BS", "$.Lst", "$.PT", "J.adapter.readers.quantum.BasisFunctionReader", "J.adapter.smarter.SmarterJmolAdapter", "J.api.JmolAdapter", "JU.Elements", "$.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.taskNumber = 1;
|
||||
this.equivalentAtomSets = 0;
|
||||
this.energyKey = "";
|
||||
this.energyValue = "";
|
||||
this.converged = false;
|
||||
this.haveEnergy = false;
|
||||
this.haveAt = false;
|
||||
this.inInput = false;
|
||||
this.atomTypes = null;
|
||||
this.htMOs = null;
|
||||
this.nBasisFunctions = 0;
|
||||
this.moCount = 0;
|
||||
this.purging = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "NWChemReader", J.adapter.readers.quantum.MOReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.htMOs = new java.util.Hashtable ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.calculationType = "(NWCHEM)";
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.trim ().startsWith ("NWChem")) {
|
||||
this.inInput = (this.line.indexOf ("NWChem Input Module") >= 0);
|
||||
if (this.inInput) {
|
||||
this.checkMOs ();
|
||||
}}if (this.line.startsWith (" Step")) {
|
||||
this.init ();
|
||||
return true;
|
||||
}if (this.line.indexOf (" wavefunction = ") >= 0) {
|
||||
this.calculationType = this.line.substring (this.line.indexOf ("=") + 1).trim () + "(NWCHEM)";
|
||||
this.moData.put ("calculationType", this.calculationType);
|
||||
return true;
|
||||
}if (this.line.indexOf ("Total") >= 0) {
|
||||
this.readTotal ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("@") >= 0) {
|
||||
this.readAtSign ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" Task times")) {
|
||||
this.init ();
|
||||
this.taskNumber++;
|
||||
return true;
|
||||
}if (this.line.startsWith (" Optimization converged")) {
|
||||
this.converged = true;
|
||||
return true;
|
||||
}if (this.line.startsWith (" Symmetry information")) {
|
||||
this.readSymmetry ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Output coordinates in ") >= 0) {
|
||||
var thisLine = this.line;
|
||||
if (!this.htMOs.isEmpty ()) this.checkMOs ();
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.equivalentAtomSets++;
|
||||
this.readAtoms (thisLine);
|
||||
return true;
|
||||
}if (this.line.indexOf ("Vibrational analysis") >= 0) {
|
||||
this.readFrequencies ();
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.startsWith (" Mulliken analysis of the total density")) {
|
||||
if (this.equivalentAtomSets != 0) this.readPartialCharges ();
|
||||
return true;
|
||||
}if (this.line.contains ("Basis \"ao basis\"") && this.doReadMolecularOrbitals) {
|
||||
return this.readBasis ();
|
||||
}if (this.line.contains ("Molecular Orbital Analysis")) {
|
||||
if (this.equivalentAtomSets != 0) this.readMOs ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.checkMOs ();
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "init",
|
||||
function () {
|
||||
this.haveEnergy = false;
|
||||
this.haveAt = false;
|
||||
this.converged = false;
|
||||
this.inInput = false;
|
||||
this.equivalentAtomSets = 0;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setEnergies",
|
||||
function (key, value, nAtomSets) {
|
||||
this.energyKey = key;
|
||||
this.energyValue = value;
|
||||
this.setProps (this.energyKey, this.energyValue, this.equivalentAtomSets);
|
||||
this.setNames (this.energyKey + " = " + this.energyValue, null, this.equivalentAtomSets);
|
||||
this.asc.setAtomSetEnergy (value, this.parseFloatStr (value));
|
||||
this.haveEnergy = true;
|
||||
}, "~S,~S,~N");
|
||||
Clazz.defineMethod (c$, "setEnergy",
|
||||
function (key, value) {
|
||||
this.energyKey = key;
|
||||
this.energyValue = value;
|
||||
this.asc.setAtomSetModelProperty (this.energyKey, this.energyValue);
|
||||
this.asc.setAtomSetName (this.energyKey + " = " + this.energyValue);
|
||||
this.haveEnergy = true;
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "readSymmetry",
|
||||
function () {
|
||||
var tokens = JU.PT.getTokens (this.readLines (3));
|
||||
this.setProps ("Symmetry group name", tokens[tokens.length - 1], this.equivalentAtomSets);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readTotal",
|
||||
function () {
|
||||
var tokens = this.getTokens ();
|
||||
try {
|
||||
if (tokens[2].startsWith ("energy")) {
|
||||
if (!this.haveAt) this.setEnergies ("E(" + tokens[1] + ")", tokens[tokens.length - 1], this.equivalentAtomSets);
|
||||
}} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtSign",
|
||||
function () {
|
||||
if (this.line.charAt (2) == 'S') {
|
||||
if (this.readLines (2) == null) return;
|
||||
}var tokens = this.getTokens ();
|
||||
if (!this.haveEnergy) {
|
||||
this.setEnergies ("E", tokens[2], this.equivalentAtomSets);
|
||||
} else {
|
||||
this.setEnergies (this.energyKey, this.energyValue, this.equivalentAtomSets);
|
||||
}this.setProps ("Step", tokens[1], this.equivalentAtomSets);
|
||||
this.haveAt = true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setProps",
|
||||
function (key, value, n) {
|
||||
for (var i = this.asc.iSet; --n >= 0 && i >= 0; --i) this.asc.setAtomSetModelPropertyForSet (key, value, i);
|
||||
|
||||
}, "~S,~S,~N");
|
||||
Clazz.defineMethod (c$, "setNames",
|
||||
function (atomSetName, namedSets, n) {
|
||||
for (var i = this.asc.iSet; --n >= 0 && i >= 0; --i) if (namedSets == null || !namedSets.get (i)) this.asc.setModelInfoForSet ("name", atomSetName, i);
|
||||
|
||||
}, "~S,JU.BS,~N");
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (thisLine) {
|
||||
var scale = (thisLine.indexOf ("angstroms") < 0 ? 0.5291772 : 1);
|
||||
this.readLines (3);
|
||||
var tokens;
|
||||
this.haveEnergy = false;
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetModelProperty (".PATH", "Task " + this.taskNumber + (this.inInput ? J.adapter.smarter.SmarterJmolAdapter.PATH_SEPARATOR + "Input" : J.adapter.smarter.SmarterJmolAdapter.PATH_SEPARATOR + "Geometry"));
|
||||
this.atomTypes = new JU.Lst ();
|
||||
while (this.rd () != null && this.line.length > 0) {
|
||||
tokens = this.getTokens ();
|
||||
if (tokens.length < 6) break;
|
||||
var name = this.fixTag (tokens[1]);
|
||||
this.setAtomCoordScaled (null, tokens, 3, scale).atomName = name;
|
||||
this.atomTypes.addLast (name);
|
||||
}
|
||||
if (this.converged) {
|
||||
this.setEnergy (this.energyKey, this.energyValue);
|
||||
this.asc.setAtomSetModelProperty ("Step", "converged");
|
||||
} else if (this.inInput) {
|
||||
this.asc.setAtomSetName ("Input");
|
||||
}}, "~S");
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
var firstFrequencyAtomSetIndex = this.asc.atomSetCount;
|
||||
var firstVibrationNumber = this.vibrationNumber;
|
||||
var path = "Task " + this.taskNumber + J.adapter.smarter.SmarterJmolAdapter.PATH_SEPARATOR + "Frequencies";
|
||||
this.discardLinesUntilContains ("Atom information");
|
||||
this.readLines (2);
|
||||
this.asc.newAtomSet ();
|
||||
var tokens;
|
||||
while (this.rd () != null && this.line.indexOf ("---") < 0) {
|
||||
tokens = this.getTokens ();
|
||||
this.setAtomCoordScaled (null, tokens, 2, 0.5291772).atomName = this.fixTag (tokens[0]);
|
||||
}
|
||||
this.discardLinesUntilContains ("(Projected Frequencies expressed in cm-1)");
|
||||
this.readLines (3);
|
||||
var firstTime = true;
|
||||
var bsIgnore = new JU.BS ();
|
||||
while (this.rd () != null && this.line.indexOf ("P.Frequency") >= 0) {
|
||||
tokens = JU.PT.getTokensAt (this.line, 12);
|
||||
var frequencyCount = tokens.length;
|
||||
var iAtom0 = this.asc.ac;
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
if (firstTime) iAtom0 -= ac;
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
for (var i = 0; i < frequencyCount; ++i) {
|
||||
ignore[i] = (tokens[i].equals ("0.00") || !this.doGetVibration (++this.vibrationNumber));
|
||||
if (ignore[i]) {
|
||||
bsIgnore.set (this.vibrationNumber);
|
||||
continue;
|
||||
}if (!firstTime) this.asc.cloneLastAtomSet ();
|
||||
firstTime = false;
|
||||
this.asc.setAtomSetFrequency (path, null, tokens[i], null);
|
||||
}
|
||||
this.readLines (1);
|
||||
this.fillFrequencyData (iAtom0, ac, ac, ignore, false, 0, 0, null, 0);
|
||||
this.readLines (3);
|
||||
}
|
||||
try {
|
||||
this.discardLinesUntilContains ("Infra Red Intensities");
|
||||
this.readLines (2);
|
||||
var idx = firstFrequencyAtomSetIndex;
|
||||
for (var i = firstVibrationNumber; i < this.vibrationNumber; ++i) {
|
||||
if (this.rd () == null) return;
|
||||
if (bsIgnore.get (i)) continue;
|
||||
tokens = this.getTokens ();
|
||||
var iset = this.asc.iSet;
|
||||
this.asc.iSet = idx++;
|
||||
this.asc.setAtomSetModelProperty ("IRIntensity", tokens[3] + " au");
|
||||
this.asc.iSet = iset;
|
||||
}
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
System.out.println ("nwchem infra red issue" + e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPartialCharges",
|
||||
function () {
|
||||
var tokens;
|
||||
this.readLines (4);
|
||||
var ac = this.asc.ac;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = i0; i < ac; ++i) {
|
||||
while (atoms[i].elementNumber == 0) ++i;
|
||||
|
||||
do {
|
||||
if (this.rd () == null || this.line.length < 3) return;
|
||||
tokens = this.getTokens ();
|
||||
} while (tokens[0].indexOf (".") >= 0);
|
||||
atoms[i].partialCharge = this.parseIntStr (tokens[2]) - this.parseFloatStr (tokens[3]);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "fixTag",
|
||||
function (tag) {
|
||||
if (tag.equalsIgnoreCase ("bq")) return "X";
|
||||
if (tag.toLowerCase ().startsWith ("bq")) tag = tag.substring (2) + "-Bq";
|
||||
return "" + Character.toUpperCase (tag.charAt (0)) + (tag.length == 1 ? "" : "" + Character.toLowerCase (tag.charAt (1)));
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readBasis",
|
||||
function () {
|
||||
this.gaussianCount = 0;
|
||||
this.shellCount = 0;
|
||||
this.nBasisFunctions = 0;
|
||||
var isD6F10 = (this.line.indexOf ("cartesian") >= 0);
|
||||
if (isD6F10) {
|
||||
this.getDFMap ("DC", J.adapter.readers.quantum.NWChemReader.$DC_LIST, 4, "DXX DYY DZZ DXY DXZ DYZ", 3);
|
||||
this.getDFMap ("FC", J.adapter.readers.quantum.NWChemReader.$FC_LIST, 6, "XXX YYY ZZZ XYY XXY XXZ XZZ YZZ YYZ XYZ", 3);
|
||||
} else {
|
||||
this.getDFMap ("DS", J.adapter.readers.quantum.NWChemReader.$DS_LIST, 3, "d0 d1+ d1- d2+ d2-", 2);
|
||||
this.getDFMap ("FS", J.adapter.readers.quantum.NWChemReader.$FS_LIST, 5, "f0 f1+ f1- f2+ f2- f3+ f3-", 2);
|
||||
}this.shells = new JU.Lst ();
|
||||
var atomInfo = new java.util.Hashtable ();
|
||||
var atomSym = null;
|
||||
var atomData = null;
|
||||
var shellData = null;
|
||||
while (this.line != null) {
|
||||
var nBlankLines = 0;
|
||||
while (this.line.length < 3 || this.line.charAt (2) == ' ') {
|
||||
shellData = new JU.Lst ();
|
||||
this.rd ();
|
||||
if (this.line.length < 3) nBlankLines++;
|
||||
}
|
||||
if (nBlankLines >= 2) break;
|
||||
if (this.parseIntStr (this.line) == -2147483648) {
|
||||
atomSym = this.getTokens ()[0];
|
||||
if (atomSym.length > 2) atomSym = J.api.JmolAdapter.getElementSymbol (JU.Elements.elementNumberFromName (atomSym));
|
||||
atomData = new JU.Lst ();
|
||||
atomInfo.put (atomSym, atomData);
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
continue;
|
||||
}while (this.line != null && this.line.length > 3) {
|
||||
var tokens = this.getTokens ();
|
||||
var o = Clazz.newArray (-1, [tokens[1], Clazz.newFloatArray (-1, [this.parseFloatStr (tokens[2]), this.parseFloatStr (tokens[3])])]);
|
||||
shellData.addLast (o);
|
||||
this.rd ();
|
||||
}
|
||||
atomData.addLast (shellData);
|
||||
}
|
||||
var nD = (isD6F10 ? 6 : 5);
|
||||
var nF = (isD6F10 ? 10 : 7);
|
||||
var gdata = new JU.Lst ();
|
||||
for (var i = 0; i < this.atomTypes.size (); i++) {
|
||||
atomData = atomInfo.get (this.atomTypes.get (i));
|
||||
var nShells = atomData.size ();
|
||||
for (var ishell = 0; ishell < nShells; ishell++) {
|
||||
this.shellCount++;
|
||||
shellData = atomData.get (ishell);
|
||||
var nGaussians = shellData.size ();
|
||||
var type = shellData.get (0)[0];
|
||||
switch (type.charAt (0)) {
|
||||
case 'S':
|
||||
this.nBasisFunctions += 1;
|
||||
break;
|
||||
case 'P':
|
||||
this.nBasisFunctions += 3;
|
||||
break;
|
||||
case 'D':
|
||||
this.nBasisFunctions += nD;
|
||||
break;
|
||||
case 'F':
|
||||
this.nBasisFunctions += nF;
|
||||
break;
|
||||
}
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
slater[0] = i + 1;
|
||||
slater[1] = (isD6F10 ? J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (type) : J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagIDSpherical (type));
|
||||
slater[2] = this.gaussianCount + 1;
|
||||
slater[3] = nGaussians;
|
||||
this.shells.addLast (slater);
|
||||
for (var ifunc = 0; ifunc < nGaussians; ifunc++) gdata.addLast (shellData.get (ifunc)[1]);
|
||||
|
||||
this.gaussianCount += nGaussians;
|
||||
}
|
||||
}
|
||||
this.gaussians = JU.AU.newFloat2 (this.gaussianCount);
|
||||
for (var i = 0; i < this.gaussianCount; i++) this.gaussians[i] = gdata.get (i);
|
||||
|
||||
JU.Logger.info (this.gaussianCount + " Gaussians read");
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMOs",
|
||||
function () {
|
||||
var lines = new JU.Lst ();
|
||||
this.htMOs.put (this.line, lines);
|
||||
lines.addLast (this.line);
|
||||
var nblank = 0;
|
||||
while (nblank != 2 && this.rd () != null) {
|
||||
lines.addLast (this.line);
|
||||
if (this.line.length < 2) nblank++;
|
||||
else nblank = 0;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "checkMOs",
|
||||
function () {
|
||||
if (this.shells == null) return;
|
||||
for (var entry, $entry = this.htMOs.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) {
|
||||
this.line = entry.getKey ();
|
||||
this.alphaBeta = this.line.substring (0, this.line.indexOf ("Final")).trim () + " ";
|
||||
var moCount = 0;
|
||||
if (!this.filterMO ()) continue;
|
||||
var list = entry.getValue ();
|
||||
var n = list.size ();
|
||||
JU.Logger.info (this.line);
|
||||
for (var i = 3; i < n; i++) {
|
||||
while (i < n && ((this.line = list.get (i)).length < 2 || this.line.charAt (1) != 'V')) i++;
|
||||
|
||||
if (i == n) break;
|
||||
this.line = this.line.$replace ('=', ' ');
|
||||
var tokens = this.getTokens ();
|
||||
var occupancy = this.parseFloatStr (tokens[3]);
|
||||
var energy = this.parseFloatStr (tokens[5]);
|
||||
var symmetry = (tokens.length > 7 ? tokens[7] : null);
|
||||
var mo = new java.util.Hashtable ();
|
||||
mo.put ("occupancy", Float.$valueOf (occupancy));
|
||||
mo.put ("energy", Float.$valueOf (energy));
|
||||
if (symmetry != null) mo.put ("symmetry", symmetry);
|
||||
var coefs = null;
|
||||
this.setMO (mo);
|
||||
mo.put ("type", this.alphaBeta + (++moCount));
|
||||
coefs = Clazz.newFloatArray (this.nBasisFunctions, 0);
|
||||
mo.put ("coefficients", coefs);
|
||||
i += 3;
|
||||
while ((this.line = list.get (++i)) != null && this.line.length > 3) {
|
||||
tokens = this.getTokens ();
|
||||
coefs[this.parseIntStr (tokens[0]) - 1] = this.parseFloatStr (tokens[1]);
|
||||
var pt = Clazz.doubleToInt (tokens.length / 2);
|
||||
if (pt == 5 || pt == 6) coefs[this.parseIntStr (tokens[pt]) - 1] = this.parseFloatStr (tokens[pt + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.energyUnits = "a.u.";
|
||||
this.setMOData (true);
|
||||
this.htMOs.clear ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "rd",
|
||||
function () {
|
||||
this.RL ();
|
||||
if (!this.purging && this.line != null && this.line.startsWith ("--")) {
|
||||
this.purging = true;
|
||||
this.discardLinesUntilStartsWith ("*");
|
||||
this.rd ();
|
||||
this.purging = false;
|
||||
this.RL ();
|
||||
}return this.line;
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"$DS_LIST", "d2- d1- d0 d1+ d2+",
|
||||
"$FS_LIST", "f3- f2- f1- f0 f1+ f2+ f3+",
|
||||
"$DC_LIST", "DXX DXY DXZ DYY DYZ DZZ",
|
||||
"$FC_LIST", "XXX XXY XXZ XYY XYZ XZZ YYY YYZ YZZ ZZZ");
|
||||
});
|
||||
@@ -0,0 +1,202 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MOReader", "java.util.Hashtable", "JU.Lst"], "J.adapter.readers.quantum.PsiReader", ["java.lang.Float", "JU.AU", "$.PT", "J.adapter.readers.quantum.BasisFunctionReader", "J.api.JmolAdapter", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.atomNames = null;
|
||||
this.shellsByUniqueAtom = null;
|
||||
this.uniqueAtomMap = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "PsiReader", J.adapter.readers.quantum.MOReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.atomNames = new JU.Lst ();
|
||||
this.shellsByUniqueAtom = new JU.Lst ();
|
||||
this.uniqueAtomMap = new java.util.Hashtable ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf ("-Geometry after Center-of-Mass shift and reorientation (a.u.):") >= 0) {
|
||||
this.readAtoms (true);
|
||||
this.doProcessLines = true;
|
||||
return true;
|
||||
}if (this.line.indexOf ("-Unique atoms in the canonical coordinate system (a.u.):") >= 0) {
|
||||
this.readUniqueAtoms ();
|
||||
this.doProcessLines = true;
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.indexOf ("New Cartesian Geometry in a.u.") >= 0) {
|
||||
this.readAtoms (false);
|
||||
return true;
|
||||
}if (this.line.startsWith (" label = ")) {
|
||||
this.moData.put ("calculationType", this.calculationType = this.line.substring (17).trim ());
|
||||
return true;
|
||||
}if (this.line.startsWith ("molecular orbitals for ")) {
|
||||
this.moData.put ("energyUnits", "");
|
||||
return true;
|
||||
}if (this.line.startsWith (" -BASIS SETS:")) {
|
||||
this.readBasis ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Molecular Orbital Coefficients") >= 0) {
|
||||
if (this.filterMO ()) this.readPsiMolecularOrbitals ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("SCF total energy =") >= 0) {
|
||||
this.readSCFDone ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Normal Modes") >= 0) {
|
||||
this.readFrequencies ();
|
||||
return true;
|
||||
}return this.checkNboLine ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSCFDone",
|
||||
function () {
|
||||
this.asc.setAtomSetName (this.line);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (isInitial) {
|
||||
if (isInitial) {
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetName ("");
|
||||
this.discardLinesUntilContains ("----");
|
||||
}var atomPt = 0;
|
||||
while (this.rd () != null && this.line.length > 0) {
|
||||
var tokens = this.getTokens ();
|
||||
var atom = (isInitial ? this.asc.addNewAtom () : this.asc.atoms[atomPt++]);
|
||||
if (isInitial) {
|
||||
this.atomNames.addLast (tokens[0]);
|
||||
if (tokens[0].length <= 2) atom.elementNumber = J.api.JmolAdapter.getElementNumber (tokens[0]);
|
||||
} else {
|
||||
atom.elementNumber = this.parseIntStr (tokens[0]);
|
||||
}if (atom.elementNumber < 0) atom.elementNumber = 0;
|
||||
this.setAtomCoordScaled (atom, tokens, 1, 0.5291772);
|
||||
}
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "readBasis",
|
||||
function () {
|
||||
var gdata = new JU.Lst ();
|
||||
this.gaussianCount = 0;
|
||||
this.shellCount = 0;
|
||||
var tokens;
|
||||
var slater = null;
|
||||
var slatersByUniqueAtom = null;
|
||||
this.rd ();
|
||||
while (this.rd () != null && this.line.startsWith (" -Basis set on")) {
|
||||
slatersByUniqueAtom = new JU.Lst ();
|
||||
var nGaussians = 0;
|
||||
while (this.rd () != null && !this.line.startsWith (" )")) {
|
||||
this.line = this.line.$replace ('(', ' ').$replace (')', ' ');
|
||||
tokens = this.getTokens ();
|
||||
var ipt = 0;
|
||||
switch (tokens.length) {
|
||||
case 3:
|
||||
if (slater != null) {
|
||||
slatersByUniqueAtom.addLast (slater);
|
||||
}ipt = 1;
|
||||
slater = Clazz.newIntArray (3, 0);
|
||||
slater[0] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (tokens[0]);
|
||||
slater[1] = this.gaussianCount;
|
||||
this.shellCount++;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
nGaussians++;
|
||||
gdata.addLast ( Clazz.newArray (-1, [tokens[ipt], tokens[ipt + 1]]));
|
||||
slater[2] = nGaussians;
|
||||
}
|
||||
if (slater != null) {
|
||||
slatersByUniqueAtom.addLast (slater);
|
||||
}this.shellsByUniqueAtom.addLast (slatersByUniqueAtom);
|
||||
this.gaussianCount += nGaussians;
|
||||
this.rd ();
|
||||
}
|
||||
var garray = JU.AU.newFloat2 (this.gaussianCount);
|
||||
for (var i = 0; i < this.gaussianCount; i++) {
|
||||
tokens = gdata.get (i);
|
||||
garray[i] = Clazz.newFloatArray (tokens.length, 0);
|
||||
for (var j = 0; j < tokens.length; j++) garray[i][j] = this.parseFloatStr (tokens[j]);
|
||||
|
||||
}
|
||||
this.moData.put ("gaussians", garray);
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (this.shellCount + " slater shells read");
|
||||
JU.Logger.debug (this.gaussianCount + " gaussian primitives read");
|
||||
}});
|
||||
Clazz.defineMethod (c$, "readUniqueAtoms",
|
||||
function () {
|
||||
var sdata = new JU.Lst ();
|
||||
this.discardLinesUntilContains ("----");
|
||||
var n = 0;
|
||||
while (this.rd () != null && this.line.length > 0) {
|
||||
var tokens = this.getTokens ();
|
||||
this.uniqueAtomMap.put (tokens[0], Integer.$valueOf (n++));
|
||||
}
|
||||
var ac = this.atomNames.size ();
|
||||
for (var i = 0; i < ac; i++) {
|
||||
var atomType = this.atomNames.get (i);
|
||||
var iUnique = this.uniqueAtomMap.get (atomType).intValue ();
|
||||
var slaters = this.shellsByUniqueAtom.get (iUnique);
|
||||
if (slaters == null) {
|
||||
JU.Logger.error ("slater for atom " + i + " atomType " + atomType + " was not found in listing. Ignoring molecular orbitals");
|
||||
return;
|
||||
}for (var j = 0; j < slaters.size (); j++) {
|
||||
var slater = slaters.get (j);
|
||||
sdata.addLast ( Clazz.newIntArray (-1, [i + 1, slater[0], slater[1], slater[2]]));
|
||||
}
|
||||
}
|
||||
this.moData.put ("shells", sdata);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPsiMolecularOrbitals",
|
||||
function () {
|
||||
var mos = JU.AU.createArrayOfHashtable (5);
|
||||
var data = JU.AU.createArrayOfArrayList (5);
|
||||
var nThisLine = 0;
|
||||
while (this.rd () != null && this.line.toUpperCase ().indexOf ("DENS") < 0) {
|
||||
var tokens = this.getTokens ();
|
||||
var ptData = (this.line.charAt (5) == ' ' ? 2 : 4);
|
||||
if (this.line.indexOf (" ") == 0) {
|
||||
this.addMOData (nThisLine, data, mos);
|
||||
nThisLine = tokens.length;
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
for (var i = 0; i < nThisLine; i++) {
|
||||
mos[i] = new java.util.Hashtable ();
|
||||
data[i] = new JU.Lst ();
|
||||
mos[i].put ("symmetry", tokens[i]);
|
||||
}
|
||||
tokens = J.adapter.smarter.AtomSetCollectionReader.getStrings (this.rd ().substring (21), nThisLine, 10);
|
||||
for (var i = 0; i < nThisLine; i++) {
|
||||
mos[i].put ("energy", Float.$valueOf (JU.PT.fVal (tokens[i])));
|
||||
}
|
||||
continue;
|
||||
}try {
|
||||
for (var i = 0; i < nThisLine; i++) {
|
||||
data[i].addLast (tokens[i + ptData]);
|
||||
}
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
JU.Logger.error ("Error reading Psi3 file molecular orbitals at line: " + this.line);
|
||||
break;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.addMOData (nThisLine, data, mos);
|
||||
this.moData.put ("mos", this.orbitals);
|
||||
this.finalizeMOData (this.moData);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
this.rd ();
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var tokens;
|
||||
while (this.rd () != null && this.line.indexOf ("Frequency") >= 0) {
|
||||
tokens = this.getTokens ();
|
||||
var iAtom0 = this.asc.ac;
|
||||
var ignore = Clazz.newBooleanArray (1, false);
|
||||
if (!this.doGetVibration (++this.vibrationNumber)) continue;
|
||||
this.asc.cloneLastAtomSet ();
|
||||
this.asc.setAtomSetFrequency (null, null, tokens[1], null);
|
||||
this.readLines (2);
|
||||
this.fillFrequencyData (iAtom0, ac, ac, ignore, true, 0, 0, null, 0);
|
||||
this.rd ();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,235 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MoldenReader"], "J.adapter.readers.quantum.QCJSONReader", ["java.lang.Double", "$.Float", "java.util.Arrays", "$.Hashtable", "JU.AU", "$.Lst", "$.SB", "J.adapter.readers.quantum.BasisFunctionReader", "J.api.JmolAdapter", "JU.Logger", "org.qcschema.QCSchemaUnits"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.job = null;
|
||||
this.jobCount = 0;
|
||||
this.modelCount = 0;
|
||||
this.$haveEnergy = true;
|
||||
this.lastBasisID = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "QCJSONReader", J.adapter.readers.quantum.MoldenReader);
|
||||
Clazz.defineMethod (c$, "initializeReader",
|
||||
function () {
|
||||
Clazz.superCall (this, J.adapter.readers.quantum.QCJSONReader, "initializeReader", []);
|
||||
var sb = new JU.SB ();
|
||||
try {
|
||||
while (this.rd () != null) sb.append (this.line);
|
||||
|
||||
var json = this.vwr.parseJSONArray (sb.toString ());
|
||||
JU.Logger.info (json.get (0).toString ());
|
||||
this.jobCount = json.size () - 2;
|
||||
for (var i = 0; i < this.jobCount; i++) this.processJob (json.get (i + 2));
|
||||
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
e.printStackTrace ();
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processJob",
|
||||
function (job) {
|
||||
this.job = job;
|
||||
this.readSteps ();
|
||||
}, "java.util.Map");
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSteps",
|
||||
function () {
|
||||
var steps = org.qcschema.QCSchemaUnits.getList (this.job, "steps");
|
||||
var nSteps = steps.size ();
|
||||
for (var iStep = 0; iStep < nSteps; iStep++) {
|
||||
if (!this.doGetModel (++this.modelCount, null)) {
|
||||
if (!this.checkLastModel ()) return;
|
||||
continue;
|
||||
}this.asc.newAtomSet ();
|
||||
var step = steps.get (iStep);
|
||||
var topology = J.adapter.readers.quantum.QCJSONReader.getMapSafely (step, "topology");
|
||||
var atoms = J.adapter.readers.quantum.QCJSONReader.getMapSafely (topology, "atoms");
|
||||
var symbols = org.qcschema.QCSchemaUnits.getStringArray (atoms, "symbol");
|
||||
var atomNumbers = org.qcschema.QCSchemaUnits.getIntArray (atoms, "atom_number");
|
||||
var atom_names = org.qcschema.QCSchemaUnits.getStringArray (atoms, "atom_names");
|
||||
var coords = org.qcschema.QCSchemaUnits.getDoubleArray (atoms, "coords");
|
||||
this.modelAtomCount = Clazz.doubleToInt (coords.length / 3);
|
||||
var f = org.qcschema.QCSchemaUnits.getConversionFactor (atoms, "coords", "angstroms");
|
||||
var isFractional = (f == 0);
|
||||
this.setFractionalCoordinates (isFractional);
|
||||
if (isFractional) {
|
||||
f = org.qcschema.QCSchemaUnits.getConversionFactor (atoms, "unit_cell", "angstroms");
|
||||
var cell = org.qcschema.QCSchemaUnits.getDoubleArray (atoms, "unit_cell");
|
||||
if (cell == null) {
|
||||
JU.Logger.error ("topology.unit_cell is missing even though atoms are listed as fractional");
|
||||
} else {
|
||||
for (var i = 0; i < 6; i++) {
|
||||
switch (i) {
|
||||
case 3:
|
||||
f = 1;
|
||||
default:
|
||||
this.setUnitCellItem (i, (cell[i] * f));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}}for (var i = 0, pt = 0; i < this.modelAtomCount; i++) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
this.setAtomCoordXYZ (atom, (coords[pt++] * f), (coords[pt++] * f), (coords[pt++] * f));
|
||||
var sym = (symbols == null ? J.api.JmolAdapter.getElementSymbol (atomNumbers[i]) : symbols[i]);
|
||||
atom.atomName = (atom_names == null ? sym : atom_names[i]);
|
||||
atom.elementNumber = (atomNumbers == null ? J.api.JmolAdapter.getElementNumber (sym) : atomNumbers[i]);
|
||||
}
|
||||
if (this.doReadMolecularOrbitals) {
|
||||
this.readMolecularOrbitals (J.adapter.readers.quantum.QCJSONReader.getMapSafely (step, "molecular_orbitals"));
|
||||
this.clearOrbitals ();
|
||||
}this.applySymmetryAndSetTrajectory ();
|
||||
if (this.loadVibrations) {
|
||||
this.readFreqsAndModes (org.qcschema.QCSchemaUnits.getList (step, "vibrations"));
|
||||
}}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFreqsAndModes",
|
||||
function (vibrations) {
|
||||
var $private = Clazz.checkPrivateMethod (arguments);
|
||||
if ($private != null) {
|
||||
return $private.apply (this, arguments);
|
||||
}
|
||||
if (vibrations != null) {
|
||||
var n = vibrations.size ();
|
||||
for (var i = 0; i < n; i++) {
|
||||
var vib = vibrations.get (i);
|
||||
var freq = org.qcschema.QCSchemaUnits.getDouble (vib, "frequency", "cm-1");
|
||||
var vectors = org.qcschema.QCSchemaUnits.getDoubleArray (vib, "vectors");
|
||||
if (i > 0) this.asc.cloneLastAtomSet ();
|
||||
this.asc.setAtomSetFrequency (null, null, "" + freq, "cm-1");
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
for (var j = 0, pt = 0; j < this.modelAtomCount; j++) {
|
||||
this.asc.addVibrationVector (j + i0, (vectors[pt++] * 0.5291772), (vectors[pt++] * 0.5291772), (vectors[pt++] * 0.5291772));
|
||||
}
|
||||
}
|
||||
}return true;
|
||||
}, "java.util.ArrayList");
|
||||
Clazz.defineMethod (c$, "readMolecularOrbitals",
|
||||
function (molecular_orbitals) {
|
||||
var $private = Clazz.checkPrivateMethod (arguments);
|
||||
if ($private != null) {
|
||||
return $private.apply (this, arguments);
|
||||
}
|
||||
if (molecular_orbitals == null) return false;
|
||||
var moBasisID = molecular_orbitals.get ("basis_id").toString ();
|
||||
if (!this.readBasis (moBasisID)) return false;
|
||||
var isNormalized = molecular_orbitals.get ("__jmol_normalized");
|
||||
if (isNormalized != null && isNormalized.booleanValue ()) this.moData.put ("isNormalized", isNormalized);
|
||||
this.calculationType = molecular_orbitals.get ("__jmol_calculation_type");
|
||||
if (this.calculationType == null) this.calculationType = "?";
|
||||
this.moData.put ("calculationType", this.calculationType);
|
||||
var mos = org.qcschema.QCSchemaUnits.getList (molecular_orbitals, "orbitals");
|
||||
var n = mos.size ();
|
||||
for (var i = 0; i < n; i++) {
|
||||
var thisMO = mos.get (i);
|
||||
var energy = org.qcschema.QCSchemaUnits.getDouble (thisMO, "energy", "ev");
|
||||
var occupancy = org.qcschema.QCSchemaUnits.getDouble (thisMO, "occupancy", null);
|
||||
var symmetry = thisMO.get ("symmetry");
|
||||
var spin = thisMO.get ("type");
|
||||
if (spin != null) {
|
||||
if (spin.indexOf ("beta") >= 0) this.alphaBeta = "beta";
|
||||
else if (spin.indexOf ("alpha") >= 0) this.alphaBeta = "alpha";
|
||||
}var coefs = this.toFloatArray (org.qcschema.QCSchemaUnits.getDoubleArray (thisMO, "coefficients"));
|
||||
this.line = "" + symmetry;
|
||||
if (this.filterMO ()) {
|
||||
var mo = new java.util.Hashtable ();
|
||||
mo.put ("coefficients", coefs);
|
||||
if (Double.isNaN (energy)) {
|
||||
this.$haveEnergy = false;
|
||||
} else {
|
||||
mo.put ("energy", Float.$valueOf (energy));
|
||||
}if (!Double.isNaN (occupancy)) mo.put ("occupancy", Float.$valueOf (occupancy));
|
||||
if (symmetry != null) mo.put ("symmetry", symmetry);
|
||||
if (this.alphaBeta.length > 0) mo.put ("type", this.alphaBeta);
|
||||
this.setMO (mo);
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (coefs.length + " coefficients in MO " + this.orbitals.size ());
|
||||
}}}
|
||||
if (this.debugging) JU.Logger.debug ("read " + this.orbitals.size () + " MOs");
|
||||
var units = org.qcschema.QCSchemaUnits.getList (molecular_orbitals, "orbitals_energy_units");
|
||||
var sunits = (units == null ? null : units.get (0).toString ());
|
||||
this.setMOs (sunits == null || sunits.equals ("?") ? "?" : sunits);
|
||||
if (this.$haveEnergy && this.doSort) this.sortMOs ();
|
||||
return false;
|
||||
}, "java.util.Map");
|
||||
Clazz.defineMethod (c$, "toFloatArray",
|
||||
function (da) {
|
||||
var fa = Clazz.newFloatArray (da.length, 0);
|
||||
for (var j = da.length; --j >= 0; ) fa[j] = da[j];
|
||||
|
||||
return fa;
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "readBasis",
|
||||
function (moBasisID) {
|
||||
var moBasisData = J.adapter.readers.quantum.QCJSONReader.getMapSafely (this.job, "mo_bases");
|
||||
var moBasis = J.adapter.readers.quantum.QCJSONReader.getMapSafely (moBasisData, moBasisID);
|
||||
if (moBasis == null) {
|
||||
JU.Logger.error ("No job.mo_bases entry for " + moBasisID);
|
||||
return false;
|
||||
}if (moBasisID === this.lastBasisID) return true;
|
||||
this.lastBasisID = moBasisID;
|
||||
var listG = org.qcschema.QCSchemaUnits.getList (moBasis, "gaussians");
|
||||
var listS = org.qcschema.QCSchemaUnits.getList (moBasis, "shells");
|
||||
if (listG == null && listS == null) {
|
||||
listG = listS = org.qcschema.QCSchemaUnits.getList (moBasis, "slaters");
|
||||
}if ((listG == null) != (listS == null)) {
|
||||
JU.Logger.error ("gaussians/shells or slaters missing");
|
||||
return false;
|
||||
}if (listG === listS) {
|
||||
this.readSlaterBasis (listS);
|
||||
} else {
|
||||
this.readGaussianBasis (listG, listS);
|
||||
}return true;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readSlaterBasis",
|
||||
function (listS) {
|
||||
this.nCoef = listS.size ();
|
||||
for (var i = 0; i < this.nCoef; i++) {
|
||||
var a = org.qcschema.QCSchemaUnits.getDoubleArray (listS.get (i), null);
|
||||
this.addSlater (Clazz.doubleToInt (a[0]), Clazz.doubleToInt (a[1]), Clazz.doubleToInt (a[2]), Clazz.doubleToInt (a[3]), Clazz.doubleToInt (a[4]), a[5], a[6]);
|
||||
}
|
||||
this.setSlaters (false, false);
|
||||
return true;
|
||||
}, "java.util.ArrayList");
|
||||
Clazz.defineMethod (c$, "readGaussianBasis",
|
||||
function (listG, listS) {
|
||||
var $private = Clazz.checkPrivateMethod (arguments);
|
||||
if ($private != null) {
|
||||
return $private.apply (this, arguments);
|
||||
}
|
||||
this.shells = new JU.Lst ();
|
||||
for (var i = 0; i < listS.size (); i++) this.shells.addLast (org.qcschema.QCSchemaUnits.getIntArray (listS.get (i), null));
|
||||
|
||||
var gaussianPtr = listG.size ();
|
||||
var garray = JU.AU.newFloat2 (gaussianPtr);
|
||||
for (var i = 0; i < gaussianPtr; i++) garray[i] = this.toFloatArray (org.qcschema.QCSchemaUnits.getDoubleArray (listG.get (i), null));
|
||||
|
||||
this.moData.put ("shells", this.shells);
|
||||
this.moData.put ("gaussians", garray);
|
||||
JU.Logger.info (this.shells.size () + " slater shells read");
|
||||
JU.Logger.info (garray.length + " gaussian primitives read");
|
||||
this.asc.setCurrentModelInfo ("moData", this.moData);
|
||||
return false;
|
||||
}, "java.util.ArrayList,java.util.ArrayList");
|
||||
Clazz.defineMethod (c$, "sortMOs",
|
||||
function () {
|
||||
var $private = Clazz.checkPrivateMethod (arguments);
|
||||
if ($private != null) {
|
||||
return $private.apply (this, arguments);
|
||||
}
|
||||
var list = this.orbitals.toArray ( new Array (this.orbitals.size ()));
|
||||
java.util.Arrays.sort (list, Clazz.innerTypeInstance (J.adapter.readers.quantum.BasisFunctionReader.MOEnergySorter, this, null));
|
||||
this.orbitals.clear ();
|
||||
for (var i = 0; i < list.length; i++) this.orbitals.addLast (list[i]);
|
||||
|
||||
});
|
||||
c$.getMapSafely = Clazz.defineMethod (c$, "getMapSafely",
|
||||
function (map, key) {
|
||||
return (map == null ? null : map.get (key));
|
||||
}, "java.util.Map,~S");
|
||||
});
|
||||
@@ -0,0 +1,319 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MOReader"], "J.adapter.readers.quantum.QchemReader", ["java.lang.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "J.adapter.readers.quantum.BasisFunctionReader", "J.api.JmolAdapter", "J.quantum.QS", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.calculationNumber = 1;
|
||||
this.isFirstJob = true;
|
||||
this.alphas = null;
|
||||
this.betas = null;
|
||||
this.nBasis = 0;
|
||||
this.dFixed = false;
|
||||
this.fFixed = false;
|
||||
this.dList = "";
|
||||
this.fList = "";
|
||||
this.dSpherical = false;
|
||||
this.fSpherical = false;
|
||||
if (!Clazz.isClassDefined ("J.adapter.readers.quantum.QchemReader.MOInfo")) {
|
||||
J.adapter.readers.quantum.QchemReader.$QchemReader$MOInfo$ ();
|
||||
}
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "QchemReader", J.adapter.readers.quantum.MOReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.energyUnits = "au";
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf ("Standard Nuclear Orientation") >= 0) {
|
||||
this.readAtoms ();
|
||||
this.moData = null;
|
||||
return true;
|
||||
}if (this.line.indexOf ("Total energy") >= 0 || this.line.indexOf ("total energy") >= 0 || this.line.indexOf ("Energy is") >= 0) {
|
||||
if (this.line.indexOf ("Excitation") == -1) this.readEnergy ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Requested basis set is") >= 0) {
|
||||
this.readCalculationType ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("VIBRATIONAL FREQUENCIES") >= 0) {
|
||||
this.readFrequencies ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Mulliken Net Atomic Charges") >= 0) {
|
||||
this.readPartialCharges ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("Job ") || this.line.startsWith ("Running Job")) {
|
||||
if (this.isFirstJob && this.line.startsWith ("Running")) this.calculationNumber = 0;
|
||||
this.calculationNumber++;
|
||||
this.isFirstJob = false;
|
||||
this.moData = null;
|
||||
return true;
|
||||
}if (this.line.indexOf ("Basis set in general basis input format") >= 0) {
|
||||
if (this.moData == null) {
|
||||
this.readBasis ();
|
||||
}return true;
|
||||
}if (this.moData == null) return true;
|
||||
if (this.line.indexOf ("Orbital Energies (a.u.) and Symmetries") >= 0) {
|
||||
this.readESym (true);
|
||||
return true;
|
||||
}if (this.line.indexOf ("Orbital Energies (a.u.)") >= 0) {
|
||||
this.readESym (false);
|
||||
return true;
|
||||
}if (this.line.indexOf ("MOLECULAR ORBITAL COEFFICIENTS") >= 0) {
|
||||
if (this.filterMO ()) this.readQchemMolecularOrbitals ();
|
||||
return true;
|
||||
}return this.checkNboLine ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCalculationType",
|
||||
function () {
|
||||
this.calculationType = this.line.substring (this.line.indexOf ("set is") + 6).trim ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
this.setMOData (true);
|
||||
this.dFixed = this.fFixed = false;
|
||||
this.readLines (2);
|
||||
var tokens;
|
||||
while (this.rd () != null && !this.line.startsWith (" --")) {
|
||||
tokens = this.getTokens ();
|
||||
if (tokens.length < 5) continue;
|
||||
var symbol = tokens[1];
|
||||
if (J.api.JmolAdapter.getElementNumber (symbol) > 0) this.addAtomXYZSymName (tokens, 2, symbol, null);
|
||||
}
|
||||
this.asc.setAtomSetModelProperty (".PATH", "Job " + this.calculationNumber);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
while (this.rd () != null && this.line.indexOf ("STANDARD") < 0) {
|
||||
if (!this.line.startsWith (" Frequency:")) this.discardLinesUntilStartsWith (" Frequency:");
|
||||
var frequencies = this.getTokens ();
|
||||
var frequencyCount = frequencies.length - 1;
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var iAtom0 = this.asc.ac;
|
||||
for (var i = 0; i < frequencyCount; ++i) {
|
||||
ignore[i] = !this.doGetVibration (++this.vibrationNumber);
|
||||
if (ignore[i]) continue;
|
||||
this.asc.cloneLastAtomSet ();
|
||||
this.asc.setAtomSetFrequency ("Job " + this.calculationNumber, null, frequencies[i + 1], null);
|
||||
}
|
||||
this.discardLinesUntilStartsWith (" X");
|
||||
this.fillFrequencyData (iAtom0, ac, ac, ignore, true, 0, 0, null, 0);
|
||||
this.discardLinesUntilBlank ();
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPartialCharges",
|
||||
function () {
|
||||
this.readLines (3);
|
||||
var atoms = this.asc.atoms;
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
for (var i = 0; i < ac && this.rd () != null; ++i) atoms[i].partialCharge = this.parseFloatStr (this.getTokens ()[2]);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "readEnergy",
|
||||
function () {
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var tokens = this.getTokens ();
|
||||
var energyKey = "E(" + tokens[0] + ")";
|
||||
var energyString = tokens[tokens.length - 1];
|
||||
this.asc.setAtomSetEnergy (energyString, this.parseFloatStr (energyString));
|
||||
this.asc.setAtomSetName (energyKey + " = " + energyString);
|
||||
this.asc.setModelInfoForSet ("name", energyKey + " " + energyString, ac);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBasis",
|
||||
function () {
|
||||
this.moData = new java.util.Hashtable ();
|
||||
var ac = 1;
|
||||
var shellCount = 0;
|
||||
var gaussianCount = 0;
|
||||
this.shells = new JU.Lst ();
|
||||
var gdata = new JU.Lst ();
|
||||
var tokens;
|
||||
this.discardLinesUntilStartsWith ("$basis");
|
||||
this.rd ();
|
||||
while (this.rd () != null) {
|
||||
if (this.line.startsWith ("****")) {
|
||||
ac++;
|
||||
if (this.rd () != null && this.line.startsWith ("$end")) break;
|
||||
continue;
|
||||
}shellCount++;
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
tokens = this.getTokens ();
|
||||
slater[0] = ac;
|
||||
slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (tokens[0]);
|
||||
slater[2] = gaussianCount + 1;
|
||||
var nGaussians = this.parseIntStr (tokens[1]);
|
||||
slater[3] = nGaussians;
|
||||
this.shells.addLast (slater);
|
||||
gaussianCount += nGaussians;
|
||||
for (var i = 0; i < nGaussians; i++) {
|
||||
gdata.addLast (JU.PT.getTokens (this.rd ()));
|
||||
}
|
||||
}
|
||||
this.gaussians = JU.AU.newFloat2 (gaussianCount);
|
||||
for (var i = 0; i < gaussianCount; i++) {
|
||||
tokens = gdata.get (i);
|
||||
this.gaussians[i] = Clazz.newFloatArray (tokens.length, 0);
|
||||
for (var j = 0; j < tokens.length; j++) this.gaussians[i][j] = this.parseFloatStr (tokens[j]);
|
||||
|
||||
}
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (shellCount + " slater shells read");
|
||||
JU.Logger.debug (gaussianCount + " gaussian primitives read");
|
||||
}this.discardLinesUntilStartsWith (" There are");
|
||||
tokens = this.getTokens ();
|
||||
this.nBasis = this.parseIntStr (tokens[5]);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readESym",
|
||||
function (haveSym) {
|
||||
this.alphas = new Array (this.nBasis);
|
||||
this.betas = new Array (this.nBasis);
|
||||
var moInfos;
|
||||
var ne = 0;
|
||||
var readBetas = false;
|
||||
this.discardLinesUntilStartsWith (" Alpha");
|
||||
var tokens = this.getTokens ();
|
||||
moInfos = this.alphas;
|
||||
for (var e = 0; e < 2; e++) {
|
||||
var nMO = 0;
|
||||
while (this.rd () != null) {
|
||||
if (this.line.startsWith (" -- ")) {
|
||||
ne = 0;
|
||||
if (this.line.indexOf ("Vacant") < 0) {
|
||||
if (this.line.indexOf ("Occupied") > 0) ne = 1;
|
||||
}this.rd ();
|
||||
}if (this.line.startsWith (" -------")) {
|
||||
e = 2;
|
||||
break;
|
||||
}var nOrbs = this.getTokens ().length;
|
||||
if (nOrbs == 0 || this.line.startsWith (" Warning")) {
|
||||
this.discardLinesUntilStartsWith (" Beta");
|
||||
readBetas = true;
|
||||
moInfos = this.betas;
|
||||
break;
|
||||
}if (haveSym) tokens = JU.PT.getTokens (this.rd ());
|
||||
for (var i = 0, j = 0; i < nOrbs; i++, j += 2) {
|
||||
var info = Clazz.innerTypeInstance (J.adapter.readers.quantum.QchemReader.MOInfo, this, null);
|
||||
info.ne = ne;
|
||||
if (haveSym) info.moSymmetry = tokens[j] + tokens[j + 1] + " ";
|
||||
moInfos[nMO] = info;
|
||||
nMO++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!readBetas) this.betas = this.alphas;
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "readQchemMolecularOrbitals",
|
||||
function () {
|
||||
var orbitalType = this.getTokens ()[0];
|
||||
this.alphaBeta = "A";
|
||||
this.readMOs (orbitalType.equals ("RESTRICTED"), this.alphas);
|
||||
if (orbitalType.equals ("ALPHA")) {
|
||||
this.discardLinesUntilContains ("BETA");
|
||||
this.alphaBeta = "B";
|
||||
this.readMOs (false, this.betas);
|
||||
}var isOK = true;
|
||||
if (this.dList.length > 0) {
|
||||
if (this.dSpherical) isOK = this.getDFMap ("DS", this.dList, 3, J.adapter.readers.quantum.QchemReader.$DS_LIST, 2);
|
||||
else isOK = this.getDFMap ("DC", this.dList, 4, J.adapter.readers.quantum.QchemReader.$DC_LIST, 3);
|
||||
if (!isOK) {
|
||||
JU.Logger.error ("atomic orbital order is unrecognized -- skipping reading of MOs. dList=" + this.dList);
|
||||
this.shells = null;
|
||||
}}if (this.fList.length > 0) {
|
||||
if (this.fSpherical) isOK = this.getDFMap ("FS", this.fList, 5, J.adapter.readers.quantum.QchemReader.$FS_LIST, 2);
|
||||
else isOK = this.getDFMap ("FC", this.fList, 6, J.adapter.readers.quantum.QchemReader.$FC_LIST, 3);
|
||||
if (!isOK) {
|
||||
JU.Logger.error ("atomic orbital order is unrecognized -- skipping reading of MOs. fList=" + this.fList);
|
||||
this.shells = null;
|
||||
}}this.setMOData (this.shells == null);
|
||||
this.shells = null;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMOs",
|
||||
function (restricted, moInfos) {
|
||||
var mos = JU.AU.createArrayOfHashtable (6);
|
||||
var mocoef = JU.AU.newFloat2 (6);
|
||||
var moid = Clazz.newIntArray (6, 0);
|
||||
var tokens;
|
||||
var energy;
|
||||
var nMOs = 0;
|
||||
while (this.rd ().length > 2) {
|
||||
tokens = this.getTokens ();
|
||||
var nMO = tokens.length;
|
||||
energy = JU.PT.getTokens (this.rd ().substring (13));
|
||||
for (var i = 0; i < nMO; i++) {
|
||||
moid[i] = this.parseIntStr (tokens[i]) - 1;
|
||||
mocoef[i] = Clazz.newFloatArray (this.nBasis, 0);
|
||||
mos[i] = new java.util.Hashtable ();
|
||||
}
|
||||
for (var i = 0, pt = 0; i < this.nBasis; i++) {
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
var s = this.line.substring (12, 17).trim ();
|
||||
var ch = s.charAt (0);
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
s = s.substring (s.length - 3).toUpperCase ();
|
||||
if (s.startsWith ("D ")) {
|
||||
if (!this.dFixed) this.fixSlaterTypes (4, 3);
|
||||
s = "D" + s.charAt (2);
|
||||
this.dSpherical = true;
|
||||
}if (this.dList.indexOf (s) < 0) this.dList += s + " ";
|
||||
this.dFixed = true;
|
||||
break;
|
||||
case 'f':
|
||||
s = s.substring (s.length - 3).toUpperCase ();
|
||||
if (s.startsWith ("F ")) {
|
||||
if (!this.fFixed) this.fixSlaterTypes (6, 5);
|
||||
s = "F" + s.charAt (2);
|
||||
this.fSpherical = true;
|
||||
}if (this.fList.indexOf (s) < 0) this.fList += s + " ";
|
||||
this.fFixed = true;
|
||||
break;
|
||||
default:
|
||||
if (!J.quantum.QS.isQuantumBasisSupported (ch)) continue;
|
||||
break;
|
||||
}
|
||||
for (var j = tokens.length - nMO, k = 0; k < nMO; j++, k++) mocoef[k][pt] = this.parseFloatStr (tokens[j]);
|
||||
|
||||
pt++;
|
||||
}
|
||||
for (var i = 0; i < nMO; i++) {
|
||||
var moInfo = moInfos[moid[i]];
|
||||
mos[i].put ("energy", Float.$valueOf (JU.PT.fVal (energy[i])));
|
||||
mos[i].put ("coefficients", mocoef[i]);
|
||||
var label = this.alphaBeta;
|
||||
var ne = moInfo.ne;
|
||||
if (restricted) ne = this.alphas[moid[i]].ne + this.betas[moid[i]].ne;
|
||||
mos[i].put ("occupancy", Float.$valueOf (ne));
|
||||
switch (ne) {
|
||||
case 2:
|
||||
label = "AB";
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 0:
|
||||
if (restricted) label = "V";
|
||||
else label = "V" + label;
|
||||
break;
|
||||
}
|
||||
mos[i].put ("symmetry", moInfo.moSymmetry + label + "(" + (moid[i] + 1) + ")");
|
||||
this.orbitals.addLast (mos[i]);
|
||||
}
|
||||
nMOs += nMO;
|
||||
}
|
||||
return nMOs;
|
||||
}, "~B,~A");
|
||||
c$.$QchemReader$MOInfo$ = function () {
|
||||
Clazz.pu$h(self.c$);
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
Clazz.prepareCallback (this, arguments);
|
||||
this.ne = 0;
|
||||
this.moSymmetry = "";
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum.QchemReader, "MOInfo");
|
||||
c$ = Clazz.p0p ();
|
||||
};
|
||||
c$.$DC_LIST = c$.prototype.$DC_LIST = "DXX DYY DZZ DXY DXZ DYZ";
|
||||
Clazz.defineStatics (c$,
|
||||
"$DS_LIST", "D3 D4 D2 D5 D1");
|
||||
c$.$FC_LIST = c$.prototype.$FC_LIST = "XXX YYY ZZZ XYY XXY XXZ XZZ YZZ YYZ XYZ";
|
||||
Clazz.defineStatics (c$,
|
||||
"$FS_LIST", "F4 F5 F3 F6 F2 F7 F1");
|
||||
});
|
||||
@@ -0,0 +1,128 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.BasisFunctionReader", "JU.Lst"], "J.adapter.readers.quantum.SlaterReader", ["java.util.Arrays", "J.quantum.SlaterData", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.slaters = null;
|
||||
this.slaterArray = null;
|
||||
if (!Clazz.isClassDefined ("J.adapter.readers.quantum.SlaterReader.SlaterSorter")) {
|
||||
J.adapter.readers.quantum.SlaterReader.$SlaterReader$SlaterSorter$ ();
|
||||
}
|
||||
if (!Clazz.isClassDefined ("J.adapter.readers.quantum.SlaterReader.OrbitalSorter")) {
|
||||
J.adapter.readers.quantum.SlaterReader.$SlaterReader$OrbitalSorter$ ();
|
||||
}
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum, "SlaterReader", J.adapter.readers.quantum.BasisFunctionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.slaters = new JU.Lst ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "addSlater",
|
||||
function (iAtom, a, b, c, d, zeta, coef) {
|
||||
this.slaters.addLast ( new J.quantum.SlaterData (iAtom, a, b, c, d, zeta, coef));
|
||||
}, "~N,~N,~N,~N,~N,~N,~N");
|
||||
Clazz.defineMethod (c$, "addSlater",
|
||||
function (sd, n) {
|
||||
sd.index = n;
|
||||
this.slaters.addLast (sd);
|
||||
}, "J.quantum.SlaterData,~N");
|
||||
Clazz.defineMethod (c$, "setSlaters",
|
||||
function (doScale, doSort) {
|
||||
if (this.slaterArray == null) {
|
||||
var nSlaters = this.slaters.size ();
|
||||
this.slaterArray = new Array (nSlaters);
|
||||
for (var i = 0; i < this.slaterArray.length; i++) this.slaterArray[i] = this.slaters.get (i);
|
||||
|
||||
}if (doScale) for (var i = 0; i < this.slaterArray.length; i++) {
|
||||
var sd = this.slaterArray[i];
|
||||
sd.coef *= this.scaleSlater (sd.x, sd.y, sd.z, sd.r, sd.zeta);
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug ("SlaterReader " + i + ": " + sd.atomNo + " " + sd.x + " " + sd.y + " " + sd.z + " " + sd.r + " " + sd.zeta + " " + sd.coef);
|
||||
}}
|
||||
if (doSort) {
|
||||
java.util.Arrays.sort (this.slaterArray, Clazz.innerTypeInstance (J.adapter.readers.quantum.SlaterReader.SlaterSorter, this, null));
|
||||
var pointers = Clazz.newIntArray (this.slaterArray.length, 0);
|
||||
for (var i = 0; i < this.slaterArray.length; i++) pointers[i] = this.slaterArray[i].index;
|
||||
|
||||
this.sortOrbitalCoefficients (pointers);
|
||||
}this.moData.put ("slaters", this.slaterArray);
|
||||
this.asc.setCurrentModelInfo ("moData", this.moData);
|
||||
}, "~B,~B");
|
||||
Clazz.defineMethod (c$, "setMOs",
|
||||
function (units) {
|
||||
this.moData.put ("mos", this.orbitals);
|
||||
this.moData.put ("energyUnits", units);
|
||||
this.finalizeMOData (this.moData);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "sortOrbitalCoefficients",
|
||||
function (pointers) {
|
||||
for (var i = this.orbitals.size (); --i >= 0; ) {
|
||||
var mo = this.orbitals.get (i);
|
||||
var coefs = mo.get ("coefficients");
|
||||
var sorted = Clazz.newFloatArray (pointers.length, 0);
|
||||
for (var j = 0; j < pointers.length; j++) {
|
||||
var k = pointers[j];
|
||||
if (k < coefs.length) sorted[j] = coefs[k];
|
||||
}
|
||||
mo.put ("coefficients", sorted);
|
||||
}
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "sortOrbitals",
|
||||
function () {
|
||||
var array = this.orbitals.toArray ( new Array (0));
|
||||
java.util.Arrays.sort (array, Clazz.innerTypeInstance (J.adapter.readers.quantum.SlaterReader.OrbitalSorter, this, null));
|
||||
this.orbitals.clear ();
|
||||
for (var i = 0; i < array.length; i++) this.orbitals.addLast (array[i]);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "scaleSlater",
|
||||
function (ex, ey, ez, er, zeta) {
|
||||
var el = ex + ey + ez;
|
||||
switch (el) {
|
||||
case 0:
|
||||
case 1:
|
||||
ez = -1;
|
||||
break;
|
||||
}
|
||||
return J.adapter.readers.quantum.SlaterReader.getSlaterConstCartesian (el + er + 1, Math.abs (zeta), el, ex, ey, ez);
|
||||
}, "~N,~N,~N,~N,~N");
|
||||
c$.fact = Clazz.defineMethod (c$, "fact",
|
||||
function (f, zeta, n) {
|
||||
return Math.pow (2 * zeta, n + 0.5) * Math.sqrt (f * 0.07957747154594767 / J.adapter.readers.quantum.SlaterReader.fact1[n]);
|
||||
}, "~N,~N,~N");
|
||||
c$.getSlaterConstCartesian = Clazz.defineMethod (c$, "getSlaterConstCartesian",
|
||||
function (n, zeta, el, ex, ey, ez) {
|
||||
return J.adapter.readers.quantum.SlaterReader.fact (ez < 0 ? J.adapter.readers.quantum.SlaterReader.dfact2[el + 1] : J.adapter.readers.quantum.SlaterReader.dfact2[el + 1] / J.adapter.readers.quantum.SlaterReader.dfact2[ex] / J.adapter.readers.quantum.SlaterReader.dfact2[ey] / J.adapter.readers.quantum.SlaterReader.dfact2[ez], zeta, n);
|
||||
}, "~N,~N,~N,~N,~N,~N");
|
||||
c$.getSlaterConstDSpherical = Clazz.defineMethod (c$, "getSlaterConstDSpherical",
|
||||
function (n, zeta, ex, ey) {
|
||||
return J.adapter.readers.quantum.SlaterReader.fact (Clazz.doubleToInt (15 / (ex < 0 ? 12 : ey < 0 ? 4 : 1)), zeta, n);
|
||||
}, "~N,~N,~N,~N");
|
||||
c$.$SlaterReader$SlaterSorter$ = function () {
|
||||
Clazz.pu$h(self.c$);
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
Clazz.prepareCallback (this, arguments);
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum.SlaterReader, "SlaterSorter", null, java.util.Comparator);
|
||||
Clazz.overrideMethod (c$, "compare",
|
||||
function (a, b) {
|
||||
return (a.atomNo < b.atomNo ? -1 : a.atomNo > b.atomNo ? 1 : 0);
|
||||
}, "J.quantum.SlaterData,J.quantum.SlaterData");
|
||||
c$ = Clazz.p0p ();
|
||||
};
|
||||
c$.$SlaterReader$OrbitalSorter$ = function () {
|
||||
Clazz.pu$h(self.c$);
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
Clazz.prepareCallback (this, arguments);
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.quantum.SlaterReader, "OrbitalSorter", null, java.util.Comparator);
|
||||
Clazz.overrideMethod (c$, "compare",
|
||||
function (a, b) {
|
||||
var c = (a.get ("energy")).floatValue ();
|
||||
var d = (b.get ("energy")).floatValue ();
|
||||
return (c < d ? -1 : d < c ? 1 : 0);
|
||||
}, "java.util.Map,java.util.Map");
|
||||
c$ = Clazz.p0p ();
|
||||
};
|
||||
Clazz.defineStatics (c$,
|
||||
"_1_4pi", 0.07957747154594767,
|
||||
"fact1", Clazz.newDoubleArray (-1, [1.0, 2.0, 24.0, 720.0, 40320.0, 362880.0, 87178291200.0]),
|
||||
"dfact2", Clazz.newDoubleArray (-1, [1, 1, 3, 15, 105]));
|
||||
});
|
||||
@@ -0,0 +1,188 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.quantum");
|
||||
Clazz.load (["J.adapter.readers.quantum.MopacSlaterReader"], "J.adapter.readers.quantum.WebMOReader", ["java.lang.Boolean", "$.Exception", "$.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "J.adapter.readers.quantum.BasisFunctionReader", "J.adapter.smarter.Bond", "JU.Logger"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.quantum, "WebMOReader", J.adapter.readers.quantum.MopacSlaterReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.equals ("[HEADER]")) {
|
||||
this.readHeader ();
|
||||
return true;
|
||||
}if (this.line.equals ("[ATOMS]")) {
|
||||
this.readAtoms ();
|
||||
return false;
|
||||
}if (this.line.equals ("[BONDS]")) {
|
||||
this.readBonds ();
|
||||
return false;
|
||||
}if (!this.doReadMolecularOrbitals) return true;
|
||||
if (this.line.equals ("[AO_ORDER]")) {
|
||||
this.readAtomicOrbitalOrder ();
|
||||
return false;
|
||||
}if (this.line.equals ("[GTO]")) {
|
||||
this.readGaussianBasis ();
|
||||
return false;
|
||||
}if (this.line.equals ("[STO]")) {
|
||||
this.readSlaterBasis ();
|
||||
return false;
|
||||
}if (this.line.indexOf ("[MO") == 0) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.readMolecularOrbital ();
|
||||
return false;
|
||||
}return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.finalizeReaderASCR ();
|
||||
if (this.nOrbitals > 0) this.setMOs ("eV");
|
||||
if (this.debugging) JU.Logger.debug (this.orbitals.size () + " molecular orbitals read");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readHeader",
|
||||
function () {
|
||||
this.moData.put ("isNormalized", Boolean.TRUE);
|
||||
while (this.rd () != null && this.line.length > 0) {
|
||||
this.moData.put ("calculationType", "?");
|
||||
var tokens = this.getTokens ();
|
||||
tokens[0] = tokens[0].substring (0, 1).toLowerCase () + tokens[0].substring (1, tokens[0].length);
|
||||
var str = "";
|
||||
for (var i = 1; i < tokens.length; i++) str += (i == 1 ? "" : " ") + tokens[i].toLowerCase ();
|
||||
|
||||
this.moData.put (tokens[0], str);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
while (this.getLine ()) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 0) continue;
|
||||
var sym = tokens[0];
|
||||
var atNo = this.parseIntStr (sym);
|
||||
this.setAtomCoordScaled (null, tokens, 1, 0.5291772).elementSymbol = (atNo == -2147483648 ? sym : J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (atNo));
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBonds",
|
||||
function () {
|
||||
while (this.getLine ()) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 0) continue;
|
||||
var atomIndex1 = this.parseIntStr (tokens[0]);
|
||||
var atomIndex2 = this.parseIntStr (tokens[1]);
|
||||
var order = this.parseIntStr (tokens[2]);
|
||||
this.asc.addBond ( new J.adapter.smarter.Bond (atomIndex1 - 1, atomIndex2 - 1, order));
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtomicOrbitalOrder",
|
||||
function () {
|
||||
while (this.getLine ()) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 0) continue;
|
||||
var data = this.line.substring (9).trim ().toLowerCase ();
|
||||
var isOK = false;
|
||||
switch (tokens.length - 1) {
|
||||
case 3:
|
||||
case 4:
|
||||
isOK = true;
|
||||
break;
|
||||
case 5:
|
||||
isOK = (tokens[0].equals ("DOrbitals") && this.getDFMap ("DS", data, 3, J.adapter.readers.quantum.WebMOReader.DS_LIST, 99));
|
||||
break;
|
||||
case 6:
|
||||
isOK = (tokens[0].equals ("DOrbitals") && this.getDFMap ("DC", data, 4, J.adapter.readers.quantum.WebMOReader.DC_LIST, 2));
|
||||
break;
|
||||
case 7:
|
||||
isOK = (tokens[0].equals ("FOrbitals") && this.getDFMap ("FS", data, 5, J.adapter.readers.quantum.WebMOReader.FS_LIST, 99));
|
||||
break;
|
||||
case 10:
|
||||
isOK = (tokens[0].equals ("FOrbitals") && this.getDFMap ("FC", data, 6, J.adapter.readers.quantum.WebMOReader.FC_LIST, 3));
|
||||
break;
|
||||
}
|
||||
if (!isOK) {
|
||||
JU.Logger.error ("atomic orbital order is unrecognized -- skipping reading of MOs due to line: " + this.line);
|
||||
this.orbitals = null;
|
||||
}}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getLine",
|
||||
function () {
|
||||
return (this.rd () != null && (this.line.length == 0 || this.line.charAt (0) != '['));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readGaussianBasis",
|
||||
function () {
|
||||
var sdata = new JU.Lst ();
|
||||
var gdata = new JU.Lst ();
|
||||
var atomNo = 1;
|
||||
var gaussianPtr = 0;
|
||||
while (this.getLine ()) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 0) continue;
|
||||
if (tokens.length != 1) throw new Exception ("Error reading GTOs: missing atom index");
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
atomNo = this.parseIntStr (tokens[0]);
|
||||
tokens = JU.PT.getTokens (this.rd ());
|
||||
var nGaussians = this.parseIntStr (tokens[1]);
|
||||
slater[0] = atomNo;
|
||||
slater[1] = J.adapter.readers.quantum.BasisFunctionReader.getQuantumShellTagID (tokens[0]);
|
||||
slater[2] = gaussianPtr + 1;
|
||||
slater[3] = nGaussians;
|
||||
for (var i = 0; i < nGaussians; i++) {
|
||||
var strData = JU.PT.getTokens (this.rd ());
|
||||
var nData = strData.length;
|
||||
var data = Clazz.newFloatArray (nData, 0);
|
||||
for (var d = 0; d < nData; d++) {
|
||||
data[d] = this.parseFloatStr (strData[d]);
|
||||
}
|
||||
gdata.addLast (data);
|
||||
gaussianPtr++;
|
||||
}
|
||||
sdata.addLast (slater);
|
||||
}
|
||||
var garray = JU.AU.newFloat2 (gaussianPtr);
|
||||
for (var i = 0; i < gaussianPtr; i++) {
|
||||
garray[i] = gdata.get (i);
|
||||
}
|
||||
this.moData.put ("shells", sdata);
|
||||
this.moData.put ("gaussians", garray);
|
||||
if (this.debugging) {
|
||||
JU.Logger.debug (sdata.size () + " slater shells read");
|
||||
JU.Logger.debug (garray.length + " gaussian primitives read");
|
||||
}this.asc.setCurrentModelInfo ("moData", this.moData);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSlaterBasis",
|
||||
function () {
|
||||
while (this.getLine ()) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length < 7) continue;
|
||||
this.addSlater (this.parseIntStr (tokens[0]), this.parseIntStr (tokens[1]), this.parseIntStr (tokens[2]), this.parseIntStr (tokens[3]), this.parseIntStr (tokens[4]), this.parseFloatStr (tokens[5]), this.parseFloatStr (tokens[6]));
|
||||
}
|
||||
this.setSlaters (false, false);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbital",
|
||||
function () {
|
||||
if (this.orbitals == null) {
|
||||
JU.Logger.error ("MOLECULAR ORBITALS SKIPPED");
|
||||
while (this.getLine ()) {
|
||||
}
|
||||
return;
|
||||
}var mo = new java.util.Hashtable ();
|
||||
var data = new JU.Lst ();
|
||||
var energy = this.parseFloatStr (this.rd ());
|
||||
var occupancy = this.parseFloatStr (this.rd ());
|
||||
while (this.getLine ()) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 0) {
|
||||
continue;
|
||||
}data.addLast (tokens[1]);
|
||||
}
|
||||
var coefs = Clazz.newFloatArray (data.size (), 0);
|
||||
for (var i = data.size (); --i >= 0; ) {
|
||||
coefs[i] = this.parseFloatStr (data.get (i));
|
||||
}
|
||||
mo.put ("energy", Float.$valueOf (energy));
|
||||
mo.put ("occupancy", Float.$valueOf (occupancy));
|
||||
mo.put ("coefficients", coefs);
|
||||
this.orbitals.addLast (mo);
|
||||
this.nOrbitals++;
|
||||
if (occupancy > 0) this.moData.put ("HOMO", Integer.$valueOf (this.nOrbitals));
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"DS_LIST", "NOT IMPLEMENTED IN THIS READER",
|
||||
"DC_LIST", "xx yy zz xy xz yz",
|
||||
"FS_LIST", "NOT IMPLEMENTED IN THIS READER",
|
||||
"FC_LIST", "xxx yyy zzz yyx xxy xxz zzx zzy yyz xyz");
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.AlchemyReader", ["java.lang.Character", "JU.PT", "J.adapter.smarter.Atom"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.isM3D = false;
|
||||
this.ac = 0;
|
||||
this.bondCount = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.simple, "AlchemyReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
this.rd ();
|
||||
if (this.line.indexOf ("ATOMS") < 0) {
|
||||
this.isM3D = true;
|
||||
this.rd ();
|
||||
}var tokens = this.getTokens ();
|
||||
this.ac = this.parseIntStr (tokens[0]);
|
||||
this.bondCount = this.parseIntStr (tokens[this.isM3D ? 1 : 2]);
|
||||
this.readAtoms ();
|
||||
this.readBonds ();
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
var pt = (this.isM3D ? 3 : 2);
|
||||
for (var i = this.ac; --i >= 0; ) {
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
var atom = new J.adapter.smarter.Atom ();
|
||||
atom.atomSerial = this.parseIntStr (tokens[0]);
|
||||
var name = tokens[1];
|
||||
if (!this.isM3D) {
|
||||
atom.atomName = name;
|
||||
atom.elementSymbol = name.substring (0, 1);
|
||||
var c1 = name.charAt (0);
|
||||
var c2 = ' ';
|
||||
var nChar = (name.length == 2 && (J.adapter.smarter.Atom.isValidSym2 (c1, c2 = Character.toLowerCase (name.charAt (1))) || name.equals ("Du")) ? 2 : 1);
|
||||
name = (nChar == 1 ? "" + c1 : "" + c1 + c2);
|
||||
}atom.elementSymbol = name;
|
||||
this.setAtomCoordTokens (atom, tokens, pt);
|
||||
atom.partialCharge = (tokens.length >= 6 ? this.parseFloatStr (tokens[pt + 3]) : 0);
|
||||
this.asc.addAtomWithMappedSerialNumber (atom);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBonds",
|
||||
function () {
|
||||
for (var i = this.bondCount; --i >= 0; ) {
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
var atomSerial1 = tokens[1];
|
||||
var atomSerial2 = tokens[2];
|
||||
var sOrder = (tokens.length < 4 ? "1" : tokens[3].toUpperCase ());
|
||||
var order = 0;
|
||||
switch (sOrder.charAt (0)) {
|
||||
default:
|
||||
case '1':
|
||||
case 'S':
|
||||
order = 1;
|
||||
break;
|
||||
case '2':
|
||||
case 'D':
|
||||
order = 2;
|
||||
break;
|
||||
case '3':
|
||||
case 'T':
|
||||
order = 3;
|
||||
break;
|
||||
case 'A':
|
||||
order = 515;
|
||||
break;
|
||||
case 'H':
|
||||
order = 2048;
|
||||
break;
|
||||
}
|
||||
this.asc.addNewBondFromNames (atomSerial1, atomSerial2, order);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.AmpacReader", ["JU.P3"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.ac = 0;
|
||||
this.freqAtom0 = -1;
|
||||
this.partialCharges = null;
|
||||
this.atomPositions = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.simple, "AmpacReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf ("CARTESIAN COORDINATES") >= 0) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.readCoordinates ();
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.indexOf ("NET ATOMIC CHARGES") >= 0) {
|
||||
this.readPartialCharges ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("VIBRATIONAL FREQUENCIES") >= 0) {
|
||||
this.readFrequencies ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCoordinates",
|
||||
function () {
|
||||
var haveFreq = (this.freqAtom0 >= 0);
|
||||
if (haveFreq) {
|
||||
this.atomPositions = new Array (this.ac);
|
||||
} else {
|
||||
this.asc.newAtomSet ();
|
||||
}this.rd ();
|
||||
this.ac = 0;
|
||||
while (this.rd () != null) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length < 5) break;
|
||||
if (haveFreq) {
|
||||
this.atomPositions[this.ac] = JU.P3.new3 (this.parseFloatStr (tokens[2]), this.parseFloatStr (tokens[3]), this.parseFloatStr (tokens[4]));
|
||||
} else {
|
||||
this.addAtomXYZSymName (tokens, 2, tokens[1], null);
|
||||
}this.ac++;
|
||||
}
|
||||
if (haveFreq) this.setPositions ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "setPositions",
|
||||
function () {
|
||||
var maxAtom = this.asc.ac;
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = this.freqAtom0; i < maxAtom; i++) {
|
||||
atoms[i].setT (this.atomPositions[i % this.ac]);
|
||||
atoms[i].partialCharge = this.partialCharges[i % this.ac];
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPartialCharges",
|
||||
function () {
|
||||
this.rd ();
|
||||
this.partialCharges = Clazz.newFloatArray (this.ac, 0);
|
||||
var tokens;
|
||||
for (var i = 0; i < this.ac; i++) {
|
||||
if (this.rd () == null || (tokens = this.getTokens ()).length < 4) break;
|
||||
this.partialCharges[i] = this.parseFloatStr (tokens[2]);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
while (this.rd () != null && this.line.indexOf ("FREQ :") < 0) {
|
||||
}
|
||||
while (this.line != null && this.line.indexOf ("FREQ :") >= 0) {
|
||||
var frequencies = this.getTokens ();
|
||||
while (this.rd () != null && this.line.indexOf ("IR I") < 0) {
|
||||
}
|
||||
var iAtom0 = this.asc.ac;
|
||||
if (this.vibrationNumber == 0) this.freqAtom0 = iAtom0;
|
||||
var frequencyCount = frequencies.length - 2;
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
for (var i = 0; i < frequencyCount; ++i) {
|
||||
ignore[i] = !this.doGetVibration (++this.vibrationNumber);
|
||||
if (ignore[i]) continue;
|
||||
this.asc.cloneLastAtomSet ();
|
||||
this.asc.setAtomSetName (frequencies[i + 2] + " cm^-1");
|
||||
this.asc.setAtomSetModelProperty ("Frequency", frequencies[i + 2] + " cm^-1");
|
||||
this.asc.setAtomSetModelProperty (".PATH", "Frequencies");
|
||||
}
|
||||
this.fillFrequencyData (iAtom0, this.ac, this.ac, ignore, false, 8, 9, null, 0);
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.CubeReader", ["JU.PT"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.ac = 0;
|
||||
this.isAngstroms = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.simple, "CubeReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
this.readTitleLines ();
|
||||
this.readAtomCountAndOrigin ();
|
||||
this.readLines (3);
|
||||
this.readAtoms ();
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readTitleLines",
|
||||
function () {
|
||||
if (this.rd ().indexOf ("#JVXL") == 0) while (this.rd ().indexOf ("#") == 0) {
|
||||
}
|
||||
this.checkCurrentLineForScript ();
|
||||
var name = this.line.trim ();
|
||||
this.rd ();
|
||||
this.checkCurrentLineForScript ();
|
||||
this.asc.setAtomSetName (name + " - " + this.line.trim ());
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtomCountAndOrigin",
|
||||
function () {
|
||||
this.rd ();
|
||||
this.isAngstroms = (this.line.indexOf ("ANGSTROMS") >= 0);
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens[0].charAt (0) == '+') tokens[0] = tokens[0].substring (1);
|
||||
this.ac = Math.abs (this.parseIntStr (tokens[0]));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
var f = (this.isAngstroms ? 1 : 0.5291772);
|
||||
for (var i = 0; i < this.ac; ++i) {
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
this.setAtomCoordScaled (null, tokens, 2, f).elementNumber = this.parseIntStr (tokens[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.FoldingXyzReader", ["java.util.Hashtable", "JU.PT", "J.adapter.smarter.Atom"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.simple, "FoldingXyzReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
if (this.asc.bondCount > 0) this.asc.setNoAutoBond ();
|
||||
this.isTrajectory = false;
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
var next = Clazz.newIntArray (-1, [0]);
|
||||
var token = JU.PT.parseTokenNext (this.line, next);
|
||||
if (token == null) return true;
|
||||
var addAtoms = this.doGetModel (++this.modelNumber, null);
|
||||
var modelAtomCount = this.parseIntStr (token);
|
||||
if (addAtoms) {
|
||||
this.asc.newAtomSet ();
|
||||
var tokens = this.getTokens ();
|
||||
this.asc.setAtomSetName (tokens.length == 2 ? "Protein " + tokens[1] : this.line.substring (next[0]).trim ());
|
||||
}var readLine = this.readAtoms (modelAtomCount + 1, addAtoms);
|
||||
this.continuing = !addAtoms || !this.isLastModel (this.modelNumber);
|
||||
return readLine;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (ac, addAtoms) {
|
||||
var htBondCounts = new java.util.Hashtable ();
|
||||
var bonds = new Array (ac);
|
||||
var haveAtomTypes = true;
|
||||
var checking = true;
|
||||
var lastAtom = null;
|
||||
var readNextLine = true;
|
||||
for (var i = 0; i < ac; i++) {
|
||||
this.discardLinesUntilNonBlank ();
|
||||
if (this.line == null) break;
|
||||
var tokens = this.getTokens ();
|
||||
var sIndex = tokens[0];
|
||||
if (sIndex.equals (lastAtom)) {
|
||||
readNextLine = false;
|
||||
break;
|
||||
}lastAtom = sIndex;
|
||||
if (!addAtoms) continue;
|
||||
var atom = new J.adapter.smarter.Atom ();
|
||||
atom.atomName = tokens[1];
|
||||
atom.elementSymbol = this.getElement (tokens[1]);
|
||||
atom.atomSerial = this.parseIntStr (sIndex);
|
||||
if (!this.filterAtom (atom, i)) continue;
|
||||
this.setAtomCoordTokens (atom, tokens, 2);
|
||||
this.asc.addAtomWithMappedSerialNumber (atom);
|
||||
var n = tokens.length - 5;
|
||||
bonds[i] = new Array (n + 1);
|
||||
bonds[i][n] = sIndex;
|
||||
for (var j = 0; j < n; j++) {
|
||||
var t = tokens[j + 5];
|
||||
var i2 = this.parseIntStr (t);
|
||||
bonds[i][j] = t;
|
||||
if (checking) {
|
||||
if (n == 0 || t.equals (sIndex) || i2 <= 0 || i2 > ac) {
|
||||
haveAtomTypes = (n > 0);
|
||||
checking = false;
|
||||
} else {
|
||||
var count = htBondCounts.get (t);
|
||||
if (count == null) htBondCounts.put (t, count = Clazz.newIntArray (1, 0));
|
||||
if (++count[0] > 10) haveAtomTypes = !(checking = false);
|
||||
}}}
|
||||
}
|
||||
if (addAtoms) {
|
||||
this.makeBonds (bonds, !checking && haveAtomTypes);
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
}return readNextLine;
|
||||
}, "~N,~B");
|
||||
Clazz.defineMethod (c$, "makeBonds",
|
||||
function (bonds, haveAtomTypes) {
|
||||
for (var i = bonds.length; --i >= 0; ) {
|
||||
var b = bonds[i];
|
||||
if (b == null) continue;
|
||||
var a1 = this.asc.getAtomFromName (b[b.length - 1]);
|
||||
var b0 = 0;
|
||||
if (haveAtomTypes) a1.atomName += "\0" + b[b0++];
|
||||
for (var j = b.length - 1; --j >= b0; ) {
|
||||
var a2 = this.asc.getAtomFromName (b[j]);
|
||||
if (a1.index < a2.index) this.asc.addNewBondWithOrderA (a1, a2, 1);
|
||||
}
|
||||
}
|
||||
}, "~A,~B");
|
||||
Clazz.defineMethod (c$, "getElement",
|
||||
function (name) {
|
||||
var n = name.length;
|
||||
switch (n) {
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
var c1 = name.charAt (0);
|
||||
var c2 = name.charAt (1);
|
||||
n = (J.adapter.smarter.Atom.isValidSym2 (c1, c2) || c1 == 'C' && c2 == 'L' ? 2 : 1);
|
||||
}
|
||||
return name.substring (0, n);
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.GhemicalMMReader", ["java.lang.Exception", "JU.PT"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.simple, "GhemicalMMReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.startsWith ("!Header")) {
|
||||
this.processHeader ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("!Info")) {
|
||||
this.processInfo ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("!Atoms")) {
|
||||
this.processAtoms ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("!Bonds")) {
|
||||
this.processBonds ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("!Coord")) {
|
||||
this.processCoord ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("!Charges")) {
|
||||
this.processCharges ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processHeader",
|
||||
function () {
|
||||
});
|
||||
Clazz.defineMethod (c$, "processInfo",
|
||||
function () {
|
||||
});
|
||||
Clazz.defineMethod (c$, "processAtoms",
|
||||
function () {
|
||||
var ac = this.parseIntAt (this.line, 6);
|
||||
for (var i = 0; i < ac; ++i) {
|
||||
if (this.asc.ac != i) throw new Exception ("GhemicalMMReader error #1");
|
||||
this.rd ();
|
||||
var atomIndex = this.parseIntStr (this.line);
|
||||
if (atomIndex != i) throw new Exception ("bad atom index in !Atomsexpected: " + i + " saw:" + atomIndex);
|
||||
var elementNumber = this.parseInt ();
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.elementNumber = elementNumber;
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "processBonds",
|
||||
function () {
|
||||
var bondCount = this.parseIntAt (this.line, 6);
|
||||
for (var i = 0; i < bondCount; ++i) {
|
||||
this.rd ();
|
||||
var atomIndex1 = this.parseIntStr (this.line);
|
||||
var atomIndex2 = this.parseInt ();
|
||||
var orderCode = this.parseToken ();
|
||||
var order = 0;
|
||||
switch (orderCode.charAt (0)) {
|
||||
case 'C':
|
||||
order = 515;
|
||||
break;
|
||||
case 'T':
|
||||
order = 3;
|
||||
break;
|
||||
case 'D':
|
||||
order = 2;
|
||||
break;
|
||||
case 'S':
|
||||
default:
|
||||
order = 1;
|
||||
}
|
||||
this.asc.addNewBondWithOrder (atomIndex1, atomIndex2, order);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "processCoord",
|
||||
function () {
|
||||
var atoms = this.asc.atoms;
|
||||
var ac = this.asc.ac;
|
||||
for (var i = 0; i < ac; ++i) this.setAtomCoordScaled (atoms[i], JU.PT.getTokens (this.rd ()), 1, 10);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "processCharges",
|
||||
function () {
|
||||
var atoms = this.asc.atoms;
|
||||
var ac = this.asc.ac;
|
||||
for (var i = 0; i < ac; ++i) {
|
||||
this.rd ();
|
||||
var atomIndex = this.parseIntStr (this.line);
|
||||
if (atomIndex != i) throw new Exception ("bad atom index in !Chargesexpected: " + i + " saw:" + atomIndex);
|
||||
atoms[i].partialCharge = this.parseFloat ();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.HyperChemReader", ["java.lang.Exception"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.atomIndex = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.simple, "HyperChemReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.length == 0 || this.line.charAt (0) == ';') return true;
|
||||
if (this.line.startsWith ("mol ")) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.processMol ();
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.startsWith ("atom ")) {
|
||||
this.processAtom ();
|
||||
return true;
|
||||
}if (this.line.startsWith ("endmol ")) {
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processMol",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
var molName = this.getMolName ();
|
||||
this.asc.setAtomSetName (molName);
|
||||
this.atomIndex = 0;
|
||||
this.baseAtomIndex = this.asc.ac;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getMolName",
|
||||
function () {
|
||||
this.parseTokenStr (this.line);
|
||||
this.parseToken ();
|
||||
return this.parseToken ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "processAtom",
|
||||
function () {
|
||||
var fileAtomNumber = this.parseIntAt (this.line, 5);
|
||||
if (fileAtomNumber - 1 != this.atomIndex) {
|
||||
throw new Exception ("bad atom number sequence ... expected:" + (this.atomIndex + 1) + " found:" + fileAtomNumber);
|
||||
}var atom = this.asc.addNewAtom ();
|
||||
this.parseToken ();
|
||||
atom.elementSymbol = this.parseToken ();
|
||||
this.parseToken ();
|
||||
this.parseToken ();
|
||||
atom.partialCharge = this.parseFloat ();
|
||||
this.setAtomCoordXYZ (atom, this.parseFloat (), this.parseFloat (), this.parseFloat ());
|
||||
var bondCount = this.parseInt ();
|
||||
for (var i = 0; i < bondCount; ++i) {
|
||||
var otherAtomNumber = this.parseInt ();
|
||||
var bondTypeToken = this.parseToken ();
|
||||
if (otherAtomNumber > this.atomIndex) continue;
|
||||
var bondOrder;
|
||||
switch (bondTypeToken.charAt (0)) {
|
||||
case 's':
|
||||
bondOrder = 1;
|
||||
break;
|
||||
case 'd':
|
||||
bondOrder = 2;
|
||||
break;
|
||||
case 't':
|
||||
bondOrder = 3;
|
||||
break;
|
||||
case 'a':
|
||||
bondOrder = 515;
|
||||
break;
|
||||
default:
|
||||
throw new Exception ("unrecognized bond type:" + bondTypeToken + " atom #" + fileAtomNumber);
|
||||
}
|
||||
this.asc.addNewBondWithOrder (this.baseAtomIndex + this.atomIndex, this.baseAtomIndex + otherAtomNumber - 1, bondOrder);
|
||||
}
|
||||
++this.atomIndex;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,320 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader", "java.util.Hashtable", "JU.Lst", "$.P3", "$.P4", "$.V3"], "J.adapter.readers.simple.InputReader", ["java.lang.Exception", "$.Float", "JU.Measure", "$.PT", "$.Quat", "J.adapter.smarter.Atom", "$.Bond", "J.api.JmolAdapter", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.ac = 0;
|
||||
this.vAtoms = null;
|
||||
this.atomMap = null;
|
||||
this.tokens = null;
|
||||
this.isJmolZformat = false;
|
||||
this.lineBuffer = null;
|
||||
this.symbolicMap = null;
|
||||
this.isMopac = false;
|
||||
this.isHeader = true;
|
||||
this.firstLine = true;
|
||||
this.pt0 = null;
|
||||
this.v1 = null;
|
||||
this.v2 = null;
|
||||
this.plane1 = null;
|
||||
this.plane2 = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.simple, "InputReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.vAtoms = new JU.Lst ();
|
||||
this.atomMap = new java.util.Hashtable ();
|
||||
this.lineBuffer = new JU.Lst ();
|
||||
this.symbolicMap = new java.util.Hashtable ();
|
||||
this.pt0 = new JU.P3 ();
|
||||
this.v1 = new JU.V3 ();
|
||||
this.v2 = new JU.V3 ();
|
||||
this.plane1 = new JU.P4 ();
|
||||
this.plane2 = new JU.P4 ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.firstLine) {
|
||||
this.firstLine = false;
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 3 && this.parseIntStr (tokens[0]) > 0 && this.parseIntStr (tokens[1]) > 0 && this.parseIntStr (tokens[2]) > 0) {
|
||||
this.readConFile ();
|
||||
return this.continuing = false;
|
||||
}}this.cleanLine ();
|
||||
if (this.line.length <= 2) this.isHeader = false;
|
||||
if (this.line.startsWith ("#") || this.line.startsWith ("*") || this.isMopac && this.isHeader) {
|
||||
if (this.line.startsWith ("#ZMATRIX")) this.isJmolZformat = this.line.toUpperCase ().indexOf ("GAUSSIAN") < 0 && !(this.isMopac = (this.line.toUpperCase ().indexOf ("MOPAC") >= 0));
|
||||
this.checkCurrentLineForScript ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("#") >= 0) this.line = this.line.substring (0, this.line.indexOf ("#"));
|
||||
if (this.line.indexOf (":") >= 0) return true;
|
||||
if (this.line.contains ("$molecule")) {
|
||||
this.rd ();
|
||||
return this.readBlock ("$end");
|
||||
}if (this.line.startsWith ("$")) return true;
|
||||
if (this.line.contains ("%mem")) {
|
||||
this.discardLinesUntilBlank ();
|
||||
this.discardLinesUntilBlank ();
|
||||
this.rd ();
|
||||
return this.readBlock (null);
|
||||
}if (this.line.contains ("ATOMS cartesian")) {
|
||||
return this.readBlock ("END");
|
||||
}if (this.line.contains ("geometry units angstroms")) {
|
||||
return this.readBlock ("end");
|
||||
}if (this.line.contains ("&zmat")) {
|
||||
return this.readBlock ("&");
|
||||
}if (this.line.contains ("%coords")) {
|
||||
this.discardLinesUntilContains ("coords");
|
||||
return this.readBlock ("end");
|
||||
}if (this.line.contains ("GEOM=PQS")) {
|
||||
return this.readBlock ("BASIS");
|
||||
}if (this.line.contains ("geometry={")) {
|
||||
this.readLines (2);
|
||||
return this.readBlock ("}");
|
||||
}this.tokens = this.getTokens ();
|
||||
if (this.tokens.length > 10) return this.readVFI ();
|
||||
switch (this.tokens.length) {
|
||||
case 1:
|
||||
if (this.tokens[0].indexOf ("=") < 0) {
|
||||
this.lineBuffer.clear ();
|
||||
break;
|
||||
}this.tokens = JU.PT.split (this.tokens[0], "=");
|
||||
case 2:
|
||||
if (this.parseIntStr (this.line) > 0 && this.parseInt () >= 0) {
|
||||
this.readCFI ();
|
||||
return (this.continuing = false);
|
||||
}this.getSymbolic ();
|
||||
return true;
|
||||
case 10:
|
||||
if (this.tokens[0].equals ("0")) return (this.continuing = false);
|
||||
if (this.tokens[1].indexOf (".") < 0) return true;
|
||||
if (this.lineBuffer.size () > 0 && this.lineBuffer.get (this.lineBuffer.size () - 1).length < 8) this.lineBuffer.clear ();
|
||||
break;
|
||||
}
|
||||
this.lineBuffer.addLast (this.tokens);
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readConFile",
|
||||
function () {
|
||||
this.rd ();
|
||||
var map = new java.util.Hashtable ();
|
||||
var lstTokens = new JU.Lst ();
|
||||
var n = 0;
|
||||
while (this.rd () != null && this.line.length > 40) {
|
||||
n++;
|
||||
var tokens = this.getTokens ();
|
||||
lstTokens.addLast (tokens);
|
||||
map.put (tokens[1], this.addAtomXYZSymName (tokens, 2, tokens[0], null));
|
||||
}
|
||||
for (var i = 0; i < n; i++) {
|
||||
var tokens = lstTokens.get (i);
|
||||
var a = map.get (tokens[1]);
|
||||
for (var j = 6; j < tokens.length; j++) this.asc.addBond ( new J.adapter.smarter.Bond (a.index, map.get (tokens[j]).index, 1));
|
||||
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCFI",
|
||||
function () {
|
||||
this.tokens = this.getTokens ();
|
||||
var nAtoms = Clazz.floatToInt (this.getValue (0));
|
||||
var nBonds = Clazz.floatToInt (this.getValue (1));
|
||||
var map = new java.util.Hashtable ();
|
||||
for (var i = 0; i < nAtoms; i++) {
|
||||
this.tokens = JU.PT.getTokens (this.rd ());
|
||||
if (this.tokens[1].equals ("0") || this.tokens[1].equals ("2")) continue;
|
||||
var a = this.addAtomXYZSymName (this.tokens, 2, null, null);
|
||||
a.elementNumber = Clazz.floatToShort (this.getValue (1));
|
||||
map.put (this.tokens[0], a);
|
||||
}
|
||||
var bonds = this.fillFloatArray (null, 0, Clazz.newFloatArray (nBonds * 2, 0));
|
||||
var orders = this.fillFloatArray (null, 0, Clazz.newFloatArray (nBonds, 0));
|
||||
for (var i = 0, pt = 0; i < nBonds; i++) this.asc.addBond ( new J.adapter.smarter.Bond (map.get ("" + Clazz.floatToInt (bonds[pt++])).index, map.get ("" + Clazz.floatToInt (bonds[pt++])).index, Clazz.floatToInt (orders[i])));
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "readVFI",
|
||||
function () {
|
||||
var map = new java.util.Hashtable ();
|
||||
var bonds = new JU.Lst ();
|
||||
while (this.tokens != null && this.tokens.length > 0) {
|
||||
for (var i = this.tokens.length; --i >= 11; ) bonds.addLast ( Clazz.newArray (-1, [this.tokens[3], this.tokens[i]]));
|
||||
|
||||
var id = this.tokens[3];
|
||||
this.tokens = (this.tokens[2].equals ("0") ? Clazz.newArray (-1, [this.tokens[4]]) : this.tokens[1].equals ("0") ? Clazz.newArray (-1, [this.tokens[4], this.tokens[2], this.tokens[5]]) : this.tokens[0].equals ("0") ? Clazz.newArray (-1, [this.tokens[4], this.tokens[2], this.tokens[5], this.tokens[1], this.tokens[7]]) : Clazz.newArray (-1, [this.tokens[4], this.tokens[2], this.tokens[5], this.tokens[1], this.tokens[7], this.tokens[0], this.tokens[9]]));
|
||||
var atom = this.getAtom ();
|
||||
map.put (id, atom);
|
||||
this.tokens = JU.PT.getTokens (this.rd ());
|
||||
}
|
||||
for (var i = bonds.size (); --i >= 0; ) {
|
||||
var b = bonds.get (i);
|
||||
this.asc.addBond ( new J.adapter.smarter.Bond (map.get (b[0]).index, map.get (b[1]).index, 1));
|
||||
}
|
||||
return (this.continuing = false);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBlock",
|
||||
function (strEnd) {
|
||||
this.lineBuffer.clear ();
|
||||
while (this.rd () != null && this.cleanLine () != null && (strEnd == null ? this.line.length > 0 : this.line.indexOf (strEnd) < 0)) this.lineBuffer.addLast (this.getTokens ());
|
||||
|
||||
return (this.continuing = false);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "cleanLine",
|
||||
function () {
|
||||
this.line = this.line.$replace (',', ' ');
|
||||
var pt1;
|
||||
var pt2;
|
||||
while ((pt1 = this.line.indexOf ('(')) >= 0 && (pt2 = this.line.indexOf ('(', pt1)) >= 0) this.line = this.line.substring (0, pt1) + " " + this.line.substring (pt2 + 1);
|
||||
|
||||
return (this.line = this.line.trim ());
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
var firstLine = 0;
|
||||
for (var i = firstLine; i < this.lineBuffer.size (); i++) if ((this.tokens = this.lineBuffer.get (i)).length > 0) this.getAtom ();
|
||||
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "getSymbolic",
|
||||
function () {
|
||||
if (this.symbolicMap.containsKey (this.tokens[0])) return;
|
||||
var f = this.parseFloatStr (this.tokens[1]);
|
||||
this.symbolicMap.put (this.tokens[0], Float.$valueOf (f));
|
||||
JU.Logger.info ("symbolic " + this.tokens[0] + " = " + f);
|
||||
});
|
||||
Clazz.defineMethod (c$, "getAtom",
|
||||
function () {
|
||||
var atom = new J.adapter.smarter.Atom ();
|
||||
var element = this.tokens[0];
|
||||
var i = element.length;
|
||||
while (--i >= 0 && JU.PT.isDigit (element.charAt (i))) {
|
||||
}
|
||||
if (++i == 0) element = J.api.JmolAdapter.getElementSymbol (this.parseIntStr (element));
|
||||
if (i == 0 || i == element.length) {
|
||||
atom.atomName = element + (this.ac + 1);
|
||||
} else {
|
||||
atom.atomName = element;
|
||||
element = element.substring (0, i);
|
||||
}if (this.isMopac && i != this.tokens[0].length) element = this.tokens[0].substring (i) + element;
|
||||
this.parseAtomTokens (atom, element);
|
||||
return atom;
|
||||
});
|
||||
Clazz.defineMethod (c$, "parseAtomTokens",
|
||||
function (atom, element) {
|
||||
this.setElementAndIsotope (atom, element);
|
||||
if (this.tokens.length > 5 && this.tokens[1].indexOf (".") >= 0) {
|
||||
var t = this.tokens;
|
||||
var l = t.length;
|
||||
this.tokens = (t[l - 3].equals ("0") ? Clazz.newArray (-1, [t[0]]) : t[l - 2].equals ("0") ? Clazz.newArray (-1, [t[0], t[l - 3], t[1]]) : t[l - 1].equals ("0") ? Clazz.newArray (-1, [t[0], t[l - 3], t[1], t[l - 2], t[3]]) : Clazz.newArray (-1, [t[0], t[l - 3], t[1], t[l - 2], t[3], t[l - 1], t[5]]));
|
||||
}var ia = this.getAtomIndex (1);
|
||||
var bondOrder = 0;
|
||||
switch (this.tokens.length) {
|
||||
case 8:
|
||||
case 6:
|
||||
atom = this.getAtomGeneral (atom, ia, bondOrder = Clazz.floatToInt (this.getValue (this.tokens.length - 1)));
|
||||
break;
|
||||
case 5:
|
||||
if (this.tokens[1].equals ("0")) {
|
||||
atom.set (this.getValue (2), this.getValue (3), this.getValue (4));
|
||||
break;
|
||||
}case 7:
|
||||
atom = this.getAtomGeneral (atom, ia, 0);
|
||||
break;
|
||||
case 4:
|
||||
if (this.getAtomIndex (1) < 0) {
|
||||
atom.set (this.getValue (1), this.getValue (2), this.getValue (3));
|
||||
break;
|
||||
}bondOrder = Clazz.floatToInt (this.getValue (3));
|
||||
case 3:
|
||||
if (this.ac != 1 || (ia = this.getAtomIndex (1)) != 0) {
|
||||
atom = null;
|
||||
} else {
|
||||
atom.set (this.getValue (2), 0, 0);
|
||||
}break;
|
||||
case 1:
|
||||
if (this.ac != 0) atom = null;
|
||||
else atom.set (0, 0, 0);
|
||||
break;
|
||||
default:
|
||||
atom = null;
|
||||
}
|
||||
if (atom == null) throw new Exception ("bad Z-Matrix line");
|
||||
this.vAtoms.addLast (atom);
|
||||
this.atomMap.put (atom.atomName, Integer.$valueOf (this.ac++));
|
||||
if (element.startsWith ("X") && J.api.JmolAdapter.getElementNumber (element) < 1) {
|
||||
JU.Logger.info ("#dummy atom ignored: atom " + this.ac + " - " + atom.atomName);
|
||||
} else {
|
||||
this.asc.addAtom (atom);
|
||||
this.setAtomCoord (atom);
|
||||
JU.Logger.info (atom.atomName + " " + atom.x + " " + atom.y + " " + atom.z);
|
||||
if (bondOrder < 0 || this.isJmolZformat && bondOrder > 0) this.asc.addBond ( new J.adapter.smarter.Bond (atom.index, this.vAtoms.get (ia).index, Math.abs (bondOrder)));
|
||||
}}, "J.adapter.smarter.Atom,~S");
|
||||
Clazz.defineMethod (c$, "getAtomGeneral",
|
||||
function (atom, ia, bondOrder) {
|
||||
var ib;
|
||||
var ic;
|
||||
if (this.tokens.length < 7 && this.ac != 2 || (ib = this.getAtomIndex (3)) < 0 || (ic = (this.tokens.length < 7 ? -2 : this.getAtomIndex (5))) == -1) {
|
||||
return null;
|
||||
}var d = this.getValue (2);
|
||||
var theta1 = this.getValue (4);
|
||||
var theta2 = (this.tokens.length < 7 ? 3.4028235E38 : this.getValue (6));
|
||||
if (this.tokens.length == 8 && !this.isJmolZformat && !this.isMopac && bondOrder == 1) d = -Math.abs (d);
|
||||
return atom = this.setAtom (atom, ia, ib, ic, d, theta1, theta2);
|
||||
}, "J.adapter.smarter.Atom,~N,~N");
|
||||
Clazz.defineMethod (c$, "getSymbolic",
|
||||
function (key) {
|
||||
var isNeg = key.startsWith ("-");
|
||||
var F = this.symbolicMap.get (isNeg ? key.substring (1) : key);
|
||||
if (F == null) return NaN;
|
||||
var f = F.floatValue ();
|
||||
return (isNeg ? -f : f);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getValue",
|
||||
function (i) {
|
||||
var f = this.getSymbolic (this.tokens[i]);
|
||||
if (Float.isNaN (f)) {
|
||||
f = this.parseFloatStr (this.tokens[i]);
|
||||
if (Float.isNaN (f)) throw new Exception ("Bad Z-matrix value: " + this.tokens[i]);
|
||||
}return f;
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "getAtomIndex",
|
||||
function (i) {
|
||||
var name;
|
||||
if (i >= this.tokens.length || (name = this.tokens[i]).indexOf (".") >= 0 || !JU.PT.isLetterOrDigit (name.charAt (0))) return -1;
|
||||
var ia = this.parseIntStr (name);
|
||||
if (ia <= 0 || name.length != ("" + ia).length) {
|
||||
var I = this.atomMap.get (name);
|
||||
if (I == null) {
|
||||
for (i = this.vAtoms.size (); --i >= 0; ) {
|
||||
var atom = this.vAtoms.get (i);
|
||||
if (atom.atomName.startsWith (name) && atom.atomName.length > name.length && JU.PT.isDigit (atom.atomName.charAt (name.length))) {
|
||||
I = this.atomMap.get (atom.atomName);
|
||||
break;
|
||||
}}
|
||||
}if (I == null) ia = -1;
|
||||
else ia = I.intValue ();
|
||||
} else {
|
||||
ia--;
|
||||
}return ia;
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "setAtom",
|
||||
function (atom, ia, ib, ic, d, theta1, theta2) {
|
||||
if (Float.isNaN (theta1) || Float.isNaN (theta2)) return null;
|
||||
this.pt0.setT (this.vAtoms.get (ia));
|
||||
this.v1.sub2 (this.vAtoms.get (ib), this.pt0);
|
||||
this.v1.normalize ();
|
||||
if (theta2 == 3.4028235E38) {
|
||||
this.v2.set (0, 0, 1);
|
||||
(JU.Quat.newVA (this.v2, theta1)).transform2 (this.v1, this.v2);
|
||||
} else if (d >= 0) {
|
||||
this.v2.sub2 (this.vAtoms.get (ic), this.pt0);
|
||||
this.v2.cross (this.v1, this.v2);
|
||||
(JU.Quat.newVA (this.v2, theta1)).transform2 (this.v1, this.v2);
|
||||
(JU.Quat.newVA (this.v1, -theta2)).transform2 (this.v2, this.v2);
|
||||
} else {
|
||||
JU.Measure.getPlaneThroughPoint (this.setAtom (atom, ia, ib, ic, -d, theta1, 0), this.v1, this.plane1);
|
||||
JU.Measure.getPlaneThroughPoint (this.setAtom (atom, ia, ic, ib, -d, theta2, 0), this.v1, this.plane2);
|
||||
var list = JU.Measure.getIntersectionPP (this.plane1, this.plane2);
|
||||
if (list.size () == 0) return null;
|
||||
this.pt0.setT (list.get (0));
|
||||
d = Math.sqrt (d * d - this.pt0.distanceSquared (this.vAtoms.get (ia))) * Math.signum (theta1) * Math.signum (theta2);
|
||||
this.v2.setT (list.get (1));
|
||||
}atom.scaleAdd2 (d, this.v2, this.pt0);
|
||||
return atom;
|
||||
}, "J.adapter.smarter.Atom,~N,~N,~N,~N,~N,~N");
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.JSONReader", ["JU.P3", "$.PT", "J.adapter.smarter.Bond", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.scale = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.simple, "JSONReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.asc.setCollectionName ("JSON");
|
||||
this.asc.newAtomSet ();
|
||||
var s = "";
|
||||
while (this.rd () != null) s += this.line;
|
||||
|
||||
s = JU.PT.replaceAllCharacters (s, "\" ", "").$replace (',', ':');
|
||||
if (s.contains ("_is2D:true")) this.set2D ();
|
||||
if (s.contains ("_scale:")) this.getScaling (this.getSection (s, "_scale", false));
|
||||
s = JU.PT.replaceAllCharacters (s, "}", "").$replace (',', ':');
|
||||
this.readAtoms (this.getSection (s, "a", true));
|
||||
this.readBonds (this.getSection (s, "b", true));
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getScaling",
|
||||
function (s) {
|
||||
var xyz = JU.PT.split (s[0], ":");
|
||||
this.scale = JU.P3.new3 (1, 1, 1);
|
||||
for (var j = 0; j < xyz.length; j += 2) if (xyz[j].length == 1) switch (xyz[j].charAt (0)) {
|
||||
case 'x':
|
||||
this.scale.x = this.parseFloatStr (xyz[j + 1]);
|
||||
break;
|
||||
case 'y':
|
||||
this.scale.y = this.parseFloatStr (xyz[j + 1]);
|
||||
break;
|
||||
case 'z':
|
||||
this.scale.z = this.parseFloatStr (xyz[j + 1]);
|
||||
break;
|
||||
}
|
||||
|
||||
JU.Logger.info ("scale set to " + this.scale);
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "getSection",
|
||||
function (json, key, isArray) {
|
||||
var a = JU.PT.split (json, key + ":" + (isArray ? "[" : "") + "{");
|
||||
if (a.length < 2) return a;
|
||||
var data = a[1];
|
||||
data = data.substring (0, data.indexOf ((isArray ? "]" : "}"))) + ":";
|
||||
return JU.PT.split (data, "{");
|
||||
}, "~S,~S,~B");
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (atoms) {
|
||||
for (var i = 0; i < atoms.length; ++i) {
|
||||
var lxyz = JU.PT.split (atoms[i], ":");
|
||||
var atom = this.asc.addNewAtom ();
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var z = 0;
|
||||
var l = "C";
|
||||
for (var j = 0; j < lxyz.length; j += 2) if (lxyz[j].length == 1) switch (lxyz[j].charAt (0)) {
|
||||
case 'x':
|
||||
x = this.parseFloatStr (lxyz[j + 1]);
|
||||
break;
|
||||
case 'y':
|
||||
y = this.parseFloatStr (lxyz[j + 1]);
|
||||
break;
|
||||
case 'z':
|
||||
z = this.parseFloatStr (lxyz[j + 1]);
|
||||
break;
|
||||
case 'l':
|
||||
l = lxyz[j + 1];
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.scale != null) {
|
||||
x /= this.scale.x;
|
||||
y /= this.scale.y;
|
||||
z /= this.scale.z;
|
||||
}this.setAtomCoordXYZ (atom, x, y, z);
|
||||
atom.elementSymbol = l;
|
||||
}
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "readBonds",
|
||||
function (bonds) {
|
||||
for (var i = 0; i < bonds.length; ++i) {
|
||||
var beo = JU.PT.split (bonds[i], ":");
|
||||
var b = 0;
|
||||
var e = 0;
|
||||
var order = 1;
|
||||
for (var j = 0; j < beo.length; j += 2) if (beo[j].length == 1) switch (beo[j].charAt (0)) {
|
||||
case 'b':
|
||||
b = this.parseIntStr (beo[j + 1]);
|
||||
break;
|
||||
case 'e':
|
||||
e = this.parseIntStr (beo[j + 1]);
|
||||
break;
|
||||
case 'o':
|
||||
var o = Clazz.floatToInt (this.parseFloatStr (beo[j + 1]) * 2);
|
||||
switch (o) {
|
||||
case 0:
|
||||
continue;
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
order = Clazz.doubleToInt (o / 2);
|
||||
break;
|
||||
case 1:
|
||||
order = 33;
|
||||
break;
|
||||
case 3:
|
||||
order = 66;
|
||||
break;
|
||||
case 5:
|
||||
order = 97;
|
||||
break;
|
||||
default:
|
||||
order = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
this.asc.addBond ( new J.adapter.smarter.Bond (b, e, order));
|
||||
}
|
||||
}, "~A");
|
||||
});
|
||||
@@ -0,0 +1,58 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.JmeReader", ["JU.PT", "J.adapter.smarter.Bond"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.simple, "JmeReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.asc.setCollectionName ("JME");
|
||||
this.asc.newAtomSet ();
|
||||
this.line = this.rd ().$replace ('\t', ' ');
|
||||
this.checkCurrentLineForScript ();
|
||||
this.addJmolScript ("jmeString='" + this.line + "'");
|
||||
var ac = this.parseInt ();
|
||||
var bondCount = this.parseInt ();
|
||||
this.readAtoms (ac);
|
||||
this.readBonds (bondCount);
|
||||
this.set2D ();
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (ac) {
|
||||
for (var i = 0; i < ac; ++i) {
|
||||
var strAtom = this.parseToken ();
|
||||
var atom = this.asc.addNewAtom ();
|
||||
this.setAtomCoordXYZ (atom, this.parseFloat (), this.parseFloat (), 0);
|
||||
var indexColon = strAtom.indexOf (':');
|
||||
var elementSymbol = (indexColon > 0 ? strAtom.substring (0, indexColon) : strAtom);
|
||||
if (elementSymbol.indexOf ("+") >= 0) {
|
||||
elementSymbol = JU.PT.trim (elementSymbol, "+");
|
||||
atom.formalCharge = 1;
|
||||
} else if (elementSymbol.indexOf ("-") >= 0) {
|
||||
elementSymbol = JU.PT.trim (elementSymbol, "-");
|
||||
atom.formalCharge = -1;
|
||||
}atom.elementSymbol = elementSymbol;
|
||||
}
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readBonds",
|
||||
function (bondCount) {
|
||||
for (var i = 0; i < bondCount; ++i) {
|
||||
var atomIndex1 = this.parseInt () - 1;
|
||||
var atomIndex2 = this.parseInt () - 1;
|
||||
var order = this.parseInt ();
|
||||
switch (order) {
|
||||
default:
|
||||
continue;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
break;
|
||||
case -1:
|
||||
order = 1025;
|
||||
break;
|
||||
case -2:
|
||||
order = 1041;
|
||||
break;
|
||||
}
|
||||
this.asc.addBond ( new J.adapter.smarter.Bond (atomIndex1, atomIndex2, order));
|
||||
}
|
||||
}, "~N");
|
||||
});
|
||||
@@ -0,0 +1,110 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.readers.simple.InputReader"], "J.adapter.readers.simple.MopacArchiveReader", ["java.lang.Float", "JU.P3", "J.adapter.smarter.Atom", "J.api.JmolAdapter"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.energyWithUnits = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.simple, "MopacArchiveReader", J.adapter.readers.simple.InputReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
if (!this.checkFilterKey ("NOCENTER")) this.doCentralize = true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.indexOf ("=") == 34) return this.getMyValue ();
|
||||
if (this.line.indexOf ("FINAL GEOMETRY OBTAINED") >= 0) return this.readCoordinates ();
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getMyValue",
|
||||
function () {
|
||||
if (this.line.substring (0, 10).trim ().length != 0) return true;
|
||||
var key = this.line.substring (0, 34).trim ().$replace (' ', '_');
|
||||
var value = this.line.substring (35).trim ();
|
||||
this.asc.setCurrentModelInfo (key, value);
|
||||
if (this.line.indexOf ("TOTAL ENERGY") >= 0) {
|
||||
var tokens = this.getTokens ();
|
||||
this.energyWithUnits = " (" + tokens[3] + " " + tokens[4] + ")";
|
||||
this.asc.setAtomSetEnergy (tokens[3], this.parseFloatStr (tokens[3]));
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCoordinates",
|
||||
function () {
|
||||
this.rd ();
|
||||
this.line = this.rd ().trim ();
|
||||
this.asc.setAtomSetName (this.line + (this.energyWithUnits == null ? "" : this.energyWithUnits));
|
||||
this.rd ();
|
||||
var atom = null;
|
||||
var sym = null;
|
||||
this.setFractionalCoordinates (false);
|
||||
while (this.rd () != null && this.line.length >= 50) {
|
||||
this.vAtoms.addLast (atom = new J.adapter.smarter.Atom ());
|
||||
atom.x = this.parseFloatRange (this.line, 5, 18);
|
||||
atom.y = this.parseFloatRange (this.line, 21, 34);
|
||||
atom.z = this.parseFloatRange (this.line, 37, 50);
|
||||
if (this.line.length > 58 && this.line.charAt (58) != ' ') {
|
||||
switch (this.ac) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
atom.sub (this.vAtoms.get (0));
|
||||
break;
|
||||
case 2:
|
||||
this.setAtom (atom, 0, 1, 0, atom.x, atom.y, 3.4028235E38);
|
||||
break;
|
||||
default:
|
||||
this.setAtom (atom, this.parseIntRange (this.line, 54, 59) - 1, this.parseIntRange (this.line, 60, 65) - 1, this.parseIntRange (this.line, 66, 71) - 1, atom.x, atom.y, atom.z);
|
||||
}
|
||||
}sym = this.line.substring (1, 3).trim ();
|
||||
atom.elementSymbol = sym;
|
||||
if (!sym.equals ("Tv")) {
|
||||
this.ac++;
|
||||
if (this.line.length >= 84) atom.partialCharge = this.parseFloatRange (this.line, 76, 84);
|
||||
if (J.api.JmolAdapter.getElementNumber (sym) != 0) this.asc.addAtom (atom);
|
||||
this.setAtomCoord (atom);
|
||||
}}
|
||||
if (sym.equals ("Tv")) {
|
||||
this.setSpaceGroupName ("P1");
|
||||
var nTv = this.vAtoms.size () - this.ac;
|
||||
for (var i = nTv; i < 3; i++) this.vAtoms.addLast ( new J.adapter.smarter.Atom ());
|
||||
|
||||
var xyz = Clazz.newFloatArray (9, 0);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var j = i * 3;
|
||||
atom = this.vAtoms.get (this.ac + i);
|
||||
if (!Float.isNaN (atom.x)) {
|
||||
xyz[j] = atom.x;
|
||||
xyz[j + 1] = atom.y;
|
||||
xyz[j + 2] = atom.z;
|
||||
}this.addExplicitLatticeVector (i, xyz, j);
|
||||
}
|
||||
for (var i = this.ac; --i >= 0; ) this.setAtomCoord (this.vAtoms.get (i));
|
||||
|
||||
var ptMax = JU.P3.new3 (-3.4028235E38, -3.4028235E38, -3.4028235E38);
|
||||
var ptMin = JU.P3.new3 (3.4028235E38, 3.4028235E38, 3.4028235E38);
|
||||
if (this.doCentralize) {
|
||||
for (var i = this.ac; --i >= 0; ) {
|
||||
atom = this.vAtoms.get (i);
|
||||
ptMax.x = Math.max (ptMax.x, atom.x);
|
||||
ptMax.y = Math.max (ptMax.y, atom.y);
|
||||
ptMax.z = Math.max (ptMax.z, atom.z);
|
||||
ptMin.x = Math.min (ptMin.x, atom.x);
|
||||
ptMin.y = Math.min (ptMin.y, atom.y);
|
||||
ptMin.z = Math.min (ptMin.z, atom.z);
|
||||
}
|
||||
var ptCenter = new JU.P3 ();
|
||||
switch (nTv) {
|
||||
case 3:
|
||||
ptCenter.x = 0.5;
|
||||
case 2:
|
||||
ptCenter.y = 0.5;
|
||||
case 1:
|
||||
ptCenter.z = 0.5;
|
||||
}
|
||||
ptCenter.scaleAdd2 (-0.5, ptMin, ptCenter);
|
||||
ptCenter.scaleAdd2 (-0.5, ptMax, ptCenter);
|
||||
for (var i = this.ac; --i >= 0; ) this.vAtoms.get (i).add (ptCenter);
|
||||
|
||||
}this.doCentralize = false;
|
||||
}return true;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,139 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.simple.MopacReader", ["java.lang.Exception", "$.Float", "JU.BS", "$.PT", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.chargesFound = false;
|
||||
this.haveHeader = false;
|
||||
this.mopacVersion = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.simple, "MopacReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
while (this.mopacVersion == 0) {
|
||||
this.discardLinesUntilContains ("MOPAC");
|
||||
if (this.line.indexOf ("2009") >= 0) this.mopacVersion = 2009;
|
||||
else if (this.line.indexOf ("6.") >= 0) this.mopacVersion = 6;
|
||||
else if (this.line.indexOf ("7.") >= 0) this.mopacVersion = 7;
|
||||
else if (this.line.indexOf ("93") >= 0) this.mopacVersion = 93;
|
||||
else if (this.line.indexOf ("2002") >= 0) this.mopacVersion = 2002;
|
||||
else if (this.line.indexOf ("MOPAC2") >= 0) this.mopacVersion = JU.PT.parseInt (this.line.substring (this.line.indexOf ("MOPAC2") + 5));
|
||||
}
|
||||
JU.Logger.info ("MOPAC version " + this.mopacVersion);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (!this.haveHeader) {
|
||||
if (this.line.trim ().equals ("CARTESIAN COORDINATES")) {
|
||||
this.processCoordinates ();
|
||||
this.asc.setAtomSetName ("Input Structure");
|
||||
return true;
|
||||
}this.haveHeader = this.line.startsWith (" ---");
|
||||
return true;
|
||||
}if (this.line.indexOf ("TOTAL ENERGY") >= 0) {
|
||||
this.processTotalEnergy ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("ATOMIC CHARGES") >= 0) {
|
||||
this.processAtomicCharges ();
|
||||
return true;
|
||||
}if (this.line.trim ().equals ("CARTESIAN COORDINATES")) {
|
||||
this.processCoordinates ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("ORIENTATION OF MOLECULE IN FORCE") >= 0) {
|
||||
this.processCoordinates ();
|
||||
this.asc.setAtomSetName ("Orientation in Force Field");
|
||||
return true;
|
||||
}if (this.line.indexOf ("NORMAL COORDINATE ANALYSIS") >= 0) {
|
||||
this.readFrequencies ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processTotalEnergy",
|
||||
function () {
|
||||
});
|
||||
Clazz.defineMethod (c$, "processAtomicCharges",
|
||||
function () {
|
||||
this.readLines (2);
|
||||
this.asc.newAtomSet ();
|
||||
this.baseAtomIndex = this.asc.ac;
|
||||
var expectedAtomNumber = 0;
|
||||
while (this.rd () != null) {
|
||||
var atomNumber = this.parseIntStr (this.line);
|
||||
if (atomNumber == -2147483648) break;
|
||||
++expectedAtomNumber;
|
||||
if (atomNumber != expectedAtomNumber) throw new Exception ("unexpected atom number in atomic charges");
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.elementSymbol = this.parseToken ();
|
||||
atom.partialCharge = this.parseFloat ();
|
||||
}
|
||||
this.chargesFound = true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processCoordinates",
|
||||
function () {
|
||||
if (!this.chargesFound) {
|
||||
this.asc.newAtomSet ();
|
||||
this.baseAtomIndex = this.asc.ac;
|
||||
} else {
|
||||
this.chargesFound = false;
|
||||
}var atoms = this.asc.atoms;
|
||||
var atomNumber;
|
||||
while (this.rd ().trim ().length == 0 || this.line.indexOf ("ATOM") >= 0) {
|
||||
}
|
||||
while (this.line != null) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 0 || (atomNumber = this.parseIntStr (tokens[0])) == -2147483648) break;
|
||||
var atom = atoms[this.baseAtomIndex + atomNumber - 1];
|
||||
if (atom == null) atom = this.asc.addNewAtom ();
|
||||
atom.atomSerial = atomNumber;
|
||||
this.setAtomCoordTokens (atom, tokens, 2);
|
||||
var elementSymbol = tokens[1];
|
||||
var atno = this.parseIntStr (elementSymbol);
|
||||
if (atno != -2147483648) elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (atno);
|
||||
atom.elementSymbol = elementSymbol;
|
||||
this.rd ();
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
var bsOK = new JU.BS ();
|
||||
var n0 = this.asc.iSet + 1;
|
||||
var tokens;
|
||||
var done = false;
|
||||
while (!done && this.rd () != null && this.line.indexOf ("DESCRIPTION") < 0 && this.line.indexOf ("MASS-WEIGHTED") < 0) if (this.line.toUpperCase ().indexOf ("ROOT") >= 0) {
|
||||
this.discardLinesUntilNonBlank ();
|
||||
tokens = this.getTokens ();
|
||||
if (Float.isNaN (JU.PT.parseFloatStrict (tokens[tokens.length - 1]))) {
|
||||
this.discardLinesUntilNonBlank ();
|
||||
tokens = this.getTokens ();
|
||||
}var frequencyCount = tokens.length;
|
||||
this.rd ();
|
||||
var iAtom0 = this.asc.ac;
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
var freq1 = JU.PT.parseFloatStrict (tokens[0]);
|
||||
var ignoreNegative = (freq1 < 0);
|
||||
for (var i = 0; i < frequencyCount; ++i) {
|
||||
ignore[i] = done || (done = (!ignoreNegative && JU.PT.parseFloatStrict (tokens[i]) < 1)) || !this.doGetVibration (++this.vibrationNumber);
|
||||
if (ignore[i]) continue;
|
||||
bsOK.set (this.vibrationNumber - 1);
|
||||
this.asc.cloneLastAtomSet ();
|
||||
}
|
||||
this.fillFrequencyData (iAtom0, ac, ac, ignore, false, 0, 0, null, 2);
|
||||
}
|
||||
var info = new Array (this.vibrationNumber);
|
||||
if (this.line.indexOf ("DESCRIPTION") < 0) this.discardLinesUntilContains ("DESCRIPTION");
|
||||
while (this.discardLinesUntilContains ("VIBRATION") != null) {
|
||||
tokens = this.getTokens ();
|
||||
var freqNo = this.parseIntStr (tokens[1]);
|
||||
tokens[0] = JU.PT.getTokens (this.rd ())[1];
|
||||
if (tokens[2].equals ("ATOM")) tokens[2] = null;
|
||||
info[freqNo - 1] = tokens;
|
||||
if (freqNo == this.vibrationNumber) break;
|
||||
}
|
||||
for (var i = this.vibrationNumber - 1; --i >= 0; ) if (info[i] == null) info[i] = info[i + 1];
|
||||
|
||||
for (var i = 0, n = n0; i < this.vibrationNumber; i++) {
|
||||
if (!bsOK.get (i)) continue;
|
||||
this.asc.iSet = n++;
|
||||
this.asc.setAtomSetFrequency (null, info[i][2], info[i][0], null);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.simple");
|
||||
Clazz.load (["J.adapter.readers.simple.FoldingXyzReader"], "J.adapter.readers.simple.TinkerReader", null, function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.simple, "TinkerReader", J.adapter.readers.simple.FoldingXyzReader);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.spartan");
|
||||
Clazz.load (["J.adapter.readers.spartan.SpartanInputReader"], "J.adapter.readers.spartan.OdysseyReader", null, function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.spartan, "OdysseyReader", J.adapter.readers.spartan.SpartanInputReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
var title = this.readInputRecords ();
|
||||
this.asc.setAtomSetName (title == null ? "Odyssey file" : title);
|
||||
this.continuing = false;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,450 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.spartan");
|
||||
Clazz.load (null, "J.adapter.readers.spartan.SpartanArchive", ["java.lang.Boolean", "$.Float", "java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "$.V3", "J.adapter.smarter.AtomSetCollectionReader", "$.Bond", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.modelCount = 0;
|
||||
this.modelAtomCount = 0;
|
||||
this.ac = 0;
|
||||
this.bondData = null;
|
||||
this.moCount = 0;
|
||||
this.coefCount = 0;
|
||||
this.shellCount = 0;
|
||||
this.gaussianCount = 0;
|
||||
this.endCheck = null;
|
||||
this.isSMOL = false;
|
||||
this.r = null;
|
||||
this.line = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.spartan, "SpartanArchive");
|
||||
Clazz.makeConstructor (c$,
|
||||
function (r, bondData, endCheck, smolAtomCount) {
|
||||
this.initialize (r, bondData);
|
||||
this.modelAtomCount = smolAtomCount;
|
||||
this.endCheck = endCheck;
|
||||
this.isSMOL = (endCheck != null);
|
||||
}, "J.adapter.readers.quantum.BasisFunctionReader,~S,~S,~N");
|
||||
Clazz.defineMethod (c$, "initialize",
|
||||
function (r, bondData) {
|
||||
this.r = r;
|
||||
r.moData.put ("isNormalized", Boolean.TRUE);
|
||||
r.moData.put ("energyUnits", "");
|
||||
this.bondData = bondData;
|
||||
}, "J.adapter.readers.quantum.BasisFunctionReader,~S");
|
||||
Clazz.defineMethod (c$, "readArchive",
|
||||
function (infoLine, haveGeometryLine, ac0, doAddAtoms) {
|
||||
this.modelAtomCount = this.setInfo (infoLine);
|
||||
this.line = (haveGeometryLine ? "GEOMETRY" : "");
|
||||
var haveMOData = false;
|
||||
var skipping = false;
|
||||
while (this.line != null) {
|
||||
if (this.line.equals ("GEOMETRY")) {
|
||||
if (!this.isSMOL && !this.r.doGetModel (++this.modelCount, null)) {
|
||||
this.readLine ();
|
||||
skipping = true;
|
||||
continue;
|
||||
}skipping = false;
|
||||
this.readAtoms (ac0, doAddAtoms);
|
||||
if (doAddAtoms && this.bondData.length > 0) this.addBonds (this.bondData, ac0);
|
||||
} else if (this.line.indexOf ("BASIS") == 0) {
|
||||
if (this.r.doReadMolecularOrbitals) {
|
||||
this.readBasis ();
|
||||
} else {
|
||||
this.r.discardLinesUntilContains ("ENERGY");
|
||||
this.line = this.r.line;
|
||||
continue;
|
||||
}} else if (this.line.indexOf ("WAVEFUNC") == 0 || this.line.indexOf ("BETA") == 0) {
|
||||
if (this.r.doReadMolecularOrbitals && !skipping) {
|
||||
this.readMolecularOrbital ();
|
||||
haveMOData = true;
|
||||
} else {
|
||||
this.r.discardLinesUntilContains ("GEOM");
|
||||
this.line = this.r.line;
|
||||
}} else if (this.line.indexOf ("ENERGY") == 0 && !skipping) {
|
||||
this.readEnergy ();
|
||||
} else if (this.line.equals ("ENDARCHIVE") || this.isSMOL && this.line.indexOf (this.endCheck) == 0) {
|
||||
break;
|
||||
}this.readLine ();
|
||||
}
|
||||
if (haveMOData) this.r.finalizeMOData (this.r.moData);
|
||||
return this.modelAtomCount;
|
||||
}, "~S,~B,~N,~B");
|
||||
Clazz.defineMethod (c$, "readEnergy",
|
||||
function () {
|
||||
var tokens = JU.PT.getTokens (this.readLine ());
|
||||
var value = this.parseFloat (tokens[0]);
|
||||
this.r.asc.setCurrentModelInfo ("energy", Float.$valueOf (value));
|
||||
if (this.isSMOL) (this.r).setEnergy (value);
|
||||
this.r.asc.setAtomSetEnergy (tokens[0], value);
|
||||
});
|
||||
Clazz.defineMethod (c$, "setInfo",
|
||||
function (info) {
|
||||
var tokens = JU.PT.getTokens (info);
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug ("reading Spartan archive info :" + info);
|
||||
}this.modelAtomCount = this.parseInt (tokens[0]);
|
||||
this.coefCount = this.parseInt (tokens[1]);
|
||||
this.shellCount = this.parseInt (tokens[2]);
|
||||
this.gaussianCount = this.parseInt (tokens[3]);
|
||||
this.moCount = this.parseInt (tokens[6]);
|
||||
this.r.calculationType = tokens[9];
|
||||
var s = this.r.moData.get ("calculationType");
|
||||
if (s == null) s = this.r.calculationType;
|
||||
else if (s.indexOf (this.r.calculationType) < 0) s = this.r.calculationType + s;
|
||||
this.r.moData.put ("calculationType", this.r.calculationType = s);
|
||||
return this.modelAtomCount;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function (ac0, doAddAtoms) {
|
||||
for (var i = 0; i < this.modelAtomCount; i++) {
|
||||
var tokens = JU.PT.getTokens (this.readLine ());
|
||||
var atom = (doAddAtoms ? this.r.asc.addNewAtom () : this.r.asc.atoms[ac0 - this.modelAtomCount + i]);
|
||||
atom.elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (this.parseInt (tokens[0]));
|
||||
this.r.setAtomCoordScaled (atom, tokens, 1, 0.5291772);
|
||||
}
|
||||
if (doAddAtoms && JU.Logger.debugging) {
|
||||
JU.Logger.debug (this.r.asc.ac + " atoms read");
|
||||
}}, "~N,~B");
|
||||
Clazz.defineMethod (c$, "addBonds",
|
||||
function (data, ac0) {
|
||||
var tokens = JU.PT.getTokens (data);
|
||||
for (var i = this.modelAtomCount; i < tokens.length; ) {
|
||||
var sourceIndex = this.parseInt (tokens[i++]) - 1 + ac0;
|
||||
var targetIndex = this.parseInt (tokens[i++]) - 1 + ac0;
|
||||
var bondOrder = this.parseInt (tokens[i++]);
|
||||
if (bondOrder > 0) {
|
||||
this.r.asc.addBond ( new J.adapter.smarter.Bond (sourceIndex, targetIndex, bondOrder < 4 ? bondOrder : bondOrder == 5 ? 515 : 1));
|
||||
}}
|
||||
var bondCount = this.r.asc.bondCount;
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug (bondCount + " bonds read");
|
||||
}}, "~S,~N");
|
||||
Clazz.defineMethod (c$, "readBasis",
|
||||
function () {
|
||||
var shells = new JU.Lst ();
|
||||
var gaussians = JU.AU.newFloat2 (this.gaussianCount);
|
||||
var typeArray = Clazz.newIntArray (this.gaussianCount, 0);
|
||||
for (var i = 0; i < this.shellCount; i++) {
|
||||
var tokens = JU.PT.getTokens (this.readLine ());
|
||||
var isSpherical = (tokens[4].charAt (0) == '1');
|
||||
var slater = Clazz.newIntArray (4, 0);
|
||||
slater[0] = this.parseInt (tokens[3]);
|
||||
var iBasis = this.parseInt (tokens[0]);
|
||||
switch (iBasis) {
|
||||
case 0:
|
||||
iBasis = 0;
|
||||
break;
|
||||
case 1:
|
||||
iBasis = (isSpherical ? 1 : 2);
|
||||
break;
|
||||
case 2:
|
||||
iBasis = (isSpherical ? 3 : 4);
|
||||
break;
|
||||
case 3:
|
||||
iBasis = (isSpherical ? 5 : 6);
|
||||
break;
|
||||
}
|
||||
slater[1] = iBasis;
|
||||
slater[2] = this.parseInt (tokens[2]);
|
||||
var gaussianPtr = slater[2] - 1;
|
||||
var nGaussians = slater[3] = this.parseInt (tokens[1]);
|
||||
for (var j = 0; j < nGaussians; j++) typeArray[gaussianPtr + j] = iBasis;
|
||||
|
||||
shells.addLast (slater);
|
||||
}
|
||||
for (var i = 0; i < this.gaussianCount; i++) {
|
||||
var alpha = this.parseFloat (this.readLine ());
|
||||
var tokens = JU.PT.getTokens (this.readLine ());
|
||||
var nData = tokens.length;
|
||||
var data = Clazz.newFloatArray (nData + 1, 0);
|
||||
data[0] = alpha;
|
||||
switch (typeArray[i]) {
|
||||
case 0:
|
||||
data[1] = this.parseFloat (tokens[0]);
|
||||
break;
|
||||
case 1:
|
||||
data[1] = this.parseFloat (tokens[1]);
|
||||
break;
|
||||
case 2:
|
||||
data[1] = this.parseFloat (tokens[0]);
|
||||
data[2] = this.parseFloat (tokens[1]);
|
||||
if (data[1] == 0) {
|
||||
data[1] = data[2];
|
||||
typeArray[i] = 2;
|
||||
}break;
|
||||
case 4:
|
||||
case 3:
|
||||
data[1] = this.parseFloat (tokens[2]);
|
||||
break;
|
||||
case 6:
|
||||
case 5:
|
||||
data[1] = this.parseFloat (tokens[3]);
|
||||
break;
|
||||
}
|
||||
gaussians[i] = data;
|
||||
}
|
||||
var nCoeff = 0;
|
||||
for (var i = 0; i < this.shellCount; i++) {
|
||||
var slater = shells.get (i);
|
||||
switch (typeArray[slater[2] - 1]) {
|
||||
case 0:
|
||||
nCoeff++;
|
||||
break;
|
||||
case 1:
|
||||
slater[1] = 1;
|
||||
nCoeff += 3;
|
||||
break;
|
||||
case 2:
|
||||
nCoeff += 4;
|
||||
break;
|
||||
case 3:
|
||||
nCoeff += 5;
|
||||
break;
|
||||
case 4:
|
||||
nCoeff += 6;
|
||||
break;
|
||||
case 5:
|
||||
nCoeff += 7;
|
||||
break;
|
||||
case 6:
|
||||
nCoeff += 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var isD5F7 = (nCoeff < this.coefCount);
|
||||
if (isD5F7) for (var i = 0; i < this.shellCount; i++) {
|
||||
var slater = shells.get (i);
|
||||
switch (typeArray[i]) {
|
||||
case 4:
|
||||
slater[1] = 3;
|
||||
break;
|
||||
case 6:
|
||||
slater[1] = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.r.moData.put ("shells", shells);
|
||||
this.r.moData.put ("gaussians", gaussians);
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug (shells.size () + " slater shells read");
|
||||
JU.Logger.debug (gaussians.length + " gaussian primitives read");
|
||||
}});
|
||||
Clazz.defineMethod (c$, "readMolecularOrbital",
|
||||
function () {
|
||||
var tokenPt = 0;
|
||||
this.r.orbitals = new JU.Lst ();
|
||||
var tokens = JU.PT.getTokens ("");
|
||||
var energies = Clazz.newFloatArray (this.moCount, 0);
|
||||
var coefficients = Clazz.newFloatArray (this.moCount, this.coefCount, 0);
|
||||
for (var i = 0; i < this.moCount; i++) {
|
||||
if (tokenPt == tokens.length) {
|
||||
tokens = JU.PT.getTokens (this.readLine ());
|
||||
tokenPt = 0;
|
||||
}energies[i] = this.parseFloat (tokens[tokenPt++]);
|
||||
}
|
||||
for (var i = 0; i < this.moCount; i++) {
|
||||
for (var j = 0; j < this.coefCount; j++) {
|
||||
if (tokenPt == tokens.length) {
|
||||
tokens = JU.PT.getTokens (this.readLine ());
|
||||
tokenPt = 0;
|
||||
}coefficients[i][j] = this.parseFloat (tokens[tokenPt++]);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < this.moCount; i++) {
|
||||
var mo = new java.util.Hashtable ();
|
||||
mo.put ("energy", Float.$valueOf (energies[i]));
|
||||
mo.put ("coefficients", coefficients[i]);
|
||||
this.r.setMO (mo);
|
||||
}
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug (this.r.orbitals.size () + " molecular orbitals read");
|
||||
}this.r.moData.put ("mos", this.r.orbitals);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readProperties",
|
||||
function () {
|
||||
if (JU.Logger.debugging) JU.Logger.debug ("Reading PROPARC properties records...");
|
||||
while (this.readLine () != null && !this.line.startsWith ("ENDPROPARC") && !this.line.startsWith ("END Directory Entry ")) {
|
||||
if (this.line.startsWith ("PROP")) this.readProperty ();
|
||||
else if (this.line.startsWith ("DIPOLE")) this.readDipole ();
|
||||
else if (this.line.startsWith ("VIBFREQ")) this.readVibFreqs ();
|
||||
}
|
||||
this.setVibrationsFromProperties ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readDipole",
|
||||
function () {
|
||||
this.setDipole (JU.PT.getTokens (this.readLine ()));
|
||||
});
|
||||
Clazz.defineMethod (c$, "setDipole",
|
||||
function (tokens) {
|
||||
if (tokens.length != 3) return;
|
||||
var dipole = JU.V3.new3 (this.parseFloat (tokens[0]), this.parseFloat (tokens[1]), this.parseFloat (tokens[2]));
|
||||
this.r.asc.setCurrentModelInfo ("dipole", dipole);
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "readProperty",
|
||||
function () {
|
||||
var tokens = JU.PT.getTokens (this.line);
|
||||
if (tokens.length == 0) return;
|
||||
var isString = (tokens[1].startsWith ("STRING"));
|
||||
var keyName = tokens[2];
|
||||
var isDipole = (keyName.equals ("DIPOLE_VEC"));
|
||||
var value = new Clazz._O ();
|
||||
var vector = new JU.Lst ();
|
||||
if (tokens[3].equals ("=")) {
|
||||
if (isString) {
|
||||
value = this.getQuotedString (tokens[4].substring (0, 1));
|
||||
} else {
|
||||
value = Float.$valueOf (this.parseFloat (tokens[4]));
|
||||
}} else if (tokens[tokens.length - 1].equals ("BEGIN")) {
|
||||
var nValues = this.parseInt (tokens[tokens.length - 2]);
|
||||
if (nValues == 0) nValues = 1;
|
||||
var isArray = (tokens.length == 6);
|
||||
var atomInfo = new JU.Lst ();
|
||||
var ipt = 0;
|
||||
while (this.readLine () != null && !this.line.substring (0, 3).equals ("END")) {
|
||||
if (isString) {
|
||||
value = this.getQuotedString ("\"");
|
||||
vector.addLast (value);
|
||||
} else {
|
||||
var tokens2 = JU.PT.getTokens (this.line);
|
||||
if (isDipole) this.setDipole (tokens2);
|
||||
for (var i = 0; i < tokens2.length; i++, ipt++) {
|
||||
if (isArray) {
|
||||
atomInfo.addLast (Float.$valueOf (this.parseFloat (tokens2[i])));
|
||||
if ((ipt + 1) % nValues == 0) {
|
||||
vector.addLast (atomInfo);
|
||||
atomInfo = new JU.Lst ();
|
||||
}} else {
|
||||
value = Float.$valueOf (this.parseFloat (tokens2[i]));
|
||||
vector.addLast (value);
|
||||
}}
|
||||
}}
|
||||
value = null;
|
||||
} else {
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug (" Skipping property line " + this.line);
|
||||
}}if (value != null) this.r.asc.setInfo (keyName, value);
|
||||
if (vector.size () != 0) this.r.asc.setInfo (keyName, vector);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readVibFreqs",
|
||||
function () {
|
||||
this.readLine ();
|
||||
var label = "";
|
||||
var frequencyCount = this.parseInt (this.line);
|
||||
var vibrations = new JU.Lst ();
|
||||
var freqs = new JU.Lst ();
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug ("reading VIBFREQ vibration records: frequencyCount = " + frequencyCount);
|
||||
}var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
for (var i = 0; i < frequencyCount; ++i) {
|
||||
var ac0 = this.r.asc.ac;
|
||||
ignore[i] = !this.r.doGetVibration (i + 1);
|
||||
if (!ignore[i] && this.r.desiredVibrationNumber <= 0) {
|
||||
this.r.asc.cloneLastAtomSet ();
|
||||
this.addBonds (this.bondData, ac0);
|
||||
}this.readLine ();
|
||||
var info = new java.util.Hashtable ();
|
||||
var freq = this.parseFloat (this.line);
|
||||
info.put ("freq", Float.$valueOf (freq));
|
||||
if (this.line.length > 15 && !(label = this.line.substring (15, this.line.length)).equals ("???")) info.put ("label", label);
|
||||
freqs.addLast (info);
|
||||
if (!ignore[i]) {
|
||||
this.r.asc.setAtomSetFrequency (null, label, "" + freq, null);
|
||||
}}
|
||||
this.r.asc.setInfo ("VibFreqs", freqs);
|
||||
var ac = this.r.asc.atomSetAtomCounts[0];
|
||||
var vib = new JU.Lst ();
|
||||
var vibatom = new JU.Lst ();
|
||||
var ifreq = 0;
|
||||
var iatom = ac;
|
||||
var nValues = 3;
|
||||
var atomInfo = Clazz.newFloatArray (3, 0);
|
||||
while (this.readLine () != null) {
|
||||
var tokens2 = JU.PT.getTokens (this.line);
|
||||
for (var i = 0; i < tokens2.length; i++) {
|
||||
var f = this.parseFloat (tokens2[i]);
|
||||
atomInfo[i % nValues] = f;
|
||||
vibatom.addLast (Float.$valueOf (f));
|
||||
if ((i + 1) % nValues == 0) {
|
||||
if (!ignore[ifreq]) {
|
||||
this.r.asc.addVibrationVector (iatom, atomInfo[0], atomInfo[1], atomInfo[2]);
|
||||
vib.addLast (vibatom);
|
||||
vibatom = new JU.Lst ();
|
||||
}++iatom;
|
||||
}}
|
||||
if (iatom % ac == 0) {
|
||||
if (!ignore[ifreq]) {
|
||||
vibrations.addLast (vib);
|
||||
}vib = new JU.Lst ();
|
||||
if (++ifreq == frequencyCount) {
|
||||
break;
|
||||
}}}
|
||||
this.r.asc.setInfo ("vibration", vibrations);
|
||||
});
|
||||
Clazz.defineMethod (c$, "setVibrationsFromProperties",
|
||||
function () {
|
||||
var freq_modes = this.r.asc.atomSetInfo.get ("FREQ_MODES");
|
||||
if (freq_modes == null) {
|
||||
return;
|
||||
}var freq_lab = this.r.asc.atomSetInfo.get ("FREQ_LAB");
|
||||
var freq_val = this.r.asc.atomSetInfo.get ("FREQ_VAL");
|
||||
var frequencyCount = freq_val.size ();
|
||||
var vibrations = new JU.Lst ();
|
||||
var freqs = new JU.Lst ();
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug ("reading PROP VALUE:VIB FREQ_MODE vibration records: frequencyCount = " + frequencyCount);
|
||||
}var v;
|
||||
for (var i = 0; i < frequencyCount; ++i) {
|
||||
var ac0 = this.r.asc.ac;
|
||||
this.r.asc.cloneLastAtomSet ();
|
||||
this.addBonds (this.bondData, ac0);
|
||||
var info = new java.util.Hashtable ();
|
||||
info.put ("freq", (v = freq_val.get (i)));
|
||||
var freq = v.floatValue ();
|
||||
var label = freq_lab.get (i);
|
||||
if (!label.equals ("???")) {
|
||||
info.put ("label", label);
|
||||
}freqs.addLast (info);
|
||||
this.r.asc.setAtomSetName (label + " " + freq + " cm^-1");
|
||||
this.r.asc.setAtomSetModelProperty ("Frequency", freq + " cm^-1");
|
||||
this.r.asc.setAtomSetModelProperty (".PATH", "Frequencies");
|
||||
}
|
||||
this.r.asc.setInfo ("VibFreqs", freqs);
|
||||
var ac = this.r.asc.atomSetAtomCounts[0];
|
||||
var iatom = ac;
|
||||
for (var i = 0; i < frequencyCount; i++) {
|
||||
if (!this.r.doGetVibration (i + 1)) continue;
|
||||
var ipt = 0;
|
||||
var vib = new JU.Lst ();
|
||||
var mode = freq_modes.get (i);
|
||||
for (var ia = 0; ia < ac; ia++, iatom++) {
|
||||
var vibatom = new JU.Lst ();
|
||||
var vx = (v = mode.get (ipt++)).floatValue ();
|
||||
vibatom.addLast (v);
|
||||
var vy = (v = mode.get (ipt++)).floatValue ();
|
||||
vibatom.addLast (v);
|
||||
var vz = (v = mode.get (ipt++)).floatValue ();
|
||||
vibatom.addLast (v);
|
||||
this.r.asc.addVibrationVector (iatom, vx, vy, vz);
|
||||
vib.addLast (vibatom);
|
||||
}
|
||||
vibrations.addLast (vib);
|
||||
}
|
||||
this.r.asc.setInfo ("vibration", vibrations);
|
||||
});
|
||||
Clazz.defineMethod (c$, "getQuotedString",
|
||||
function (strQuote) {
|
||||
var i = this.line.indexOf (strQuote);
|
||||
var j = this.line.lastIndexOf (strQuote);
|
||||
return (j == i ? "" : this.line.substring (i + 1, j));
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "parseInt",
|
||||
function (info) {
|
||||
return this.r.parseIntStr (info);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "parseFloat",
|
||||
function (info) {
|
||||
return this.r.parseFloatStr (info);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readLine",
|
||||
function () {
|
||||
return (this.line = this.r.rd ());
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.spartan");
|
||||
Clazz.load (["J.adapter.readers.quantum.BasisFunctionReader"], "J.adapter.readers.spartan.SpartanInputReader", ["JU.PT", "J.adapter.smarter.Bond", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.modelAtomCount = 0;
|
||||
this.bondData = "";
|
||||
this.constraints = "";
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.spartan, "SpartanInputReader", J.adapter.readers.quantum.BasisFunctionReader);
|
||||
Clazz.defineMethod (c$, "readInputRecords",
|
||||
function () {
|
||||
var ac0 = this.asc.ac;
|
||||
var modelName = this.readInputHeader ();
|
||||
while (this.rd () != null) {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 2 && this.parseIntStr (tokens[0]) != -2147483648 && this.parseIntStr (tokens[1]) >= 0) break;
|
||||
}
|
||||
if (this.line == null) return null;
|
||||
this.readInputAtoms ();
|
||||
this.discardLinesUntilContains ("ATOMLABELS");
|
||||
if (this.line != null) this.readAtomNames ();
|
||||
if (this.modelAtomCount > 1) {
|
||||
this.discardLinesUntilContains ("HESSIAN");
|
||||
if (this.line != null) this.readBonds (ac0);
|
||||
if (this.line != null && this.line.indexOf ("BEGINCONSTRAINTS") >= 0) this.readConstraints ();
|
||||
}while (this.line != null && this.line.indexOf ("END ") < 0 && this.line.indexOf ("MOLSTATE") < 0) this.rd ();
|
||||
|
||||
if (this.line != null && this.line.indexOf ("MOLSTATE") >= 0) this.readTransform ();
|
||||
return modelName;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readConstraints",
|
||||
function () {
|
||||
this.constraints = "";
|
||||
while (this.rd () != null && this.line.indexOf ("END") < 0) this.constraints += (this.constraints === "" ? "" : "\n") + this.line;
|
||||
|
||||
this.rd ();
|
||||
if (this.constraints.length == 0) return;
|
||||
this.asc.setCurrentModelInfo ("constraints", this.constraints);
|
||||
this.asc.setAtomSetModelProperty (".PATH", "EnergyProfile");
|
||||
this.asc.setAtomSetModelProperty ("Constraint", this.constraints);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readTransform",
|
||||
function () {
|
||||
this.rd ();
|
||||
var tokens = JU.PT.getTokens (this.rd () + " " + this.rd ());
|
||||
this.setTransform (this.parseFloatStr (tokens[0]), this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]), this.parseFloatStr (tokens[4]), this.parseFloatStr (tokens[5]), this.parseFloatStr (tokens[6]), this.parseFloatStr (tokens[8]), this.parseFloatStr (tokens[9]), this.parseFloatStr (tokens[10]));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readInputHeader",
|
||||
function () {
|
||||
while (this.rd () != null && !this.line.startsWith (" ")) {
|
||||
}
|
||||
this.rd ();
|
||||
return this.line.substring (0, (this.line + ";").indexOf (";")).trim ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readInputAtoms",
|
||||
function () {
|
||||
this.modelAtomCount = 0;
|
||||
while (this.rd () != null && !this.line.startsWith ("ENDCART")) {
|
||||
var tokens = this.getTokens ();
|
||||
this.addAtomXYZSymName (tokens, 1, J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (this.parseIntStr (tokens[0])), null);
|
||||
this.modelAtomCount++;
|
||||
}
|
||||
if (this.debugging) JU.Logger.debug (this.asc.ac + " atoms read");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtomNames",
|
||||
function () {
|
||||
var atom0 = this.asc.ac - this.modelAtomCount;
|
||||
for (var i = 0; i < this.modelAtomCount; i++) {
|
||||
this.line = this.rd ().trim ();
|
||||
var name = this.line.substring (1, this.line.length - 1);
|
||||
this.asc.atoms[atom0 + i].atomName = name;
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBonds",
|
||||
function (ac0) {
|
||||
var nAtoms = this.modelAtomCount;
|
||||
this.bondData = "";
|
||||
while (this.rd () != null && !this.line.startsWith ("ENDHESS")) {
|
||||
var tokens = this.getTokens ();
|
||||
this.bondData += this.line + " ";
|
||||
if (nAtoms == 0) {
|
||||
var sourceIndex = this.parseIntStr (tokens[0]) - 1 + ac0;
|
||||
var targetIndex = this.parseIntStr (tokens[1]) - 1 + ac0;
|
||||
var bondOrder = this.parseIntStr (tokens[2]);
|
||||
if (bondOrder > 0) {
|
||||
this.asc.addBond ( new J.adapter.smarter.Bond (sourceIndex, targetIndex, bondOrder < 4 ? bondOrder : bondOrder == 5 ? 515 : 1));
|
||||
}} else {
|
||||
nAtoms -= tokens.length;
|
||||
}}
|
||||
this.rd ();
|
||||
if (this.debugging) JU.Logger.debug (this.asc.bondCount + " bonds read");
|
||||
}, "~N");
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.spartan");
|
||||
Clazz.load (["J.adapter.readers.quantum.BasisFunctionReader"], "J.adapter.readers.spartan.SpartanReader", ["java.lang.Float", "java.util.Hashtable", "J.adapter.readers.spartan.SpartanArchive"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.spartan, "SpartanReader", J.adapter.readers.quantum.BasisFunctionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
var cartesianHeader = "Cartesian Coordinates (Ang";
|
||||
if (this.isSpartanArchive (cartesianHeader)) {
|
||||
this.moData = new java.util.Hashtable ();
|
||||
var spartanArchive = new J.adapter.readers.spartan.SpartanArchive (this, "", null, 0);
|
||||
var ac = spartanArchive.readArchive (this.line, true, 0, true);
|
||||
if (ac > 0) this.asc.setAtomSetName ("Spartan file");
|
||||
} else if (this.line.indexOf (cartesianHeader) >= 0) {
|
||||
this.readAtoms ();
|
||||
this.discardLinesUntilContains ("Vibrational Frequencies");
|
||||
if (this.line != null) this.readFrequencies ();
|
||||
}this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "isSpartanArchive",
|
||||
function (strNotArchive) {
|
||||
var lastLine = "";
|
||||
while (this.rd () != null) {
|
||||
if (this.line.equals ("GEOMETRY")) {
|
||||
this.line = lastLine;
|
||||
return true;
|
||||
}if (this.line.indexOf (strNotArchive) >= 0) return false;
|
||||
lastLine = this.line;
|
||||
}
|
||||
return false;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
this.discardLinesUntilBlank ();
|
||||
while (this.rd () != null && (this.parseIntRange (this.line, 0, 3)) > 0) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.elementSymbol = this.parseTokenRange (this.line, 4, 6);
|
||||
atom.atomName = this.parseTokenRange (this.line, 7, 13);
|
||||
this.setAtomCoordXYZ (atom, this.parseFloatRange (this.line, 17, 30), this.parseFloatRange (this.line, 31, 44), this.parseFloatRange (this.line, 45, 58));
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
var ac = this.asc.atomSetAtomCounts[0];
|
||||
while (true) {
|
||||
this.discardLinesUntilNonBlank ();
|
||||
var lineBaseFreqCount = this.vibrationNumber;
|
||||
this.next[0] = 16;
|
||||
var lineFreqCount;
|
||||
var ignore = Clazz.newBooleanArray (3, false);
|
||||
for (lineFreqCount = 0; lineFreqCount < 3; ++lineFreqCount) {
|
||||
var frequency = this.parseFloat ();
|
||||
if (Float.isNaN (frequency)) break;
|
||||
ignore[lineFreqCount] = !this.doGetVibration (++this.vibrationNumber);
|
||||
if (!ignore[lineFreqCount]) {
|
||||
if (this.vibrationNumber > 1) this.asc.cloneFirstAtomSet (0);
|
||||
this.asc.setAtomSetFrequency (null, null, "" + frequency, null);
|
||||
}}
|
||||
if (lineFreqCount == 0) return;
|
||||
this.readLines (2);
|
||||
for (var i = 0; i < ac; ++i) {
|
||||
this.rd ();
|
||||
for (var j = 0; j < lineFreqCount; ++j) {
|
||||
var ichCoords = j * 23 + 10;
|
||||
var x = this.parseFloatRange (this.line, ichCoords, ichCoords + 7);
|
||||
var y = this.parseFloatRange (this.line, ichCoords + 7, ichCoords + 14);
|
||||
var z = this.parseFloatRange (this.line, ichCoords + 14, ichCoords + 21);
|
||||
if (!ignore[j]) this.asc.addVibrationVector (i + (lineBaseFreqCount + j) * ac, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,181 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.spartan");
|
||||
Clazz.load (["J.adapter.readers.spartan.SpartanInputReader"], "J.adapter.readers.spartan.SpartanSmolReader", ["java.lang.Boolean", "java.util.Hashtable", "JU.BC", "$.PT", "$.SB", "J.adapter.readers.spartan.SpartanArchive", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.iHaveModelStatement = false;
|
||||
this.isCompoundDocument = false;
|
||||
this.inputOnly = false;
|
||||
this.espCharges = false;
|
||||
this.natCharges = false;
|
||||
this.isInputFirst = false;
|
||||
this.iHaveNewDir = false;
|
||||
this.title = null;
|
||||
this.spartanArchive = null;
|
||||
this.titles = null;
|
||||
this.haveCharges = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.spartan, "SpartanSmolReader", J.adapter.readers.spartan.SpartanInputReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.isCompoundDocument = (this.rd ().indexOf ("Compound Document File Directory") >= 0);
|
||||
this.inputOnly = this.checkFilterKey ("INPUT");
|
||||
this.natCharges = this.checkFilterKey ("NATCHAR");
|
||||
this.espCharges = !this.natCharges && !this.checkFilterKey ("MULLIKEN");
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
var pt = 3;
|
||||
var isNewDir = (this.isCompoundDocument && this.line.startsWith ("NEW Directory M") && !this.line.startsWith ("NEW Directory Molecules"));
|
||||
if (isNewDir) this.iHaveNewDir = true;
|
||||
var isMolecule = (!this.iHaveNewDir && !isNewDir && this.isCompoundDocument && this.line.equals ("BEGIN Directory Entry Molecule"));
|
||||
var isMacDir = (!this.isCompoundDocument && (pt = this.line.indexOf ("#JMOL_MODEL")) >= 0);
|
||||
if (isNewDir || isMolecule || isMacDir) {
|
||||
if (this.modelNumber > 0 && !this.isInputFirst) this.applySymmetryAndSetTrajectory ();
|
||||
this.iHaveModelStatement = true;
|
||||
var modelNo = (isMolecule ? 0 : this.parseIntAt (this.line, pt + 12));
|
||||
this.modelNumber = (this.bsModels == null && modelNo != -2147483648 && modelNo != 0 ? modelNo : this.modelNumber + 1);
|
||||
this.bondData = "";
|
||||
if (!this.doGetModel (this.modelNumber, null)) {
|
||||
if (this.isInputFirst) {
|
||||
this.asc.removeCurrentAtomSet ();
|
||||
this.discardLinesUntilContains ("BEGIN Directory Entry Input");
|
||||
} else if (isNewDir) {
|
||||
this.discardLinesUntilContains ("NEW Directory M");
|
||||
} else if (isMolecule) {
|
||||
this.discardLinesUntilContains ("BEGIN Directory Entry M");
|
||||
} else {
|
||||
this.discardLinesUntilContains ("#JMOL_MODEL");
|
||||
}this.checkLastModel ();
|
||||
return false;
|
||||
}if (!this.isInputFirst) {
|
||||
this.makeNewAtomSet ();
|
||||
}this.moData = new java.util.Hashtable ();
|
||||
this.moData.put ("isNormalized", Boolean.TRUE);
|
||||
var isOK = false;
|
||||
if (modelNo == -2147483648 || this.titles == null) {
|
||||
modelNo = this.modelNumber;
|
||||
this.title = "Model " + modelNo;
|
||||
} else {
|
||||
isOK = true;
|
||||
this.title = this.titles.get ("Title" + modelNo);
|
||||
this.title = "Profile " + modelNo + (this.title == null ? "" : ": " + this.title);
|
||||
}if (this.constraints == null && (isOK || !this.isInputFirst)) this.asc.setAtomSetName (this.title);
|
||||
this.setModelPDB (false);
|
||||
this.asc.setCurrentAtomSetNumber (modelNo);
|
||||
if (isMolecule) this.readMyTransform ();
|
||||
return true;
|
||||
}if (this.iHaveModelStatement && !this.doProcessLines) return true;
|
||||
if ((this.line.indexOf ("BEGIN") == 0)) {
|
||||
var lcline = this.line.toLowerCase ();
|
||||
if (lcline.endsWith ("input")) {
|
||||
if (!this.iHaveModelStatement) this.isInputFirst = true;
|
||||
if (this.isInputFirst) {
|
||||
this.makeNewAtomSet ();
|
||||
}this.bondData = "";
|
||||
this.title = this.readInputRecords ();
|
||||
if (this.asc.errorMessage != null) {
|
||||
this.continuing = false;
|
||||
return false;
|
||||
}if (this.title != null && this.constraints == null) this.asc.setAtomSetName (this.title);
|
||||
this.setCharges ();
|
||||
if (this.inputOnly) {
|
||||
this.continuing = false;
|
||||
return false;
|
||||
}} else if (lcline.endsWith ("_output")) {
|
||||
return true;
|
||||
} else if (lcline.endsWith ("output")) {
|
||||
this.readOutput ();
|
||||
return false;
|
||||
} else if (lcline.endsWith ("molecule") || lcline.endsWith ("molecule:asbinarystring")) {
|
||||
this.readMyTransform ();
|
||||
return false;
|
||||
} else if (lcline.endsWith ("proparc") || lcline.endsWith ("propertyarchive")) {
|
||||
this.readProperties ();
|
||||
return false;
|
||||
} else if (lcline.endsWith ("archive")) {
|
||||
this.asc.setAtomSetName (this.readArchive ());
|
||||
return false;
|
||||
}return true;
|
||||
}if (this.line.indexOf ("5D shell") >= 0) this.moData.put ("calculationType", this.calculationType = this.line);
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "makeNewAtomSet",
|
||||
function () {
|
||||
if (this.asc.ac == 0) this.asc.removeCurrentAtomSet ();
|
||||
this.asc.newAtomSet ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.finalizeReaderASCR ();
|
||||
if (this.asc.ac > 0 && this.spartanArchive != null && this.asc.bondCount == 0 && this.bondData != null) this.spartanArchive.addBonds (this.bondData, 0);
|
||||
if (this.moData != null) {
|
||||
var n = this.asc.atomSetInfo.get ("HOMO_N");
|
||||
if (n != null) {
|
||||
var i = n.intValue ();
|
||||
this.moData.put ("HOMO", Integer.$valueOf (i));
|
||||
}}});
|
||||
Clazz.defineMethod (c$, "readMyTransform",
|
||||
function () {
|
||||
var mat;
|
||||
var binaryCodes = this.rd ();
|
||||
var tokens = JU.PT.getTokens (binaryCodes.trim ());
|
||||
if (tokens.length < 16) return;
|
||||
var bytes = Clazz.newByteArray (tokens.length, 0);
|
||||
for (var i = 0; i < tokens.length; i++) bytes[i] = JU.PT.parseIntRadix (tokens[i], 16);
|
||||
|
||||
mat = Clazz.newFloatArray (16, 0);
|
||||
for (var i = 16, j = bytes.length - 8; --i >= 0; j -= 8) mat[i] = JU.BC.bytesToDoubleToFloat (bytes, j, false);
|
||||
|
||||
this.setTransform (mat[0], mat[1], mat[2], mat[4], mat[5], mat[6], mat[8], mat[9], mat[10]);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readOutput",
|
||||
function () {
|
||||
this.titles = new java.util.Hashtable ();
|
||||
var header = new JU.SB ();
|
||||
var pt;
|
||||
while (this.rd () != null && !this.line.startsWith ("END ")) {
|
||||
header.append (this.line).append ("\n");
|
||||
if ((pt = this.line.indexOf (")")) > 0) this.titles.put ("Title" + this.parseIntRange (this.line, 0, pt), (this.line.substring (pt + 1).trim ()));
|
||||
}
|
||||
this.asc.setInfo ("fileHeader", header.toString ());
|
||||
});
|
||||
Clazz.defineMethod (c$, "readArchive",
|
||||
function () {
|
||||
this.spartanArchive = new J.adapter.readers.spartan.SpartanArchive (this, this.bondData, "END Directory Entry ", 0);
|
||||
var modelName = this.readArchiveHeader ();
|
||||
if (modelName != null) this.modelAtomCount = this.spartanArchive.readArchive (this.line, false, this.asc.ac, false);
|
||||
return (this.constraints == null ? modelName : null);
|
||||
});
|
||||
Clazz.defineMethod (c$, "setCharges",
|
||||
function () {
|
||||
if (this.haveCharges || this.asc.ac == 0) return;
|
||||
this.haveCharges = (this.espCharges && this.asc.setAtomSetCollectionPartialCharges ("ESPCHARGES") || this.natCharges && this.asc.setAtomSetCollectionPartialCharges ("NATCHARGES") || this.asc.setAtomSetCollectionPartialCharges ("MULCHARGES") || this.asc.setAtomSetCollectionPartialCharges ("Q1_CHARGES") || this.asc.setAtomSetCollectionPartialCharges ("ESPCHARGES"));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readProperties",
|
||||
function () {
|
||||
if (this.modelAtomCount == 0) {
|
||||
this.rd ();
|
||||
return;
|
||||
}if (this.spartanArchive == null) this.spartanArchive = new J.adapter.readers.spartan.SpartanArchive (this, this.bondData, "END Directory Entry ", this.modelAtomCount);
|
||||
this.spartanArchive.readProperties ();
|
||||
this.rd ();
|
||||
this.setCharges ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readArchiveHeader",
|
||||
function () {
|
||||
var modelInfo = this.rd ();
|
||||
if (this.debugging) JU.Logger.debug (modelInfo);
|
||||
if (modelInfo.indexOf ("Error:") == 0) return null;
|
||||
this.asc.setCollectionName (modelInfo);
|
||||
this.asc.setAtomSetName (modelInfo);
|
||||
var modelName = this.rd ();
|
||||
if (this.debugging) JU.Logger.debug (modelName);
|
||||
this.rd ();
|
||||
return modelName;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setEnergy",
|
||||
function (value) {
|
||||
this.asc.setAtomSetName (this.constraints + (this.constraints.length == 0 ? "" : " ") + "Energy=" + value + " KJ");
|
||||
}, "~N");
|
||||
Clazz.defineStatics (c$,
|
||||
"endCheck", "END Directory Entry ");
|
||||
});
|
||||
@@ -0,0 +1,215 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.spartan");
|
||||
Clazz.load (null, "J.adapter.readers.spartan.SpartanUtil", ["java.io.BufferedInputStream", "java.util.Hashtable", "$.StringTokenizer", "JU.Lst", "$.PT", "$.Rdr", "$.SB", "J.api.Interface", "JU.Escape", "$.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.fm = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.spartan, "SpartanUtil");
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
});
|
||||
Clazz.defineMethod (c$, "set",
|
||||
function (fm) {
|
||||
this.fm = fm;
|
||||
return this;
|
||||
}, "JV.FileManager");
|
||||
Clazz.defineMethod (c$, "getFileList",
|
||||
function (name, isTypeCheckOnly) {
|
||||
var pt = name.lastIndexOf (".spardir");
|
||||
var info = null;
|
||||
if (name.endsWith (".spardir.zip")) {
|
||||
info = Clazz.newArray (-1, ["SpartanSmol", "Directory Entry ", name + "|output"]);
|
||||
} else {
|
||||
name = name.$replace ('\\', '/');
|
||||
if (!name.endsWith (".spardir") && name.indexOf (".spardir/") < 0) return null;
|
||||
info = (name.lastIndexOf ("/") > pt ? Clazz.newArray (-1, ["SpartanSmol", "Directory Entry ", name + "/input", name + "/archive", name + "/parchive", name + "/Molecule:asBinaryString", name + "/proparc"]) : Clazz.newArray (-1, ["SpartanSmol", "Directory Entry ", name + "/output"]));
|
||||
}if (isTypeCheckOnly) return info;
|
||||
var name00 = name;
|
||||
var header = info[1];
|
||||
var outputFileName = info[2];
|
||||
var fileData = new java.util.Hashtable ();
|
||||
if (info.length == 3) {
|
||||
outputFileName = this.spartanGetObjectAsSections (outputFileName, header, fileData);
|
||||
fileData.put ("OUTPUT", outputFileName);
|
||||
info = this.spartanFileList (name, fileData.get (outputFileName));
|
||||
if (info.length == 3) {
|
||||
outputFileName = this.spartanGetObjectAsSections (info[2], header, fileData);
|
||||
fileData.put ("OUTPUT", outputFileName);
|
||||
info = this.spartanFileList (info[1], fileData.get (outputFileName));
|
||||
}}var sb = new JU.SB ();
|
||||
var s;
|
||||
if (fileData.get ("OUTPUT") != null) {
|
||||
sb.append (fileData.get (fileData.get ("OUTPUT")));
|
||||
}for (var i = 2; i < info.length; i++) {
|
||||
name = info[i];
|
||||
name = this.spartanGetObjectAsSections (name, header, fileData);
|
||||
JU.Logger.info ("reading " + name);
|
||||
s = fileData.get (name);
|
||||
sb.append (s);
|
||||
}
|
||||
s = sb.toString ();
|
||||
if (this.fm.spardirCache == null) this.fm.spardirCache = new java.util.Hashtable ();
|
||||
this.fm.spardirCache.put (name00.$replace ('\\', '/'), s.getBytes ());
|
||||
return JU.Rdr.getBR (s);
|
||||
}, "~S,~B");
|
||||
Clazz.defineMethod (c$, "getData",
|
||||
function (is, zipDirectory) {
|
||||
var data = new JU.SB ();
|
||||
data.append ("Zip File Directory: ").append ("\n").append (JU.Escape.eAS (zipDirectory, true)).append ("\n");
|
||||
var fileData = new java.util.Hashtable ();
|
||||
this.fm.vwr.getJzt ().getAllZipData (is, Clazz.newArray (-1, []), "", "Molecule", "__MACOSX", fileData);
|
||||
var prefix = "|";
|
||||
var outputData = fileData.get (prefix + "output");
|
||||
if (outputData == null) outputData = fileData.get ((prefix = "|" + zipDirectory[1]) + "output");
|
||||
data.append (outputData);
|
||||
var files = this.getSpartanFileList (prefix, this.getSpartanDirs (outputData));
|
||||
for (var i = 2; i < files.length; i++) {
|
||||
var name = files[i];
|
||||
if (fileData.containsKey (name)) data.append (fileData.get (name));
|
||||
else data.append (name + "\n");
|
||||
}
|
||||
return data;
|
||||
}, "java.io.InputStream,~A");
|
||||
Clazz.defineMethod (c$, "spartanFileList",
|
||||
function (name, outputFileData) {
|
||||
var dirNums = this.getSpartanDirs (outputFileData);
|
||||
if (dirNums.length == 0) {
|
||||
if (name.endsWith (".spardir")) return this.getSpartanFileList (name, Clazz.newArray (-1, ["M0001"]));
|
||||
if (name.endsWith (".spardir.zip")) {
|
||||
if (outputFileData.indexOf (".zip|output") >= 0) {
|
||||
var sname = name.$replace ('\\', '/');
|
||||
var pt = name.lastIndexOf (".spardir");
|
||||
pt = sname.lastIndexOf ("/");
|
||||
sname = name + "|" + JU.PT.rep (name.substring (pt + 1, name.length - 4), "DROP_", "");
|
||||
return Clazz.newArray (-1, ["SpartanSmol", sname, sname + "/output"]);
|
||||
}}}return this.getSpartanFileList (name, dirNums);
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "getSpartanDirs",
|
||||
function (outputFileData) {
|
||||
if (outputFileData == null) return Clazz.newArray (-1, []);
|
||||
var v = new JU.Lst ();
|
||||
var token;
|
||||
var lastToken = "";
|
||||
if (outputFileData.startsWith ("java.io.FileNotFoundException") || outputFileData.startsWith ("FILE NOT FOUND") || outputFileData.indexOf ("<html") >= 0) return new Array (0);
|
||||
try {
|
||||
var tokens = new java.util.StringTokenizer (outputFileData, " \t\r\n");
|
||||
while (tokens.hasMoreTokens ()) {
|
||||
if ((token = tokens.nextToken ()).equals (")")) v.addLast (lastToken);
|
||||
else if (token.equals ("Start-") && tokens.nextToken ().equals ("Molecule")) v.addLast (JU.PT.split (tokens.nextToken (), "\"")[1]);
|
||||
else if (token.equals ("Molecules")) {
|
||||
var n = JU.PT.parseInt (lastToken);
|
||||
for (var i = 1; i <= n; i++) {
|
||||
var s = "0000" + i;
|
||||
v.addLast ("M" + s.substring (s.length - 4));
|
||||
}
|
||||
}lastToken = token;
|
||||
}
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return (v.size () == 0 ? Clazz.newArray (-1, ["M0001"]) : v.toArray ( new Array (v.size ())));
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getSpartanFileList",
|
||||
function (name, dirNums) {
|
||||
var files = new Array (2 + dirNums.length * 6);
|
||||
files[0] = "SpartanSmol";
|
||||
files[1] = "Directory Entry ";
|
||||
var pt = 2;
|
||||
name = name.$replace ('\\', '/');
|
||||
if (name.endsWith ("/")) name = name.substring (0, name.length - 1);
|
||||
var sep = (name.equals ("|") ? "" : name.endsWith (".zip") ? "|" : "/");
|
||||
for (var i = 0; i < dirNums.length; i++) {
|
||||
var path = name + sep;
|
||||
var s = dirNums[i];
|
||||
path += (JU.PT.isDigit (s.charAt (0)) ? "Profile." + s : s) + "/";
|
||||
files[pt++] = path + "#JMOL_MODEL " + dirNums[i];
|
||||
files[pt++] = path + "input";
|
||||
files[pt++] = path + "archive";
|
||||
files[pt++] = path + "parchive";
|
||||
files[pt++] = path + "Molecule:asBinaryString";
|
||||
files[pt++] = path + "proparc";
|
||||
}
|
||||
return files;
|
||||
}, "~S,~A");
|
||||
Clazz.defineMethod (c$, "spartanGetObjectAsSections",
|
||||
function (name, header, fileData) {
|
||||
if (name == null) return null;
|
||||
var subFileList = null;
|
||||
var asBinaryString = false;
|
||||
var path = name.$replace ('\\', '/');
|
||||
if (name.indexOf (":asBinaryString") >= 0) {
|
||||
asBinaryString = true;
|
||||
name = name.substring (0, name.indexOf (":asBinaryString"));
|
||||
}var sb = null;
|
||||
if (fileData.containsKey (path)) return path;
|
||||
if (path.indexOf ("#JMOL_MODEL ") >= 0) {
|
||||
fileData.put (path, path + "\n");
|
||||
return path;
|
||||
}var fullName = name;
|
||||
if (name.indexOf ("|") >= 0) {
|
||||
subFileList = JU.PT.split (name, "|");
|
||||
name = subFileList[0];
|
||||
}var bis = null;
|
||||
try {
|
||||
var t = this.fm.getBufferedInputStreamOrErrorMessageFromName (name, fullName, false, false, null, false, true);
|
||||
if (Clazz.instanceOf (t, String)) {
|
||||
fileData.put (path, t + "\n");
|
||||
return path;
|
||||
}name = name.$replace ('\\', '/');
|
||||
bis = t;
|
||||
if (JU.Rdr.isCompoundDocumentS (bis)) {
|
||||
var doc = J.api.Interface.getInterface ("JU.CompoundDocument", this.fm.vwr, "file");
|
||||
doc.setDocStream (this.fm.vwr.getJzt (), bis);
|
||||
doc.getAllDataMapped (name, "Molecule", fileData);
|
||||
} else if (JU.Rdr.isZipS (bis)) {
|
||||
this.fm.vwr.getJzt ().getAllZipData (bis, subFileList, name, "Molecule", "__MACOSX", fileData);
|
||||
} else if (asBinaryString) {
|
||||
var bd = J.api.Interface.getInterface ("JU.BinaryDocument", this.fm.vwr, "file");
|
||||
bd.setStream (bis, false);
|
||||
sb = new JU.SB ();
|
||||
if (header != null) sb.append ("BEGIN Directory Entry " + path + "\n");
|
||||
try {
|
||||
while (true) sb.append (Integer.toHexString (bd.readByte () & 0xFF)).appendC (' ');
|
||||
|
||||
} catch (e1) {
|
||||
if (Clazz.exceptionOf (e1, Exception)) {
|
||||
sb.appendC ('\n');
|
||||
} else {
|
||||
throw e1;
|
||||
}
|
||||
}
|
||||
if (header != null) sb.append ("\nEND Directory Entry " + path + "\n");
|
||||
fileData.put (path, sb.toString ());
|
||||
} else {
|
||||
var br = JU.Rdr.getBufferedReader (JU.Rdr.isGzipS (bis) ? new java.io.BufferedInputStream (this.fm.vwr.getJzt ().newGZIPInputStream (bis)) : bis, null);
|
||||
var line;
|
||||
sb = new JU.SB ();
|
||||
if (header != null) sb.append ("BEGIN Directory Entry " + path + "\n");
|
||||
while ((line = br.readLine ()) != null) {
|
||||
sb.append (line);
|
||||
sb.appendC ('\n');
|
||||
}
|
||||
br.close ();
|
||||
if (header != null) sb.append ("\nEND Directory Entry " + path + "\n");
|
||||
fileData.put (path, sb.toString ());
|
||||
}} catch (ioe) {
|
||||
if (Clazz.exceptionOf (ioe, Exception)) {
|
||||
fileData.put (path, ioe.toString ());
|
||||
} else {
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
if (bis != null) try {
|
||||
bis.close ();
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (!fileData.containsKey (path)) fileData.put (path, "FILE NOT FOUND: " + path + "\n");
|
||||
return path;
|
||||
}, "~S,~S,java.util.Map");
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlReader"], "J.adapter.readers.xml.XmlArgusReader", ["java.lang.Float", "J.adapter.smarter.Atom"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.atomName1 = null;
|
||||
this.atomName2 = null;
|
||||
this.bondOrder = 0;
|
||||
this.elementContext = 0;
|
||||
this.trans = null;
|
||||
this.ptTrans = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlArgusReader", J.adapter.readers.xml.XmlReader);
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlArgusReader, []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
for (var i = J.adapter.readers.xml.XmlArgusReader.keepCharsList.length; --i >= 0; ) if (J.adapter.readers.xml.XmlArgusReader.keepCharsList[i].equals (localName)) {
|
||||
this.setKeepChars (true);
|
||||
break;
|
||||
}
|
||||
if ("molecule".equals (localName)) {
|
||||
this.asc.newAtomSet ();
|
||||
return;
|
||||
}if ("atom".equals (localName)) {
|
||||
this.elementContext = 2;
|
||||
this.atom = new J.adapter.smarter.Atom ();
|
||||
return;
|
||||
}if ("bond".equals (localName)) {
|
||||
this.elementContext = 3;
|
||||
this.atomName1 = null;
|
||||
this.atomName2 = null;
|
||||
this.bondOrder = this.parseBondToken (this.atts.get ("order"));
|
||||
return;
|
||||
}if ("transformmat".equals (localName)) {
|
||||
this.elementContext = 4;
|
||||
this.trans = Clazz.newFloatArray (16, 0);
|
||||
return;
|
||||
}}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "parseBondToken",
|
||||
function (str) {
|
||||
var floatOrder = this.parseFloatStr (str);
|
||||
if (Float.isNaN (floatOrder) && str.length >= 1) {
|
||||
str = str.toUpperCase ();
|
||||
switch (str.charAt (0)) {
|
||||
case 'S':
|
||||
return 1;
|
||||
case 'D':
|
||||
return 2;
|
||||
case 'T':
|
||||
return 3;
|
||||
case 'A':
|
||||
return 515;
|
||||
}
|
||||
return this.parseIntStr (str);
|
||||
}if (floatOrder == 1.5) return 515;
|
||||
if (floatOrder == 2) return 2;
|
||||
if (floatOrder == 3) return 3;
|
||||
return 1;
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
var n = this.chars.length ();
|
||||
if (n > 0 && this.chars.charAt (n - 1) == '\n') this.chars.setLength (n - 1);
|
||||
if ("molecule".equals (localName)) {
|
||||
this.elementContext = 0;
|
||||
return;
|
||||
}if ("atom".equals (localName)) {
|
||||
if (this.atom.elementSymbol != null && !Float.isNaN (this.atom.z)) {
|
||||
this.parent.setAtomCoord (this.atom);
|
||||
this.asc.addAtomWithMappedName (this.atom);
|
||||
}this.atom = null;
|
||||
this.elementContext = 0;
|
||||
return;
|
||||
}if ("bond".equals (localName)) {
|
||||
if (this.atomName2 != null) this.asc.addNewBondFromNames (this.atomName1, this.atomName2, this.bondOrder);
|
||||
this.elementContext = 0;
|
||||
return;
|
||||
}if ("transformmat".equals (localName)) {
|
||||
this.elementContext = 0;
|
||||
this.parent.setTransform (this.trans[0], this.trans[1], this.trans[2], this.trans[4], this.trans[5], this.trans[6], this.trans[8], this.trans[9], this.trans[10]);
|
||||
return;
|
||||
}if (this.elementContext == 1) {
|
||||
if ("name".equals (localName)) {
|
||||
this.asc.setAtomSetName (this.chars.toString ());
|
||||
this.setKeepChars (false);
|
||||
}return;
|
||||
}if (this.atom != null && this.elementContext == 2) {
|
||||
if ("x".equals (localName)) {
|
||||
this.atom.x = this.parseFloatStr (this.chars.toString ());
|
||||
} else if ("y".equals (localName)) {
|
||||
this.atom.y = this.parseFloatStr (this.chars.toString ());
|
||||
return;
|
||||
} else if ("z".equals (localName)) {
|
||||
this.atom.z = this.parseFloatStr (this.chars.toString ());
|
||||
return;
|
||||
} else if ("atsym".equals (localName)) {
|
||||
this.atom.elementSymbol = this.chars.toString ();
|
||||
return;
|
||||
} else if ("formalchg".equals (localName)) {
|
||||
this.atom.formalCharge = this.parseIntStr (this.chars.toString ());
|
||||
} else if ("atomkey".equals (localName)) {
|
||||
this.atom.atomName = this.chars.toString ();
|
||||
}this.setKeepChars (false);
|
||||
return;
|
||||
}if (this.elementContext == 3) {
|
||||
if ("atomkey".equals (localName)) {
|
||||
if (this.atomName1 == null) this.atomName1 = this.chars.toString ();
|
||||
else this.atomName2 = this.chars.toString ();
|
||||
this.setKeepChars (false);
|
||||
}return;
|
||||
}if (this.elementContext == 4) {
|
||||
this.trans[this.ptTrans++] = this.parseFloatStr (this.chars.toString ());
|
||||
this.setKeepChars (false);
|
||||
return;
|
||||
}}, "~S");
|
||||
Clazz.defineStatics (c$,
|
||||
"keepCharsList", Clazz.newArray (-1, ["name", "x", "y", "z", "formalchg", "atomkey", "atsym", "e00", "e01", "e02", "e03", "e10", "e11", "e12", "e13", "e20", "e21", "e22", "e23", "e30", "e31", "e32", "e33"]),
|
||||
"UNSET", 0,
|
||||
"MOLECULE", 1,
|
||||
"ATOM", 2,
|
||||
"BOND", 3,
|
||||
"TRANSFORMMAT", 4);
|
||||
});
|
||||
@@ -0,0 +1,105 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlReader", "JU.Lst"], "J.adapter.readers.xml.XmlChem3dReader", ["java.lang.Boolean", "$.Float", "java.util.Hashtable", "JU.PT", "J.adapter.smarter.Atom", "J.api.Interface", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.orbitals = null;
|
||||
this.moData = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlChem3dReader", J.adapter.readers.xml.XmlReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.orbitals = new JU.Lst ();
|
||||
});
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlChem3dReader, []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processXml",
|
||||
function (parent, saxReader) {
|
||||
this.processXml2 (parent, saxReader);
|
||||
this.finalizeMOData (this.moData);
|
||||
}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
var tokens;
|
||||
if ("model".equals (localName)) {
|
||||
this.asc.newAtomSet ();
|
||||
return;
|
||||
}if ("atom".equals (localName)) {
|
||||
this.atom = new J.adapter.smarter.Atom ();
|
||||
this.atom.atomName = this.atts.get ("id");
|
||||
this.atom.elementSymbol = this.atts.get ("symbol");
|
||||
if (this.atts.containsKey ("cartcoords")) {
|
||||
var xyz = this.atts.get ("cartcoords");
|
||||
tokens = JU.PT.getTokens (xyz);
|
||||
this.atom.set (this.parseFloatStr (tokens[0]), this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]));
|
||||
}return;
|
||||
}if ("bond".equals (localName)) {
|
||||
var atom1 = this.atts.get ("bondatom1");
|
||||
var atom2 = this.atts.get ("bondatom2");
|
||||
var order = 1;
|
||||
if (this.atts.containsKey ("bondorder")) order = this.parseIntStr (this.atts.get ("bondorder"));
|
||||
this.asc.addNewBondFromNames (atom1, atom2, order);
|
||||
return;
|
||||
}if ("electronicstructurecalculation".equals (localName)) {
|
||||
tokens = JU.PT.getTokens (this.atts.get ("calcpartialcharges"));
|
||||
var tokens2 = JU.PT.getTokens (this.atts.get ("calcatoms"));
|
||||
for (var i = this.parseIntStr (tokens[0]); --i >= 0; ) this.asc.mapPartialCharge (tokens2[i + 1], this.parseFloatStr (tokens[i + 1]));
|
||||
|
||||
}if ("griddata".equals (localName)) {
|
||||
var nPointsX = this.parseIntStr (this.atts.get ("griddatxdim"));
|
||||
var nPointsY = this.parseIntStr (this.atts.get ("griddatydim"));
|
||||
var nPointsZ = this.parseIntStr (this.atts.get ("griddatzdim"));
|
||||
var xStep = this.parseFloatStr (this.atts.get ("griddatxsize")) / (nPointsX);
|
||||
var yStep = this.parseFloatStr (this.atts.get ("griddatysize")) / (nPointsY);
|
||||
var zStep = this.parseFloatStr (this.atts.get ("griddatzsize")) / (nPointsZ);
|
||||
tokens = JU.PT.getTokens (this.atts.get ("griddatorigin"));
|
||||
var ox = this.parseFloatStr (tokens[0]);
|
||||
var oy = this.parseFloatStr (tokens[1]);
|
||||
var oz = this.parseFloatStr (tokens[2]);
|
||||
tokens = JU.PT.getTokens (this.atts.get ("griddatdata"));
|
||||
var pt = 1;
|
||||
var voxelData = Clazz.newFloatArray (nPointsX, nPointsY, nPointsZ, 0);
|
||||
var sum = 0;
|
||||
for (var z = 0; z < nPointsZ; z++) for (var y = 0; y < nPointsY; y++) for (var x = 0; x < nPointsX; x++) {
|
||||
var f = this.parseFloatStr (tokens[pt++]);
|
||||
voxelData[x][y][z] = f;
|
||||
sum += f * f;
|
||||
}
|
||||
|
||||
|
||||
sum = (1 / Math.sqrt (sum));
|
||||
for (var z = 0; z < nPointsZ; z++) for (var y = 0; y < nPointsY; y++) for (var x = 0; x < nPointsX; x++) {
|
||||
voxelData[x][y][z] *= sum;
|
||||
}
|
||||
|
||||
|
||||
var vd = J.api.Interface.getOption ("jvxl.data.VolumeData", this.vwr, "file");
|
||||
vd.setVoxelCounts (nPointsX, nPointsY, nPointsZ);
|
||||
vd.setVolumetricVector (0, xStep, 0, 0);
|
||||
vd.setVolumetricVector (1, 0, yStep, 0);
|
||||
vd.setVolumetricVector (2, 0, 0, zStep);
|
||||
vd.setVolumetricOrigin (ox, oy, oz);
|
||||
vd.setVoxelDataAsArray (voxelData);
|
||||
if (this.moData == null) {
|
||||
this.moData = new java.util.Hashtable ();
|
||||
this.moData.put ("defaultCutoff", Float.$valueOf (0.01));
|
||||
this.moData.put ("haveVolumeData", Boolean.TRUE);
|
||||
this.moData.put ("calculationType", "Chem3D");
|
||||
this.orbitals = new JU.Lst ();
|
||||
this.moData.put ("mos", this.orbitals);
|
||||
}var mo = new java.util.Hashtable ();
|
||||
mo.put ("volumeData", vd);
|
||||
this.orbitals.addLast (mo);
|
||||
JU.Logger.info ("Chem3D molecular orbital data displayable using ISOSURFACE MO " + this.orbitals.size ());
|
||||
return;
|
||||
}}, "~S,~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
if ("atom".equals (localName)) {
|
||||
if (this.atom.elementSymbol != null && !Float.isNaN (this.atom.z)) {
|
||||
this.parent.setAtomCoord (this.atom);
|
||||
this.asc.addAtomWithMappedName (this.atom);
|
||||
}this.atom = null;
|
||||
return;
|
||||
}this.setKeepChars (false);
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,592 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlReader"], "J.adapter.readers.xml.XmlCmlReader", ["java.lang.Float", "$.IndexOutOfBoundsException", "java.util.Hashtable", "$.Properties", "$.StringTokenizer", "JU.BS", "$.Lst", "$.PT", "J.adapter.smarter.Atom", "$.Bond", "J.api.JmolAdapter", "JU.BSUtil", "$.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.scalarDictRef = null;
|
||||
this.scalarDictValue = null;
|
||||
this.scalarTitle = null;
|
||||
this.cellParameterType = null;
|
||||
this.checkedSerial = false;
|
||||
this.isSerial = false;
|
||||
this.moleculeNesting = 0;
|
||||
this.latticeVectorPtr = 0;
|
||||
this.embeddedCrystal = false;
|
||||
this.atomIdNames = null;
|
||||
this.tokens = null;
|
||||
this.aaLen = 0;
|
||||
this.atomArray = null;
|
||||
this.bondCount = 0;
|
||||
this.bondArray = null;
|
||||
this.tokenCount = 0;
|
||||
this.moduleNestingLevel = 0;
|
||||
this.haveMolecule = false;
|
||||
this.localSpaceGroupName = null;
|
||||
this.processing = true;
|
||||
this.state = 0;
|
||||
this.atomIndex0 = 0;
|
||||
this.joinList = null;
|
||||
this.mapRtoA = null;
|
||||
this.deleteAtoms = null;
|
||||
this.moleculeID = null;
|
||||
this.htModelAtomMap = null;
|
||||
this.optimize2d = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlCmlReader", J.adapter.readers.xml.XmlReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.tokens = new Array (16);
|
||||
this.atomArray = new Array (100);
|
||||
this.bondArray = new Array (100);
|
||||
});
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlCmlReader, []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processXml",
|
||||
function (parent, saxReader) {
|
||||
this.optimize2d = parent.checkFilterKey ("2D");
|
||||
this.processXml2 (parent, saxReader);
|
||||
if (this.optimize2d) this.set2D ();
|
||||
}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (name, nodeName) {
|
||||
if (!this.processing) return;
|
||||
this.processStart2 (name);
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "processStart2",
|
||||
function (name) {
|
||||
name = name.toLowerCase ();
|
||||
var val;
|
||||
switch (this.state) {
|
||||
case 0:
|
||||
if (name.equals ("molecule")) {
|
||||
this.moleculeID = this.atts.get ("id");
|
||||
this.state = 6;
|
||||
this.haveMolecule = true;
|
||||
if (this.moleculeNesting == 0) this.createNewAtomSet ();
|
||||
this.moleculeNesting++;
|
||||
} else if (name.equals ("crystal")) {
|
||||
this.state = 2;
|
||||
} else if (name.equals ("symmetry")) {
|
||||
this.state = 17;
|
||||
if ((val = this.atts.get ("spacegroup")) != null) {
|
||||
this.localSpaceGroupName = val;
|
||||
} else {
|
||||
this.localSpaceGroupName = "P1";
|
||||
this.parent.clearUnitCell ();
|
||||
}} else if (name.equals ("module")) {
|
||||
this.moduleNestingLevel++;
|
||||
} else if (name.equals ("latticevector")) {
|
||||
this.state = 18;
|
||||
this.setKeepChars (true);
|
||||
}break;
|
||||
case 2:
|
||||
this.checkedSerial = true;
|
||||
this.isSerial = false;
|
||||
if (name.equals ("scalar")) {
|
||||
this.state = 3;
|
||||
this.setKeepChars (true);
|
||||
this.scalarTitle = this.atts.get ("title");
|
||||
this.getDictRefValue ();
|
||||
} else if (name.equals ("symmetry")) {
|
||||
this.state = 4;
|
||||
if ((val = this.atts.get ("spacegroup")) != null) {
|
||||
this.localSpaceGroupName = val;
|
||||
for (var i = 0; i < this.localSpaceGroupName.length; i++) if (this.localSpaceGroupName.charAt (i) == '_') this.localSpaceGroupName = this.localSpaceGroupName.substring (0, i) + this.localSpaceGroupName.substring ((i--) + 1);
|
||||
|
||||
}} else if (name.equals ("cellparameter")) {
|
||||
if ((val = this.atts.get ("parametertype")) != null) {
|
||||
this.cellParameterType = val;
|
||||
this.setKeepChars (true);
|
||||
}}break;
|
||||
case 18:
|
||||
this.setKeepChars (true);
|
||||
break;
|
||||
case 17:
|
||||
case 3:
|
||||
case 4:
|
||||
if (name.equals ("transform3")) {
|
||||
this.state = 5;
|
||||
this.setKeepChars (true);
|
||||
}break;
|
||||
case 5:
|
||||
case 6:
|
||||
if (name.equals ("fragmentlist")) {
|
||||
this.joinList = new JU.Lst ();
|
||||
this.mapRtoA = new java.util.Hashtable ();
|
||||
if (this.deleteAtoms == null) this.deleteAtoms = new JU.BS ();
|
||||
} else if (name.equals ("crystal")) {
|
||||
this.state = 2;
|
||||
this.embeddedCrystal = true;
|
||||
} else if (name.equals ("molecule")) {
|
||||
this.state = 6;
|
||||
this.moleculeNesting++;
|
||||
} else if (name.equals ("join")) {
|
||||
var order = -1;
|
||||
this.tokenCount = 0;
|
||||
if ((val = this.atts.get ("atomrefs2")) != null) {
|
||||
this.breakOutTokens (val);
|
||||
if ((val = this.atts.get ("order")) != null) order = this.parseBondToken (val);
|
||||
if (this.tokenCount == 2 && order > 0) this.joinList.addLast ( Clazz.newArray (-1, [this.tokens[0], this.tokens[1], "" + order]));
|
||||
}} else if (name.equals ("bondarray")) {
|
||||
this.state = 10;
|
||||
this.bondCount = 0;
|
||||
if ((val = this.atts.get ("order")) != null) {
|
||||
this.breakOutBondTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.bondArray[i].order = this.parseBondToken (this.tokens[i]);
|
||||
|
||||
}if ((val = this.atts.get ("atomref1")) != null) {
|
||||
this.breakOutBondTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.bondArray[i].atomIndex1 = this.getAtomIndex (this.tokens[i]);
|
||||
|
||||
}if ((val = this.atts.get ("atomref2")) != null) {
|
||||
this.breakOutBondTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.bondArray[i].atomIndex2 = this.getAtomIndex (this.tokens[i]);
|
||||
|
||||
}} else if (name.equals ("atomarray")) {
|
||||
this.state = 7;
|
||||
this.aaLen = 0;
|
||||
var coords3D = false;
|
||||
if ((val = this.atts.get ("atomid")) != null) {
|
||||
this.breakOutAtomTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.atomArray[i].atomName = this.tokens[i];
|
||||
|
||||
}var is3d = (!this.optimize2d && (val = this.atts.get ("x3")) != null);
|
||||
if (is3d) {
|
||||
is3d = true;
|
||||
coords3D = true;
|
||||
this.breakOutAtomTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.atomArray[i].x = this.parseFloatStr (this.tokens[i]);
|
||||
|
||||
if ((val = this.atts.get ("y3")) != null) {
|
||||
this.breakOutAtomTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.atomArray[i].y = this.parseFloatStr (this.tokens[i]);
|
||||
|
||||
}if ((val = this.atts.get ("z3")) != null) {
|
||||
this.breakOutAtomTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.atomArray[i].z = this.parseFloatStr (this.tokens[i]);
|
||||
|
||||
}} else {
|
||||
if ((val = this.atts.get ("x2")) != null) {
|
||||
this.breakOutAtomTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.atomArray[i].x = this.parseFloatStr (this.tokens[i]);
|
||||
|
||||
}if ((val = this.atts.get ("y2")) != null) {
|
||||
this.breakOutAtomTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.atomArray[i].y = this.parseFloatStr (this.tokens[i]);
|
||||
|
||||
}}if ((val = this.atts.get ("elementtype")) != null) {
|
||||
this.breakOutAtomTokens (val);
|
||||
for (var i = this.tokenCount; --i >= 0; ) this.atomArray[i].elementSymbol = this.tokens[i];
|
||||
|
||||
}for (var i = this.aaLen; --i >= 0; ) {
|
||||
var atom = this.atomArray[i];
|
||||
if (!coords3D) atom.z = 0;
|
||||
this.addAtom (atom);
|
||||
}
|
||||
} else if (name.equals ("formula")) {
|
||||
this.state = 13;
|
||||
} else if (name.equals ("association")) {
|
||||
this.state = 19;
|
||||
}break;
|
||||
case 10:
|
||||
if (name.equals ("bond")) {
|
||||
this.state = 11;
|
||||
var order = -1;
|
||||
this.tokenCount = 0;
|
||||
if ((val = this.atts.get ("atomrefs2")) != null) this.breakOutTokens (val);
|
||||
if ((val = this.atts.get ("order")) != null) order = this.parseBondToken (val);
|
||||
if (this.tokenCount == 2 && order > 0) {
|
||||
this.addNewBond (this.tokens[0], this.tokens[1], order);
|
||||
}}break;
|
||||
case 7:
|
||||
if (name.equals ("atom")) {
|
||||
this.state = 8;
|
||||
this.atom = new J.adapter.smarter.Atom ();
|
||||
this.parent.setFractionalCoordinates (false);
|
||||
var id = this.atts.get ("id");
|
||||
if ((val = this.atts.get ("name")) != null) this.atom.atomName = val;
|
||||
else if ((val = this.atts.get ("title")) != null) this.atom.atomName = val;
|
||||
else if ((val = this.atts.get ("label")) != null) this.atom.atomName = val;
|
||||
else this.atom.atomName = id;
|
||||
if (!this.checkedSerial) {
|
||||
this.isSerial = (id != null && id.length > 1 && id.startsWith ("a") && JU.PT.parseInt (id.substring (1)) != -2147483648);
|
||||
this.checkedSerial = true;
|
||||
}if (this.isSerial) this.atom.atomSerial = JU.PT.parseInt (id.substring (1));
|
||||
if ((val = this.atts.get ("xfract")) != null && (this.parent.iHaveUnitCell || !this.atts.containsKey ("x3"))) {
|
||||
this.parent.setFractionalCoordinates (true);
|
||||
this.atom.set (this.parseFloatStr (val), this.parseFloatStr (this.atts.get ("yfract")), this.parseFloatStr (this.atts.get ("zfract")));
|
||||
} else if ((val = this.atts.get ("x3")) != null) {
|
||||
this.atom.set (this.parseFloatStr (val), this.parseFloatStr (this.atts.get ("y3")), this.parseFloatStr (this.atts.get ("z3")));
|
||||
} else if ((val = this.atts.get ("x2")) != null) {
|
||||
this.atom.set (this.parseFloatStr (val), this.parseFloatStr (this.atts.get ("y2")), 0);
|
||||
}if ((val = this.atts.get ("elementtype")) != null) {
|
||||
var sym = val;
|
||||
if ((val = this.atts.get ("isotope")) != null) this.atom.elementNumber = ((this.parseIntStr (val) << 7) + J.api.JmolAdapter.getElementNumber (sym));
|
||||
this.atom.elementSymbol = sym;
|
||||
}if ((val = this.atts.get ("formalcharge")) != null) this.atom.formalCharge = this.parseIntStr (val);
|
||||
}break;
|
||||
case 11:
|
||||
if ((val = this.atts.get ("builtin")) != null) {
|
||||
this.setKeepChars (true);
|
||||
this.state = 15;
|
||||
this.scalarDictValue = val;
|
||||
} else if (name.equals ("bondstereo")) {
|
||||
this.state = 12;
|
||||
}break;
|
||||
case 12:
|
||||
this.setKeepChars (true);
|
||||
this.state = 12;
|
||||
break;
|
||||
case 8:
|
||||
if (name.equals ("scalar")) {
|
||||
this.state = 9;
|
||||
this.setKeepChars (true);
|
||||
this.scalarTitle = this.atts.get ("title");
|
||||
this.getDictRefValue ();
|
||||
} else if ((val = this.atts.get ("builtin")) != null) {
|
||||
this.setKeepChars (true);
|
||||
this.state = 14;
|
||||
this.scalarDictValue = val;
|
||||
}break;
|
||||
case 9:
|
||||
break;
|
||||
case 13:
|
||||
break;
|
||||
case 14:
|
||||
break;
|
||||
case 15:
|
||||
break;
|
||||
}
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getAtomIndex",
|
||||
function (label) {
|
||||
return this.asc.getAtomIndex (this.isSerial ? label.substring (1) : label);
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (name) {
|
||||
if (!this.processing) return;
|
||||
this.processEnd2 (name);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "processEnd2",
|
||||
function (name) {
|
||||
name = name.toLowerCase ();
|
||||
switch (this.state) {
|
||||
case 0:
|
||||
if (name.equals ("module")) {
|
||||
if (--this.moduleNestingLevel == 0) {
|
||||
if (this.parent.iHaveUnitCell) this.applySymmetryAndSetTrajectory ();
|
||||
this.setAtomNames ();
|
||||
}}break;
|
||||
case 19:
|
||||
if (name.equals ("association")) this.state = 6;
|
||||
break;
|
||||
case 2:
|
||||
if (name.equals ("crystal")) {
|
||||
if (this.embeddedCrystal) {
|
||||
this.state = 6;
|
||||
this.embeddedCrystal = false;
|
||||
} else {
|
||||
this.state = 0;
|
||||
}} else if (name.equals ("cellparameter") && this.keepChars) {
|
||||
var tokens = JU.PT.getTokens (this.chars.toString ());
|
||||
this.setKeepChars (false);
|
||||
if (tokens.length != 3 || this.cellParameterType == null) {
|
||||
} else if (this.cellParameterType.equals ("length")) {
|
||||
for (var i = 0; i < 3; i++) this.parent.setUnitCellItem (i, this.parseFloatStr (tokens[i]));
|
||||
|
||||
break;
|
||||
} else if (this.cellParameterType.equals ("angle")) {
|
||||
for (var i = 0; i < 3; i++) this.parent.setUnitCellItem (i + 3, this.parseFloatStr (tokens[i]));
|
||||
|
||||
break;
|
||||
}JU.Logger.error ("bad cellParameter information: parameterType=" + this.cellParameterType + " data=" + this.chars);
|
||||
this.parent.setFractionalCoordinates (false);
|
||||
}break;
|
||||
case 3:
|
||||
if (name.equals ("scalar")) {
|
||||
this.state = 2;
|
||||
if (this.scalarTitle != null) this.checkUnitCellItem (J.adapter.readers.xml.XmlCmlReader.unitCellParamTags, this.scalarTitle);
|
||||
else if (this.scalarDictRef != null) this.checkUnitCellItem (J.api.JmolAdapter.cellParamNames, (this.scalarDictValue.startsWith ("_") ? this.scalarDictValue : "_" + this.scalarDictValue));
|
||||
}this.setKeepChars (false);
|
||||
this.scalarTitle = null;
|
||||
this.scalarDictRef = null;
|
||||
break;
|
||||
case 5:
|
||||
if (name.equals ("transform3")) {
|
||||
this.setKeepChars (false);
|
||||
this.state = 4;
|
||||
}break;
|
||||
case 18:
|
||||
var values = J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (this.chars.toString (), null, 3);
|
||||
this.parent.addExplicitLatticeVector (this.latticeVectorPtr, values, 0);
|
||||
this.latticeVectorPtr = (this.latticeVectorPtr + 1) % 3;
|
||||
this.setKeepChars (false);
|
||||
this.state = 0;
|
||||
break;
|
||||
case 4:
|
||||
case 17:
|
||||
if (name.equals ("symmetry")) this.state = (this.state == 4 ? 2 : 0);
|
||||
if (this.moduleNestingLevel == 0 && this.parent.iHaveUnitCell && !this.embeddedCrystal) this.applySymmetryAndSetTrajectory ();
|
||||
break;
|
||||
case 6:
|
||||
if (name.equals ("fragmentlist")) {
|
||||
for (var i = this.joinList.size (); --i >= 0; ) {
|
||||
var join = this.joinList.get (i);
|
||||
var r1 = this.asc.getAtomFromName (this.fixSerialName (join[0]));
|
||||
var r2 = this.asc.getAtomFromName (this.fixSerialName (join[1]));
|
||||
if (r1 != null && r2 != null) {
|
||||
this.deleteAtoms.set (r1.index);
|
||||
this.deleteAtoms.set (r2.index);
|
||||
this.addNewBond (this.mapRtoA.get (r1), this.mapRtoA.get (r2), this.parseIntStr (join[2]));
|
||||
}}
|
||||
this.joinList = null;
|
||||
this.mapRtoA = null;
|
||||
}if (name.equals ("molecule")) {
|
||||
if (--this.moleculeNesting == 0) {
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.setAtomNames ();
|
||||
this.state = 0;
|
||||
} else {
|
||||
this.state = 6;
|
||||
}}break;
|
||||
case 10:
|
||||
if (name.equals ("bondarray")) {
|
||||
this.state = 6;
|
||||
for (var i = 0; i < this.bondCount; ++i) this.addBond (this.bondArray[i]);
|
||||
|
||||
this.parent.applySymmetryToBonds = true;
|
||||
}break;
|
||||
case 7:
|
||||
if (name.equals ("atomarray")) {
|
||||
this.state = 6;
|
||||
}break;
|
||||
case 11:
|
||||
if (name.equals ("bond")) {
|
||||
this.state = 10;
|
||||
}break;
|
||||
case 8:
|
||||
if (name.equals ("atom")) {
|
||||
this.state = 7;
|
||||
this.addAtom (this.atom);
|
||||
this.atom = null;
|
||||
}break;
|
||||
case 9:
|
||||
if (name.equals ("scalar")) {
|
||||
this.state = 8;
|
||||
if ("jmol:charge".equals (this.scalarDictRef)) {
|
||||
this.atom.partialCharge = this.parseFloatStr (this.chars.toString ());
|
||||
} else if (this.scalarDictRef != null && "_atom_site_label".equals (this.scalarDictValue)) {
|
||||
if (this.atomIdNames == null) this.atomIdNames = new java.util.Properties ();
|
||||
this.atomIdNames.put (this.atom.atomName, this.chars.toString ());
|
||||
}}this.setKeepChars (false);
|
||||
this.scalarTitle = null;
|
||||
this.scalarDictRef = null;
|
||||
break;
|
||||
case 14:
|
||||
this.state = 8;
|
||||
if (this.scalarDictValue.equals ("x3")) this.atom.x = this.parseFloatStr (this.chars.toString ());
|
||||
else if (this.scalarDictValue.equals ("y3")) this.atom.y = this.parseFloatStr (this.chars.toString ());
|
||||
else if (this.scalarDictValue.equals ("z3")) this.atom.z = this.parseFloatStr (this.chars.toString ());
|
||||
else if (this.scalarDictValue.equals ("elementType")) this.atom.elementSymbol = this.chars.toString ();
|
||||
this.setKeepChars (false);
|
||||
break;
|
||||
case 12:
|
||||
var stereo = this.chars.toString ();
|
||||
if (this.bond.order == 1) this.bond.order = (stereo.equals ("H") ? 1041 : 1025);
|
||||
this.setKeepChars (false);
|
||||
this.state = 11;
|
||||
break;
|
||||
case 15:
|
||||
this.state = 11;
|
||||
if (this.scalarDictValue.equals ("atomRef")) {
|
||||
if (this.tokenCount == 0) this.tokens = new Array (2);
|
||||
if (this.tokenCount < 2) this.tokens[this.tokenCount++] = this.chars.toString ();
|
||||
} else if (this.scalarDictValue.equals ("order")) {
|
||||
var order = this.parseBondToken (this.chars.toString ());
|
||||
if (order > 0 && this.tokenCount == 2) this.addNewBond (this.tokens[0], this.tokens[1], order);
|
||||
}this.setKeepChars (false);
|
||||
break;
|
||||
case 13:
|
||||
this.state = 6;
|
||||
break;
|
||||
}
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "addBond",
|
||||
function (bond) {
|
||||
var a1 = this.asc.atoms[bond.atomIndex1];
|
||||
var a2 = this.asc.atoms[bond.atomIndex2];
|
||||
if (this.joinList != null && !this.checkBondToR (a1.atomName, a2.atomName)) this.asc.addBond (bond);
|
||||
}, "J.adapter.smarter.Bond");
|
||||
Clazz.defineMethod (c$, "checkBondToR",
|
||||
function (a1name, a2name) {
|
||||
var a1 = this.asc.getAtomFromName (a1name);
|
||||
var a2 = this.asc.getAtomFromName (a2name);
|
||||
if (a1 == null || a2 == null) return true;
|
||||
if ("R".equals (a1.elementSymbol)) {
|
||||
this.mapRtoA.put (a1, a2.atomName);
|
||||
return true;
|
||||
} else if ("R".equals (a2.elementSymbol)) {
|
||||
this.mapRtoA.put (a2, a1.atomName);
|
||||
return true;
|
||||
}return false;
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "setAtomNames",
|
||||
function () {
|
||||
if (this.atomIdNames == null) return;
|
||||
var s;
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = this.atomIndex0; i < this.asc.ac; i++) if ((s = this.atomIdNames.getProperty (atoms[i].atomName)) != null) atoms[i].atomName = s;
|
||||
|
||||
this.atomIdNames = null;
|
||||
this.atomIndex0 = this.asc.ac;
|
||||
});
|
||||
Clazz.defineMethod (c$, "addNewBond",
|
||||
function (a1, a2, order) {
|
||||
if (a1 == null || a2 == null) return;
|
||||
this.parent.applySymmetryToBonds = true;
|
||||
a1 = this.fixSerialName (a1);
|
||||
a2 = this.fixSerialName (a2);
|
||||
if (this.joinList == null || !this.checkBondToR (a1, a2)) {
|
||||
this.asc.addNewBondFromNames (a1, a2, order);
|
||||
this.bond = this.asc.bonds[this.asc.bondCount - 1];
|
||||
}}, "~S,~S,~N");
|
||||
Clazz.defineMethod (c$, "fixSerialName",
|
||||
function (a) {
|
||||
return (this.isSerial ? a.substring (1) : a);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getDictRefValue",
|
||||
function () {
|
||||
this.scalarDictRef = this.atts.get ("dictref");
|
||||
if (this.scalarDictRef != null) {
|
||||
var iColon = this.scalarDictRef.indexOf (":");
|
||||
this.scalarDictValue = this.scalarDictRef.substring (iColon + 1);
|
||||
}});
|
||||
Clazz.defineMethod (c$, "checkUnitCellItem",
|
||||
function (tags, value) {
|
||||
for (var i = tags.length; --i >= 0; ) if (value.equals (tags[i])) {
|
||||
this.parent.setUnitCellItem (i, this.parseFloatStr (this.chars.toString ()));
|
||||
return;
|
||||
}
|
||||
}, "~A,~S");
|
||||
Clazz.defineMethod (c$, "addAtom",
|
||||
function (atom) {
|
||||
if ((atom.elementSymbol == null && atom.elementNumber < 0) || Float.isNaN (atom.z)) return;
|
||||
this.parent.setAtomCoord (atom);
|
||||
if (this.htModelAtomMap != null) this.htModelAtomMap.put (this.moleculeID + atom.atomName, atom);
|
||||
if (this.isSerial) this.asc.addAtomWithMappedSerialNumber (atom);
|
||||
else this.asc.addAtomWithMappedName (atom);
|
||||
}, "J.adapter.smarter.Atom");
|
||||
Clazz.defineMethod (c$, "parseBondToken",
|
||||
function (str) {
|
||||
var floatOrder = this.parseFloatStr (str);
|
||||
if (Float.isNaN (floatOrder) && str.length >= 1) {
|
||||
str = str.toUpperCase ();
|
||||
switch (str.charAt (0)) {
|
||||
case 'S':
|
||||
return 1;
|
||||
case 'D':
|
||||
return 2;
|
||||
case 'T':
|
||||
return 3;
|
||||
case 'A':
|
||||
return 515;
|
||||
case 'P':
|
||||
return 66;
|
||||
}
|
||||
return this.parseIntStr (str);
|
||||
}if (floatOrder == 1.5) return 515;
|
||||
if (floatOrder == 2) return 2;
|
||||
if (floatOrder == 3) return 3;
|
||||
return 1;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "breakOutTokens",
|
||||
function (str) {
|
||||
var st = new java.util.StringTokenizer (str);
|
||||
this.tokenCount = st.countTokens ();
|
||||
if (this.tokenCount > this.tokens.length) this.tokens = new Array (this.tokenCount);
|
||||
for (var i = 0; i < this.tokenCount; ++i) {
|
||||
try {
|
||||
this.tokens[i] = st.nextToken ();
|
||||
} catch (nsee) {
|
||||
if (Clazz.exceptionOf (nsee, java.util.NoSuchElementException)) {
|
||||
this.tokens[i] = null;
|
||||
} else {
|
||||
throw nsee;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "breakOutAtomTokens",
|
||||
function (str) {
|
||||
this.breakOutTokens (str);
|
||||
this.checkAtomArrayLength (this.tokenCount);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "checkAtomArrayLength",
|
||||
function (newAtomCount) {
|
||||
if (this.aaLen == 0) {
|
||||
if (newAtomCount > this.atomArray.length) this.atomArray = new Array (newAtomCount);
|
||||
for (var i = newAtomCount; --i >= 0; ) this.atomArray[i] = new J.adapter.smarter.Atom ();
|
||||
|
||||
this.aaLen = newAtomCount;
|
||||
} else if (newAtomCount != this.aaLen) {
|
||||
throw new IndexOutOfBoundsException ("bad atom attribute length");
|
||||
}}, "~N");
|
||||
Clazz.defineMethod (c$, "breakOutBondTokens",
|
||||
function (str) {
|
||||
this.breakOutTokens (str);
|
||||
this.checkBondArrayLength (this.tokenCount);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "checkBondArrayLength",
|
||||
function (newBondCount) {
|
||||
if (this.bondCount == 0) {
|
||||
if (newBondCount > this.bondArray.length) this.bondArray = new Array (newBondCount);
|
||||
for (var i = newBondCount; --i >= 0; ) this.bondArray[i] = new J.adapter.smarter.Bond (-1, -1, 1);
|
||||
|
||||
this.bondCount = newBondCount;
|
||||
} else if (newBondCount != this.bondCount) {
|
||||
throw new IndexOutOfBoundsException ("bad bond attribute length");
|
||||
}}, "~N");
|
||||
Clazz.defineMethod (c$, "createNewAtomSet",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
var val;
|
||||
if (this.htModelAtomMap != null) this.htModelAtomMap.put ("" + this.asc.iSet, "" + this.moleculeID);
|
||||
var collectionName = ((val = this.atts.get ("title")) != null || (val = this.atts.get ("id")) != null ? val : null);
|
||||
if (collectionName != null) {
|
||||
this.asc.setAtomSetName (collectionName);
|
||||
}});
|
||||
Clazz.defineMethod (c$, "applySymmetryAndSetTrajectory",
|
||||
function () {
|
||||
if (this.moduleNestingLevel > 0 || !this.haveMolecule || this.localSpaceGroupName == null) return;
|
||||
this.parent.setSpaceGroupName (this.localSpaceGroupName);
|
||||
this.parent.iHaveSymmetryOperators = this.iHaveSymmetryOperators;
|
||||
this.parent.applySymmetryAndSetTrajectory ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "endDocument",
|
||||
function () {
|
||||
if (this.deleteAtoms != null) {
|
||||
var bs = (this.asc.bsAtoms == null ? this.asc.bsAtoms = JU.BSUtil.newBitSet2 (0, this.asc.ac) : this.asc.bsAtoms);
|
||||
bs.andNot (this.deleteAtoms);
|
||||
}});
|
||||
Clazz.defineStatics (c$,
|
||||
"START", 0,
|
||||
"CML", 1,
|
||||
"CRYSTAL", 2,
|
||||
"CRYSTAL_SCALAR", 3,
|
||||
"CRYSTAL_SYMMETRY", 4,
|
||||
"CRYSTAL_SYMMETRY_TRANSFORM3", 5,
|
||||
"MOLECULE", 6,
|
||||
"MOLECULE_ATOM_ARRAY", 7,
|
||||
"MOLECULE_ATOM", 8,
|
||||
"MOLECULE_ATOM_SCALAR", 9,
|
||||
"MOLECULE_BOND_ARRAY", 10,
|
||||
"MOLECULE_BOND", 11,
|
||||
"MOLECULE_BOND_STEREO", 12,
|
||||
"MOLECULE_FORMULA", 13,
|
||||
"MOLECULE_ATOM_BUILTIN", 14,
|
||||
"MOLECULE_BOND_BUILTIN", 15,
|
||||
"MODULE", 16,
|
||||
"SYMMETRY", 17,
|
||||
"LATTICE_VECTOR", 18,
|
||||
"ASSOCIATION", 19,
|
||||
"unitCellParamTags", Clazz.newArray (-1, ["a", "b", "c", "alpha", "beta", "gamma"]));
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["org.xml.sax.helpers.DefaultHandler"], "J.adapter.readers.xml.XmlHandler", ["JU.Logger", "org.xml.sax.InputSource"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.xmlReader = null;
|
||||
this.debugContext = "";
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlHandler", org.xml.sax.helpers.DefaultHandler);
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlHandler, []);
|
||||
});
|
||||
Clazz.defineMethod (c$, "parseXML",
|
||||
function (xmlReader, saxReaderObj, reader) {
|
||||
this.xmlReader = xmlReader;
|
||||
var saxReader = saxReaderObj;
|
||||
saxReader.setFeature ("http://xml.org/sax/features/validation", false);
|
||||
saxReader.setFeature ("http://xml.org/sax/features/namespaces", true);
|
||||
saxReader.setEntityResolver (this);
|
||||
saxReader.setContentHandler (this);
|
||||
saxReader.setErrorHandler (this);
|
||||
var is = new org.xml.sax.InputSource (reader);
|
||||
is.setSystemId ("foo");
|
||||
saxReader.parse (is);
|
||||
}, "J.adapter.readers.xml.XmlReader,~O,java.io.BufferedReader");
|
||||
Clazz.overrideMethod (c$, "startDocument",
|
||||
function () {
|
||||
});
|
||||
Clazz.overrideMethod (c$, "endDocument",
|
||||
function () {
|
||||
this.xmlReader.endDocument ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "startElement",
|
||||
function (namespaceURI, localName, nodeName, attributes) {
|
||||
this.xmlReader.atts.clear ();
|
||||
for (var i = attributes.getLength (); --i >= 0; ) this.xmlReader.atts.put (attributes.getLocalName (i).toLowerCase (), attributes.getValue (i));
|
||||
|
||||
if (JU.Logger.debugging) {
|
||||
this.debugContext += " " + localName;
|
||||
JU.Logger.debug ("start " + this.debugContext);
|
||||
}this.xmlReader.processStartElement (localName.toLowerCase (), nodeName.toLowerCase ());
|
||||
}, "~S,~S,~S,org.xml.sax.Attributes");
|
||||
Clazz.overrideMethod (c$, "endElement",
|
||||
function (uri, localName, qName) {
|
||||
if (JU.Logger.debugging) {
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug ("end " + this.debugContext);
|
||||
}this.debugContext = this.debugContext.substring (0, this.debugContext.lastIndexOf (" "));
|
||||
}this.xmlReader.processEndElement (localName.toLowerCase ());
|
||||
}, "~S,~S,~S");
|
||||
Clazz.overrideMethod (c$, "characters",
|
||||
function (ch, start, length) {
|
||||
if (this.xmlReader.keepChars) this.xmlReader.chars.appendCB (ch, start, length);
|
||||
}, "~A,~N,~N");
|
||||
Clazz.defineMethod (c$, "resolveEntity",
|
||||
function (name, publicId, baseURI, systemId) {
|
||||
if (JU.Logger.debugging) {
|
||||
JU.Logger.debug ("Not resolving this:\n name: " + name + "\n systemID: " + systemId + "\n publicID: " + publicId + "\n baseURI: " + baseURI);
|
||||
}return null;
|
||||
}, "~S,~S,~S,~S");
|
||||
Clazz.overrideMethod (c$, "error",
|
||||
function (exception) {
|
||||
JU.Logger.error ("SAX ERROR:" + exception.getMessage ());
|
||||
}, "org.xml.sax.SAXParseException");
|
||||
Clazz.overrideMethod (c$, "fatalError",
|
||||
function (exception) {
|
||||
JU.Logger.error ("SAX FATAL:" + exception.getMessage ());
|
||||
}, "org.xml.sax.SAXParseException");
|
||||
Clazz.overrideMethod (c$, "warning",
|
||||
function (exception) {
|
||||
JU.Logger.warn ("SAX WARNING:" + exception.getMessage ());
|
||||
}, "org.xml.sax.SAXParseException");
|
||||
});
|
||||
@@ -0,0 +1,200 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlCmlReader"], "J.adapter.readers.xml.XmlMOReader", ["java.util.Hashtable", "JU.AU", "$.Lst", "$.PT", "J.adapter.readers.quantum.MOReader", "J.adapter.smarter.Resolver", "J.quantum.QS", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.moReader = null;
|
||||
this.skipMOs = false;
|
||||
this.htSlaterIDs = null;
|
||||
this.basisData = null;
|
||||
this.basisId = null;
|
||||
this.isSpherical = false;
|
||||
this.minL = 0;
|
||||
this.maxL = 0;
|
||||
this.basisIds = null;
|
||||
this.basisAtoms = null;
|
||||
this.orbOcc = 0;
|
||||
this.orbEnergy = 0;
|
||||
this.gaussianCount = 0;
|
||||
this.slaterCount = 0;
|
||||
this.coefCount = 0;
|
||||
this.groupCount = 0;
|
||||
this.lstGaussians = null;
|
||||
this.moCount = 0;
|
||||
this.calcType = null;
|
||||
this.iModelMO = 0;
|
||||
this.dclist = null;
|
||||
this.dslist = null;
|
||||
this.fclist = null;
|
||||
this.fslist = null;
|
||||
this.iHaveCoefMaps = false;
|
||||
this.maxContraction = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlMOReader", J.adapter.readers.xml.XmlCmlReader);
|
||||
Clazz.overrideMethod (c$, "processXml",
|
||||
function (parent, saxReader) {
|
||||
this.htModelAtomMap = new java.util.Hashtable ();
|
||||
this.processXml2 (parent, saxReader);
|
||||
}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.defineMethod (c$, "processStartMO",
|
||||
function (localName) {
|
||||
if (!this.parent.doReadMolecularOrbitals) return false;
|
||||
if (localName.equals ("molecule")) {
|
||||
var method = this.atts.get ("method");
|
||||
if (method != null) this.calcType = method + "(" + this.atts.get ("basis") + ")";
|
||||
return true;
|
||||
}if (localName.equals ("basisset")) {
|
||||
this.iModelMO = this.asc.iSet;
|
||||
this.lstGaussians = new JU.Lst ();
|
||||
this.htSlaterIDs = new java.util.Hashtable ();
|
||||
this.coefCount = this.groupCount = this.gaussianCount = this.slaterCount = 0;
|
||||
if (this.moReader == null && !this.skipMOs) {
|
||||
var rdr = J.adapter.smarter.Resolver.getReader ("MO", this.parent.htParams);
|
||||
if ((Clazz.instanceOf (rdr, String))) {
|
||||
this.skipMOs = true;
|
||||
} else {
|
||||
this.moReader = rdr;
|
||||
this.moReader.asc = this.asc;
|
||||
if (this.iHaveCoefMaps) {
|
||||
var m = this.moReader.getDfCoefMaps ();
|
||||
if (this.dclist != null) J.quantum.QS.createDFMap (m[4], this.dclist, "DXX DYY DZZ DXY DXZ DYZ", 2);
|
||||
if (this.dslist != null) J.quantum.QS.createDFMap (m[3], this.dslist, "d0 d1+ d1- d2+ d2-", 2);
|
||||
if (this.fclist != null) J.quantum.QS.createDFMap (m[6], this.fclist, "XXX YYY ZZZ XYY XXY XXZ XZZ YZZ YYZ XYZ", 2);
|
||||
if (this.fslist != null) J.quantum.QS.createDFMap (m[5], this.fslist, "f0 f1+ f1- f2+ f2- f3+ f3-", 2);
|
||||
}}}if (this.moReader != null) this.moReader.calculationType = this.calcType;
|
||||
return true;
|
||||
}if (this.moReader != null) {
|
||||
if (localName.equals ("basisgroup")) {
|
||||
this.groupCount++;
|
||||
this.basisId = this.atts.get ("id");
|
||||
this.isSpherical = "spherical".equalsIgnoreCase (this.atts.get ("angular"));
|
||||
this.minL = JU.PT.parseInt (this.atts.get ("minl"));
|
||||
this.maxL = JU.PT.parseInt (this.atts.get ("maxl"));
|
||||
var nContractions = JU.PT.parseInt (this.atts.get ("contractions"));
|
||||
var n = nContractions * (this.isSpherical ? this.minL * 2 + 1 : Clazz.doubleToInt (this.minL * (this.minL + 3) / 2) + 1);
|
||||
this.htModelAtomMap.put (this.basisId + "_count", Integer.$valueOf (n));
|
||||
return true;
|
||||
}if (localName.equals ("basisexponents") || localName.equals ("basiscontraction")) {
|
||||
this.setKeepChars (true);
|
||||
return true;
|
||||
}if (localName.equals ("orbital") && this.gaussianCount > 0) {
|
||||
this.orbOcc = JU.PT.parseFloat (this.atts.get ("occupation"));
|
||||
this.orbEnergy = JU.PT.parseFloat (this.atts.get ("energy"));
|
||||
this.setKeepChars (true);
|
||||
return true;
|
||||
}}return false;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "processEndMO",
|
||||
function (localName) {
|
||||
if (this.moReader != null) {
|
||||
if (localName.equals ("basisexponents")) {
|
||||
this.basisData = new JU.Lst ();
|
||||
this.basisData.addLast (JU.PT.parseFloatArray (this.chars.toString ()));
|
||||
this.setKeepChars (false);
|
||||
return true;
|
||||
}if (localName.equals ("basiscontraction")) {
|
||||
var data = JU.PT.parseFloatArray (this.chars.toString ());
|
||||
this.basisData.addLast (data);
|
||||
if (this.basisData.size () > this.maxContraction) this.maxContraction = this.basisData.size ();
|
||||
this.setKeepChars (false);
|
||||
return true;
|
||||
}if (localName.equals ("basisgroup")) {
|
||||
var otype;
|
||||
switch (this.minL) {
|
||||
case 0:
|
||||
otype = (this.maxL == 1 ? "L" : "S");
|
||||
break;
|
||||
case 1:
|
||||
otype = "P";
|
||||
break;
|
||||
default:
|
||||
otype = (this.minL <= 7 ? "SPDFGHI".substring (this.minL, this.minL + 1) : "?");
|
||||
if (this.isSpherical) otype = (2 * (this.minL) + 1) + otype;
|
||||
}
|
||||
this.lstGaussians.addLast (this.basisData);
|
||||
var nPrimitives = this.basisData.get (0).length;
|
||||
for (var i = 1, n = this.basisData.size (); i < n; i++) {
|
||||
this.htSlaterIDs.put (this.basisId + "_" + i, Clazz.newIntArray (-1, [-1, this.moReader.getQuantumShellTagID (otype), this.gaussianCount + 1, nPrimitives]));
|
||||
this.gaussianCount += nPrimitives;
|
||||
}
|
||||
return true;
|
||||
}if (localName.equals ("basisset")) {
|
||||
this.buildSlaters ();
|
||||
return true;
|
||||
}if (localName.equals ("orbital")) {
|
||||
if (this.gaussianCount == 0) return true;
|
||||
var coef = JU.PT.parseFloatArray (this.chars.toString ());
|
||||
if (this.moCount == 0) {
|
||||
if (coef.length != this.coefCount) {
|
||||
JU.Logger.error ("Number of orbital coefficients (" + coef.length + ") does not agree with expected number (" + this.coefCount + ")");
|
||||
this.moReader = null;
|
||||
return this.skipMOs = true;
|
||||
}JU.Logger.info (this.coefCount + " coefficients found");
|
||||
}this.moReader.addCoef ( new java.util.Hashtable (), coef, null, this.orbEnergy, this.orbOcc, this.moCount++);
|
||||
this.setKeepChars (false);
|
||||
return true;
|
||||
}if (localName.equals ("orbitals")) {
|
||||
this.moReader.setMOData (true);
|
||||
JU.Logger.info ("XmlMOReader created\n " + this.gaussianCount + " gaussians\n " + this.slaterCount + " slaters\n " + this.groupCount + " groups\n " + this.coefCount + " orbital coefficients\n " + this.moCount + " orbitals");
|
||||
return true;
|
||||
}if (this.state == 19) {
|
||||
if (localName.equals ("bases")) {
|
||||
this.basisIds = this.getXlink (this.atts.get ("href"), "basisGroup", false);
|
||||
} else if (localName.equals ("atoms")) {
|
||||
this.basisAtoms = this.getXlink (this.atts.get ("href"), "atom", true);
|
||||
} else if (localName.equals ("association")) {
|
||||
this.state = 6;
|
||||
for (var i = this.basisAtoms.length; --i >= 0; ) {
|
||||
var a = this.htModelAtomMap.get (this.basisAtoms[i]);
|
||||
if (a == null) {
|
||||
JU.Logger.error ("XmlMOReader atom not found; orbitals skipped: " + a);
|
||||
this.moReader = null;
|
||||
return this.skipMOs = true;
|
||||
}this.htModelAtomMap.put (this.basisAtoms[i] + "_basis", this.basisIds);
|
||||
}
|
||||
this.slaterCount += this.basisIds.length * this.basisAtoms.length;
|
||||
}return true;
|
||||
}}return false;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "buildSlaters",
|
||||
function () {
|
||||
var gaussians = JU.AU.newFloat2 (this.gaussianCount);
|
||||
for (var i = 0, p = 0, n = this.lstGaussians.size (); i < n; i++) {
|
||||
this.basisData = this.lstGaussians.get (i);
|
||||
var exp = this.basisData.get (0);
|
||||
for (var ii = 1, nn = this.basisData.size (); ii < nn; ii++) {
|
||||
var coef = this.basisData.get (ii);
|
||||
for (var j = 0; j < exp.length; j++) gaussians[p++] = Clazz.newFloatArray (-1, [exp[j], coef[j], 0]);
|
||||
|
||||
}
|
||||
}
|
||||
this.moReader.gaussians = gaussians;
|
||||
var slaters = new JU.Lst ();
|
||||
var modelID = this.htModelAtomMap.get ("" + this.iModelMO);
|
||||
var i0 = this.asc.getAtomSetAtomIndex (this.iModelMO);
|
||||
for (var i = 0, n = this.asc.getAtomSetAtomCount (this.iModelMO); i < n; i++) {
|
||||
var ids = this.htModelAtomMap.get (modelID + this.asc.atoms[i0 + i].atomName + "_basis");
|
||||
if (ids == null) continue;
|
||||
for (var k = 0; k < ids.length; k++) {
|
||||
var key = ids[k] + "_count";
|
||||
this.coefCount += (this.htModelAtomMap.get (key)).intValue ();
|
||||
for (var kk = 1; kk < this.maxContraction; kk++) {
|
||||
var slater = this.htSlaterIDs.get (ids[k] + "_" + kk);
|
||||
if (slater == null) break;
|
||||
slater = JU.AU.arrayCopyI (slater, -1);
|
||||
this.moReader.shells = slaters;
|
||||
slater[0] = i + 1;
|
||||
slaters.addLast (slater);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getXlink",
|
||||
function (href, key, addMoleculeID) {
|
||||
var p = href.indexOf (key + "[") + 1;
|
||||
var tokens = JU.PT.split (href.substring (p), "'");
|
||||
var data = new Array (Clazz.doubleToInt (tokens.length / 2));
|
||||
var molID = (addMoleculeID ? JU.PT.getQuotedAttribute (href.substring (0, p).$replace ('\'', '"'), "molecule[@id") : "");
|
||||
for (var i = 1, pt = 0; i < tokens.length; i += 2) data[pt++] = molID + tokens[i];
|
||||
|
||||
return data;
|
||||
}, "~S,~S,~B");
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlReader"], "J.adapter.readers.xml.XmlMagResReader", ["JU.Logger"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.xml, "XmlMagResReader", J.adapter.readers.xml.XmlReader);
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlMagResReader, []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processXml",
|
||||
function (parent, saxReader) {
|
||||
parent.doProcessLines = true;
|
||||
this.processXml2 (parent, saxReader);
|
||||
}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
if (this.debugging) JU.Logger.debug ("xmlmagres: start " + localName);
|
||||
if (!this.parent.continuing) return;
|
||||
if ("calculation".equals (localName)) {
|
||||
this.setKeepChars (true);
|
||||
return;
|
||||
}if ("atoms".equals (localName)) {
|
||||
this.setKeepChars (true);
|
||||
return;
|
||||
}}, "~S,~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
if (this.debugging) JU.Logger.debug ("xmlmagres: end " + localName);
|
||||
while (true) {
|
||||
if ("calculation".equals (localName)) {
|
||||
break;
|
||||
}if (!this.parent.doProcessLines) break;
|
||||
if ("atoms".equals (localName)) {
|
||||
break;
|
||||
}return;
|
||||
}
|
||||
this.setKeepChars (false);
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlMOReader"], "J.adapter.readers.xml.XmlMolproReader", ["JU.PT"], function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.xml, "XmlMolproReader", J.adapter.readers.xml.XmlMOReader);
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlMolproReader, []);
|
||||
this.dslist = "d0 d2- d1+ d2+ d1-";
|
||||
this.fclist = "XXX YYY ZZZ XXY XXZ XYY YYZ XZZ YZZ XYZ";
|
||||
this.fslist = "f1+ f1- f0 f3+ f2- f3- f2+";
|
||||
this.iHaveCoefMaps = true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
if (!this.processing) return;
|
||||
this.processStart2 (localName);
|
||||
if (!this.processStartMO (localName)) {
|
||||
if (localName.equals ("normalcoordinate")) {
|
||||
this.setKeepChars (false);
|
||||
if (!this.parent.doGetVibration (++this.vibrationNumber)) return;
|
||||
try {
|
||||
this.asc.cloneLastAtomSet ();
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
System.out.println ("" + e);
|
||||
this.asc.errorMessage = "Error processing normalCoordinate: " + e.getMessage ();
|
||||
this.vibrationNumber = 0;
|
||||
return;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (this.atts.containsKey ("wavenumber")) {
|
||||
var wavenumber = this.atts.get ("wavenumber");
|
||||
var units = "cm^-1";
|
||||
if (this.atts.containsKey ("units")) {
|
||||
units = this.atts.get ("units");
|
||||
if (units.startsWith ("inverseCent")) units = "cm^-1";
|
||||
}this.asc.setAtomSetFrequency (null, null, wavenumber, units);
|
||||
this.setKeepChars (true);
|
||||
}return;
|
||||
}if (localName.equals ("vibrations")) {
|
||||
this.vibrationNumber = 0;
|
||||
return;
|
||||
}}}, "~S,~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
if (!this.processEndMO (localName)) {
|
||||
if (localName.equals ("normalcoordinate")) {
|
||||
if (!this.keepChars) return;
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
var baseAtomIndex = this.asc.getLastAtomSetAtomIndex ();
|
||||
this.tokens = JU.PT.getTokens (this.chars.toString ());
|
||||
for (var offset = this.tokens.length - ac * 3, i = 0; i < ac; i++) {
|
||||
this.asc.addVibrationVector (i + baseAtomIndex, this.parseFloatStr (this.tokens[offset++]), this.parseFloatStr (this.tokens[offset++]), this.parseFloatStr (this.tokens[offset++]));
|
||||
}
|
||||
this.setKeepChars (false);
|
||||
}}this.processEnd2 (localName);
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlReader"], "J.adapter.readers.xml.XmlOdysseyReader", ["java.lang.Float", "JU.P3", "$.PT", "J.adapter.smarter.Atom"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.modelName = null;
|
||||
this.formula = null;
|
||||
this.phase = null;
|
||||
this.formalCharge = -2147483648;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlOdysseyReader", J.adapter.readers.xml.XmlReader);
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlOdysseyReader, []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
if ("structure".equals (localName)) {
|
||||
this.asc.newAtomSet ();
|
||||
return;
|
||||
}if ("atom".equals (localName)) {
|
||||
var id = this.atts.get ("id");
|
||||
(this.atom = new J.adapter.smarter.Atom ()).atomName = this.atts.get (this.atts.containsKey ("label") ? "label" : "id");
|
||||
if (id != null && this.stateScriptVersionInt >= 140400) this.asc.atomSymbolicMap.put (id, this.atom);
|
||||
if (this.atts.containsKey ("xyz")) {
|
||||
var xyz = this.atts.get ("xyz");
|
||||
var tokens = JU.PT.getTokens (xyz);
|
||||
this.atom.set (this.parseFloatStr (tokens[0]), this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]));
|
||||
}if (this.atts.containsKey ("element")) {
|
||||
this.atom.elementSymbol = this.atts.get ("element");
|
||||
}return;
|
||||
}if ("bond".equals (localName)) {
|
||||
var atom1 = this.atts.get ("a");
|
||||
var atom2 = this.atts.get ("b");
|
||||
var order = 1;
|
||||
if (this.atts.containsKey ("order")) order = this.parseBondToken (this.atts.get ("order"));
|
||||
this.asc.addNewBondFromNames (atom1, atom2, order);
|
||||
return;
|
||||
}if ("group".equals (localName)) {
|
||||
var charge = this.atts.get ("charge");
|
||||
if (charge != null && charge.indexOf (".") < 0) {
|
||||
this.formalCharge = JU.PT.parseInt (charge);
|
||||
}return;
|
||||
}if ("member".equals (localName) && this.formalCharge != -2147483648) {
|
||||
var atom = this.asc.getAtomFromName (this.atts.get ("entity"));
|
||||
if (atom != null) atom.formalCharge = this.formalCharge;
|
||||
return;
|
||||
}if ("boundary".equals (localName)) {
|
||||
var boxDim = JU.PT.getTokens (this.atts.get ("box"));
|
||||
var x = this.parseFloatStr (boxDim[0]);
|
||||
var y = this.parseFloatStr (boxDim[1]);
|
||||
var z = this.parseFloatStr (boxDim[2]);
|
||||
this.parent.setUnitCellItem (0, x);
|
||||
this.parent.setUnitCellItem (1, y);
|
||||
this.parent.setUnitCellItem (2, z);
|
||||
this.parent.setUnitCellItem (3, 90);
|
||||
this.parent.setUnitCellItem (4, 90);
|
||||
this.parent.setUnitCellItem (5, 90);
|
||||
var pt = JU.P3.new3 (-x / 2, -y / 2, -z / 2);
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = this.asc.ac; --i >= 0; ) {
|
||||
atoms[i].sub (pt);
|
||||
this.parent.setAtomCoord (atoms[i]);
|
||||
}
|
||||
if (this.parent.latticeCells[0] == 0) this.parent.latticeCells[0] = this.parent.latticeCells[1] = this.parent.latticeCells[2] = 1;
|
||||
return;
|
||||
}if ("odyssey_simulation".equals (localName)) {
|
||||
if (this.modelName != null && this.phase != null) this.modelName += " - " + this.phase;
|
||||
if (this.modelName != null) this.asc.setAtomSetName (this.modelName);
|
||||
if (this.formula != null) this.asc.setCurrentModelInfo ("formula", this.formula);
|
||||
}if ("title".equals (localName) || "formula".equals (localName) || "phase".equals (localName)) this.setKeepChars (true);
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "parseBondToken",
|
||||
function (str) {
|
||||
if (str.length >= 1) {
|
||||
switch (str.charAt (0)) {
|
||||
case 's':
|
||||
return 1;
|
||||
case 'd':
|
||||
return 2;
|
||||
case 't':
|
||||
return 3;
|
||||
case 'a':
|
||||
return 515;
|
||||
}
|
||||
return this.parseIntStr (str);
|
||||
}return 1;
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
if ("atom".equals (localName)) {
|
||||
if (this.atom.elementSymbol != null && !Float.isNaN (this.atom.z)) {
|
||||
this.asc.addAtomWithMappedName (this.atom);
|
||||
}this.atom = null;
|
||||
return;
|
||||
}if ("group".equals (localName)) {
|
||||
this.formalCharge = -2147483648;
|
||||
} else if ("title".equals (localName)) {
|
||||
this.modelName = this.chars.toString ();
|
||||
} else if ("formula".equals (localName)) {
|
||||
this.formula = this.chars.toString ();
|
||||
} else if ("phase".equals (localName)) {
|
||||
this.phase = this.chars.toString ();
|
||||
}this.setKeepChars (false);
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlReader"], "J.adapter.readers.xml.XmlQEReader", ["JU.PT", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.a = 0;
|
||||
this.b = 0;
|
||||
this.c = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlQEReader", J.adapter.readers.xml.XmlReader);
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlQEReader, []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processXml",
|
||||
function (parent, saxReader) {
|
||||
parent.doProcessLines = true;
|
||||
this.processXml2 (parent, saxReader);
|
||||
}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
if (this.debugging) JU.Logger.debug ("xmlqe: start " + localName);
|
||||
if (!this.parent.continuing) return;
|
||||
if ("number_of_atoms".equals (localName) || "cell_dimensions".equals (localName) || "at".equals (localName)) {
|
||||
this.setKeepChars (true);
|
||||
return;
|
||||
}if (localName.startsWith ("atom.")) {
|
||||
this.parent.setAtomCoordScaled (null, JU.PT.getTokens (this.atts.get ("tau")), 0, 0.5291772).elementSymbol = this.atts.get ("species").trim ();
|
||||
}if ("structure".equals (localName)) {
|
||||
if (!this.parent.doGetModel (++this.parent.modelNumber, null)) {
|
||||
this.parent.checkLastModel ();
|
||||
return;
|
||||
}this.parent.setFractionalCoordinates (true);
|
||||
this.asc.doFixPeriodic = true;
|
||||
this.asc.newAtomSet ();
|
||||
return;
|
||||
}if (!this.parent.doProcessLines) return;
|
||||
}, "~S,~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
if (this.debugging) JU.Logger.debug ("xmlqe: end " + localName);
|
||||
while (true) {
|
||||
if (!this.parent.doProcessLines) break;
|
||||
if ("cell_dimensions".equals (localName)) {
|
||||
this.parent.setFractionalCoordinates (true);
|
||||
var data = J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (this.chars.toString (), null, 6);
|
||||
this.a = data[0];
|
||||
this.b = (data[1] == 0 ? this.a : data[1]);
|
||||
this.c = (data[2] == 0 ? this.a : data[2]);
|
||||
break;
|
||||
}if ("at".equals (localName)) {
|
||||
var m = J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (this.chars.toString (), null, 9);
|
||||
for (var i = 0; i < 9; i += 3) {
|
||||
m[i] *= this.a;
|
||||
m[i + 1] *= this.b;
|
||||
m[i + 2] *= this.c;
|
||||
}
|
||||
this.parent.addExplicitLatticeVector (0, m, 0);
|
||||
this.parent.addExplicitLatticeVector (1, m, 3);
|
||||
this.parent.addExplicitLatticeVector (2, m, 6);
|
||||
break;
|
||||
}if ("geometry_info".equals (localName)) {
|
||||
try {
|
||||
this.parent.applySymmetryAndSetTrajectory ();
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}return;
|
||||
}
|
||||
this.setKeepChars (false);
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,205 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader", "JU.SB"], "J.adapter.readers.xml.XmlReader", ["java.io.BufferedInputStream", "java.util.Hashtable", "JU.Rdr", "J.adapter.smarter.AtomSetCollection", "$.Resolver", "J.api.Interface", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.atom = null;
|
||||
this.bond = null;
|
||||
this.parent = null;
|
||||
this.atts = null;
|
||||
this.keepChars = false;
|
||||
this.chars = null;
|
||||
this.domObj = null;
|
||||
this.attribs = null;
|
||||
this.attArgs = null;
|
||||
this.nullObj = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.chars = JU.SB.newN (2000);
|
||||
this.domObj = new Array (1);
|
||||
this.nullObj = new Array (0);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.initCML ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "initCML",
|
||||
function () {
|
||||
this.atts = new java.util.Hashtable ();
|
||||
this.setMyError (this.parseXML ());
|
||||
this.continuing = false;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setMyError",
|
||||
function (err) {
|
||||
if (err != null && (this.asc == null || this.asc.errorMessage == null)) {
|
||||
this.asc = new J.adapter.smarter.AtomSetCollection ("xml", this, null, null);
|
||||
this.asc.errorMessage = err;
|
||||
}}, "~S");
|
||||
Clazz.defineMethod (c$, "parseXML",
|
||||
function () {
|
||||
var saxReader = null;
|
||||
{
|
||||
}return this.selectReaderAndGo (saxReader);
|
||||
});
|
||||
Clazz.defineMethod (c$, "selectReaderAndGo",
|
||||
function (saxReader) {
|
||||
this.asc = new J.adapter.smarter.AtomSetCollection (this.readerName, this, null, null);
|
||||
var className = null;
|
||||
var thisReader = null;
|
||||
var pt = this.readerName.indexOf ("(");
|
||||
var name = (pt < 0 ? this.readerName : this.readerName.substring (0, pt));
|
||||
className = J.adapter.smarter.Resolver.getReaderClassBase (name);
|
||||
if ((thisReader = this.getInterface (className)) == null) return "File reader was not found: " + className;
|
||||
try {
|
||||
thisReader.processXml (this, saxReader);
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
return "Error reading XML: " + ((this.parent == null ? this.vwr : this.parent.vwr).isJS ? e : e.getMessage ());
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}, "~O");
|
||||
Clazz.defineMethod (c$, "processXml",
|
||||
function (parent, saxReader) {
|
||||
this.processXml2 (parent, saxReader);
|
||||
}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.defineMethod (c$, "processXml2",
|
||||
function (parent, saxReader) {
|
||||
this.parent = parent;
|
||||
this.asc = parent.asc;
|
||||
this.reader = parent.reader;
|
||||
this.atts = parent.atts;
|
||||
if (saxReader == null) {
|
||||
this.attribs = new Array (1);
|
||||
this.attArgs = new Array (1);
|
||||
this.domObj = new Array (1);
|
||||
var o = "";
|
||||
var data = null;
|
||||
{
|
||||
o = this.reader.lock.lock; if (o.$in) data = o.$in.buf;
|
||||
}if (Clazz.instanceOf (o, java.io.BufferedInputStream)) o = JU.Rdr.StreamToUTF8String (JU.Rdr.getBIS (data));
|
||||
{
|
||||
this.domObj[0] = this.createDomNodeJS("xmlReader",o);
|
||||
this.walkDOMTree(); this.createDomNodeJS("xmlReader",null);
|
||||
}} else {
|
||||
(J.api.Interface.getOption ("adapter.readers.xml.XmlHandler", this.vwr, "file")).parseXML (this, saxReader, this.reader);
|
||||
}}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.defineMethod (c$, "createDomNodeJS",
|
||||
function (id, data) {
|
||||
var applet = this.parent.vwr.html5Applet;
|
||||
{
|
||||
// id = applet._id + "_" + id;
|
||||
// var d = document.getElementById(id);
|
||||
// if (d)
|
||||
// document.body.removeChild(d);
|
||||
if (!data)
|
||||
return;
|
||||
if (data.indexOf("<?") == 0)
|
||||
data = data.substring(data.indexOf("<", 1));
|
||||
if (data.indexOf("/>") >= 0) {
|
||||
var D = data.split("/>");
|
||||
for (var i = D.length - 1; --i >= 0;) {
|
||||
var s = D[i];
|
||||
var pt = s.lastIndexOf("<") + 1;
|
||||
var pt2 = pt;
|
||||
var len = s.length;
|
||||
var name = "";
|
||||
while (++pt2 < len) {
|
||||
if (" \t\n\r".indexOf(s.charAt(pt2))>= 0) {
|
||||
var name = s.substring(pt, pt2);
|
||||
D[i] = s + "></"+name+">";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
data = D.join('');
|
||||
}
|
||||
var d = document.createElement("_xml");
|
||||
d.innerHTML = data;
|
||||
return d;
|
||||
}}, "~S,~O");
|
||||
Clazz.overrideMethod (c$, "applySymmetryAndSetTrajectory",
|
||||
function () {
|
||||
try {
|
||||
if (this.parent == null) this.applySymTrajASCR ();
|
||||
else this.parent.applySymmetryAndSetTrajectory ();
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
System.out.println ((this.parent == null ? this : this.parent).vwr.isJS ? e : e.getMessage ());
|
||||
JU.Logger.error ("applySymmetry failed: " + e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processDOM",
|
||||
function (DOMNode) {
|
||||
this.domObj = Clazz.newArray (-1, [DOMNode]);
|
||||
this.setMyError (this.selectReaderAndGo (null));
|
||||
}, "~O");
|
||||
Clazz.defineMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "setKeepChars",
|
||||
function (TF) {
|
||||
this.keepChars = TF;
|
||||
this.chars.setLength (0);
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "walkDOMTree",
|
||||
function () {
|
||||
var localName;
|
||||
{
|
||||
localName = "nodeName";
|
||||
}var nodeName = (this.jsObjectGetMember (this.domObj, localName));
|
||||
localName = this.fixLocal (nodeName);
|
||||
if (localName == null) return;
|
||||
if (localName.equals ("#text")) {
|
||||
if (this.keepChars) this.chars.append (this.jsObjectGetMember (this.domObj, "data"));
|
||||
return;
|
||||
}localName = localName.toLowerCase ();
|
||||
nodeName = nodeName.toLowerCase ();
|
||||
this.attribs[0] = this.jsObjectGetMember (this.domObj, "attributes");
|
||||
this.getDOMAttributesA (this.attribs);
|
||||
this.processStartElement (localName, nodeName);
|
||||
var haveChildren;
|
||||
{
|
||||
haveChildren = this.domObj[0].hasChildNodes;
|
||||
}if (haveChildren) {
|
||||
var nextNode = this.jsObjectGetMember (this.domObj, "firstChild");
|
||||
while (nextNode != null) {
|
||||
this.domObj[0] = nextNode;
|
||||
this.walkDOMTree ();
|
||||
this.domObj[0] = nextNode;
|
||||
nextNode = this.jsObjectGetMember (this.domObj, "nextSibling");
|
||||
}
|
||||
}this.processEndElement (localName);
|
||||
});
|
||||
Clazz.defineMethod (c$, "fixLocal",
|
||||
function (name) {
|
||||
{
|
||||
var pt = (name== null ? -1 : name.indexOf(":")); return (pt >=
|
||||
0 ? name.substring(pt+1) : name);
|
||||
}}, "~S");
|
||||
Clazz.defineMethod (c$, "getDOMAttributesA",
|
||||
function (attributes) {
|
||||
this.atts.clear ();
|
||||
if (attributes == null) return;
|
||||
{
|
||||
var nodes = attributes[0]; for (var i = nodes.length; --i >=
|
||||
0;) { var key = this.fixLocal(nodes[i].name);
|
||||
this.atts.put(key.toLowerCase(), nodes[i].value); }
|
||||
return;
|
||||
}}, "~A");
|
||||
Clazz.defineMethod (c$, "jsObjectGetMember",
|
||||
function (jsObject, name) {
|
||||
{
|
||||
return jsObject[0][name];
|
||||
}}, "~A,~S");
|
||||
Clazz.defineMethod (c$, "endDocument",
|
||||
function () {
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,159 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlReader"], "J.adapter.readers.xml.XmlVaspReader", ["java.lang.Double", "JU.PT", "$.SB", "$.V3", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.data = null;
|
||||
this.name = null;
|
||||
this.ac = 0;
|
||||
this.iAtom = 0;
|
||||
this.isE_wo_entrp = false;
|
||||
this.isE_fr_energy = false;
|
||||
this.enthalpy = null;
|
||||
this.gibbsEnergy = null;
|
||||
this.haveUnitCell = false;
|
||||
this.atomNames = null;
|
||||
this.atomSyms = null;
|
||||
this.atomName = null;
|
||||
this.atomSym = null;
|
||||
this.a = 0;
|
||||
this.b = 0;
|
||||
this.c = 0;
|
||||
this.alpha = 0;
|
||||
this.beta = 0;
|
||||
this.gamma = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlVaspReader", J.adapter.readers.xml.XmlReader);
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlVaspReader, []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processXml",
|
||||
function (parent, saxReader) {
|
||||
parent.doProcessLines = true;
|
||||
this.processXml2 (parent, saxReader);
|
||||
}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
if (this.debugging) JU.Logger.debug ("xmlvasp: start " + localName);
|
||||
if (!this.parent.continuing) return;
|
||||
if ("calculation".equals (localName)) {
|
||||
this.enthalpy = null;
|
||||
this.gibbsEnergy = null;
|
||||
return;
|
||||
}if ("i".equals (localName)) {
|
||||
var s = this.atts.get ("name");
|
||||
if (s.charAt (0) != 'e') return;
|
||||
this.isE_wo_entrp = s.equals ("e_wo_entrp");
|
||||
this.isE_fr_energy = s.equals ("e_fr_energy");
|
||||
this.setKeepChars (this.isE_wo_entrp || this.isE_fr_energy);
|
||||
return;
|
||||
}if ("structure".equals (localName)) {
|
||||
if (!this.parent.doGetModel (++this.parent.modelNumber, null)) {
|
||||
this.parent.checkLastModel ();
|
||||
return;
|
||||
}this.parent.setFractionalCoordinates (true);
|
||||
this.asc.doFixPeriodic = true;
|
||||
this.asc.newAtomSet ();
|
||||
if (this.enthalpy != null) {
|
||||
this.asc.setCurrentModelInfo ("enthalpy", Double.$valueOf (JU.PT.dVal (this.enthalpy)));
|
||||
}if (this.gibbsEnergy != null) {
|
||||
this.asc.setAtomSetEnergy ("" + this.gibbsEnergy, this.parseFloatStr (this.gibbsEnergy));
|
||||
this.asc.setCurrentModelInfo ("gibbsEnergy", Double.$valueOf (JU.PT.dVal (this.gibbsEnergy)));
|
||||
}if (this.enthalpy != null && this.gibbsEnergy != null) this.asc.setAtomSetName ("Enthalpy = " + this.enthalpy + " eV Gibbs Energy = " + this.gibbsEnergy + " eV");
|
||||
return;
|
||||
}if (!this.parent.doProcessLines) return;
|
||||
if ("v".equals (localName)) {
|
||||
this.setKeepChars (this.data != null);
|
||||
return;
|
||||
}if ("c".equals (localName)) {
|
||||
this.setKeepChars (this.iAtom < this.ac);
|
||||
return;
|
||||
}if ("varray".equals (localName)) {
|
||||
this.name = this.atts.get ("name");
|
||||
if (this.name != null && JU.PT.isOneOf (this.name, ";basis;positions;forces;")) this.data = new JU.SB ();
|
||||
return;
|
||||
}if ("atoms".equals (localName)) {
|
||||
this.setKeepChars (true);
|
||||
return;
|
||||
}}, "~S,~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
if (this.debugging) JU.Logger.debug ("xmlvasp: end " + localName);
|
||||
while (true) {
|
||||
if (!this.parent.doProcessLines) break;
|
||||
if (this.isE_wo_entrp) {
|
||||
this.isE_wo_entrp = false;
|
||||
this.enthalpy = this.chars.toString ().trim ();
|
||||
break;
|
||||
}if (this.isE_fr_energy) {
|
||||
this.isE_fr_energy = false;
|
||||
this.gibbsEnergy = this.chars.toString ().trim ();
|
||||
break;
|
||||
}if ("v".equals (localName) && this.data != null) {
|
||||
this.data.append (this.chars.toString ());
|
||||
break;
|
||||
}if ("c".equals (localName)) {
|
||||
if (this.iAtom < this.ac) {
|
||||
if (this.atomName == null) {
|
||||
this.atomName = this.atomSym = this.chars.toString ().trim ();
|
||||
} else {
|
||||
this.atomNames[this.iAtom++] = this.atomName + this.chars.toString ().trim ();
|
||||
this.atomName = null;
|
||||
}}break;
|
||||
}if ("atoms".equals (localName)) {
|
||||
this.ac = this.parseIntStr (this.chars.toString ());
|
||||
this.atomNames = new Array (this.ac);
|
||||
this.atomSyms = new Array (this.ac);
|
||||
this.iAtom = 0;
|
||||
break;
|
||||
}if ("varray".equals (localName) && this.data != null) {
|
||||
if (this.name == null) {
|
||||
} else if ("basis".equals (this.name) && !this.haveUnitCell) {
|
||||
this.haveUnitCell = true;
|
||||
var ijk = J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (this.data.toString (), null, 9);
|
||||
var va = JU.V3.new3 (ijk[0], ijk[1], ijk[2]);
|
||||
var vb = JU.V3.new3 (ijk[3], ijk[4], ijk[5]);
|
||||
var vc = JU.V3.new3 (ijk[6], ijk[7], ijk[8]);
|
||||
this.a = va.length ();
|
||||
this.b = vb.length ();
|
||||
this.c = vc.length ();
|
||||
va.normalize ();
|
||||
vb.normalize ();
|
||||
vc.normalize ();
|
||||
this.alpha = (Math.acos (vb.dot (vc)) * 180 / 3.141592653589793);
|
||||
this.beta = (Math.acos (va.dot (vc)) * 180 / 3.141592653589793);
|
||||
this.gamma = (Math.acos (va.dot (vb)) * 180 / 3.141592653589793);
|
||||
} else if ("positions".equals (this.name)) {
|
||||
this.parent.setUnitCell (this.a, this.b, this.c, this.alpha, this.beta, this.gamma);
|
||||
var fdata = Clazz.newFloatArray (this.ac * 3, 0);
|
||||
J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (this.data.toString (), fdata, this.ac * 3);
|
||||
var fpt = 0;
|
||||
for (var i = 0; i < this.ac; i++) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
this.parent.setAtomCoordXYZ (atom, fdata[fpt++], fdata[fpt++], fdata[fpt++]);
|
||||
atom.elementSymbol = this.atomSyms[i];
|
||||
atom.atomName = this.atomNames[i];
|
||||
}
|
||||
} else if ("forces".equals (this.name)) {
|
||||
var fdata = Clazz.newFloatArray (this.ac * 3, 0);
|
||||
J.adapter.smarter.AtomSetCollectionReader.getTokensFloat (this.data.toString (), fdata, this.ac * 3);
|
||||
var fpt = 0;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
for (var i = 0; i < this.ac; i++) this.asc.addVibrationVector (i0 + i, fdata[fpt++], fdata[fpt++], fdata[fpt++]);
|
||||
|
||||
}this.data = null;
|
||||
break;
|
||||
}if ("structure".equals (localName)) {
|
||||
try {
|
||||
this.parent.applySymmetryAndSetTrajectory ();
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}return;
|
||||
}
|
||||
this.setKeepChars (false);
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xml");
|
||||
Clazz.load (["J.adapter.readers.xml.XmlReader", "JU.BS"], "J.adapter.readers.xml.XmlXsdReader", ["java.lang.Float", "JU.PT", "J.adapter.smarter.Atom"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.bsBackbone = null;
|
||||
this.iChain = -1;
|
||||
this.iGroup = 0;
|
||||
this.iAtom = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xml, "XmlXsdReader", J.adapter.readers.xml.XmlReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.bsBackbone = new JU.BS ();
|
||||
});
|
||||
Clazz.makeConstructor (c$,
|
||||
function () {
|
||||
Clazz.superConstructor (this, J.adapter.readers.xml.XmlXsdReader, []);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "processXml",
|
||||
function (parent, saxReader) {
|
||||
parent.htParams.put ("backboneAtoms", this.bsBackbone);
|
||||
this.processXml2 (parent, saxReader);
|
||||
this.asc.atomSymbolicMap.clear ();
|
||||
}, "J.adapter.readers.xml.XmlReader,~O");
|
||||
Clazz.overrideMethod (c$, "processStartElement",
|
||||
function (localName, nodeName) {
|
||||
var tokens;
|
||||
if ("molecule".equals (localName)) {
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetName (this.atts.get ("name"));
|
||||
return;
|
||||
}if ("linearchain".equals (localName)) {
|
||||
this.iGroup = 0;
|
||||
this.iChain++;
|
||||
}if ("repeatunit".equals (localName)) {
|
||||
this.iGroup++;
|
||||
}if ("atom3d".equals (localName)) {
|
||||
this.atom = new J.adapter.smarter.Atom ();
|
||||
this.atom.elementSymbol = this.atts.get ("components");
|
||||
this.atom.atomName = this.atts.get ("id");
|
||||
this.atom.atomSerial = ++this.iAtom;
|
||||
if (this.iChain >= 0) this.parent.setChainID (this.atom, "" + String.fromCharCode ((this.iChain - 1) % 26 + 65));
|
||||
this.atom.group3 = "UNK";
|
||||
if (this.iGroup == 0) this.iGroup = 1;
|
||||
this.atom.sequenceNumber = this.iGroup;
|
||||
var xyz = this.atts.get ("xyz");
|
||||
if (xyz != null) {
|
||||
tokens = JU.PT.getTokens (xyz.$replace (',', ' '));
|
||||
this.atom.set (this.parseFloatStr (tokens[0]), this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]));
|
||||
}var isBackbone = "1".equals (this.atts.get ("isbackboneatom"));
|
||||
if (isBackbone) this.bsBackbone.set (this.iAtom);
|
||||
return;
|
||||
}if ("bond".equals (localName)) {
|
||||
var atoms = JU.PT.split (this.atts.get ("connects"), ",");
|
||||
var order = 1;
|
||||
if (this.atts.containsKey ("type")) {
|
||||
var type = this.atts.get ("type");
|
||||
if (type.equals ("Double")) order = 2;
|
||||
else if (type.equals ("Triple")) order = 3;
|
||||
}this.asc.addNewBondFromNames (atoms[0], atoms[1], order);
|
||||
return;
|
||||
}}, "~S,~S");
|
||||
Clazz.overrideMethod (c$, "processEndElement",
|
||||
function (localName) {
|
||||
if ("atom3d".equalsIgnoreCase (localName)) {
|
||||
if (this.atom.elementSymbol != null && !Float.isNaN (this.atom.z)) {
|
||||
this.parent.setAtomCoord (this.atom);
|
||||
this.asc.addAtomWithMappedName (this.atom);
|
||||
}this.atom = null;
|
||||
return;
|
||||
}this.setKeepChars (false);
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,107 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.AbinitReader", null, function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.znucl = null;
|
||||
this.inputOnly = false;
|
||||
this.nAtom = 0;
|
||||
this.nType = 0;
|
||||
this.typeArray = null;
|
||||
this.cellLattice = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "AbinitReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.setSpaceGroupName ("P1");
|
||||
this.doApplySymmetry = true;
|
||||
this.setFractionalCoordinates (false);
|
||||
this.inputOnly = this.checkFilterKey ("INPUT");
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.contains ("natom")) {
|
||||
this.readNoatom ();
|
||||
} else if (this.line.contains ("ntypat") || this.line.contains ("ntype")) {
|
||||
this.readNotypes ();
|
||||
} else if (this.line.contains ("typat") || this.line.contains ("type")) {
|
||||
this.readTypesequence ();
|
||||
} else if (this.line.contains ("Pseudopotential")) {
|
||||
this.readAtomSpecies ();
|
||||
} else if (this.line.contains ("Symmetries :")) {
|
||||
this.readSpaceGroup ();
|
||||
} else if (this.line.contains ("Real(R)+Recip(G)")) {
|
||||
this.readIntiallattice ();
|
||||
if (this.inputOnly) this.continuing = false;
|
||||
} else if (this.line.contains ("xcart")) {
|
||||
this.readAtoms ();
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readNoatom",
|
||||
function () {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length <= 2) this.nAtom = this.parseIntStr (tokens[1]);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readNotypes",
|
||||
function () {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length <= 2) this.nType = this.parseIntStr (tokens[1]);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readTypesequence",
|
||||
function () {
|
||||
this.fillFloatArray (this.line.substring (12), 0, this.typeArray = Clazz.newFloatArray (this.nAtom, 0));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtomSpecies",
|
||||
function () {
|
||||
this.znucl = Clazz.newFloatArray (this.nType, 0);
|
||||
for (var i = 0; i < this.nType; i++) {
|
||||
this.discardLinesUntilContains ("zion");
|
||||
var tokens = this.getTokens ();
|
||||
this.znucl[i] = this.parseFloatStr (tokens[tokens[0] === "-" ? 1 : 0]);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSpaceGroup",
|
||||
function () {
|
||||
});
|
||||
Clazz.defineMethod (c$, "readIntiallattice",
|
||||
function () {
|
||||
var f = 0;
|
||||
this.cellLattice = Clazz.newFloatArray (9, 0);
|
||||
for (var i = 0; i < 9; i++) {
|
||||
if (i % 3 == 0) {
|
||||
this.line = this.rd ().substring (6);
|
||||
f = this.parseFloatStr (this.line);
|
||||
}this.cellLattice[i] = f * 0.5291772;
|
||||
f = this.parseFloat ();
|
||||
}
|
||||
this.applySymmetry ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "applySymmetry",
|
||||
function () {
|
||||
if (this.cellLattice == null) return;
|
||||
this.setSpaceGroupName ("P1");
|
||||
for (var i = 0; i < 3; i++) this.addExplicitLatticeVector (i, this.cellLattice, i * 3);
|
||||
|
||||
var atoms = this.asc.atoms;
|
||||
var i0 = this.asc.getAtomSetAtomIndex (this.asc.iSet);
|
||||
if (!this.iHaveFractionalCoordinates) for (var i = this.asc.ac; --i >= i0; ) this.setAtomCoord (atoms[i]);
|
||||
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
this.iHaveFractionalCoordinates = false;
|
||||
var i0 = this.asc.ac;
|
||||
this.line = this.line.substring (12);
|
||||
while (this.line != null && !this.line.contains ("x")) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
this.setAtomCoordScaled (atom, this.getTokens (), 0, 0.5291772);
|
||||
this.rd ();
|
||||
}
|
||||
this.discardLinesUntilContains ("z");
|
||||
if (this.znucl == null) this.fillFloatArray (this.line.substring (12), 0, this.znucl = Clazz.newFloatArray (this.nType, 0));
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = 0; i < this.nAtom; i++) atoms[i + i0].elementNumber = Clazz.floatToShort (this.znucl[Clazz.floatToInt (this.typeArray[i]) - 1]);
|
||||
|
||||
this.applySymmetry ();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.AimsReader", ["JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.globalDoApplySymmetry = false;
|
||||
this.isFractional = false;
|
||||
this.nLatticeVectors = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "AimsReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.globalDoApplySymmetry = this.doApplySymmetry;
|
||||
this.doApplySymmetry = true;
|
||||
this.isFractional = true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens.length == 0) return true;
|
||||
if (tokens[0].equals ("lattice_vector")) {
|
||||
this.readLatticeVector (tokens);
|
||||
return true;
|
||||
}if (tokens[0].equals ("atom")) {
|
||||
this.readAtom (tokens, false);
|
||||
return true;
|
||||
}if (tokens[0].equals ("atom_frac")) {
|
||||
this.readAtom (tokens, true);
|
||||
return true;
|
||||
}if (tokens[0].equals ("multipole")) {
|
||||
this.readMultipole (tokens);
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.doApplySymmetry = this.globalDoApplySymmetry;
|
||||
if (this.nLatticeVectors == 1 || this.nLatticeVectors == 2) {
|
||||
JU.Logger.warn ("ignoring translation symmetry for more or less than 3 dimensions(which is currently neither supported by FHI-aims");
|
||||
}this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readLatticeVector",
|
||||
function (tokens) {
|
||||
if (tokens.length < 4) {
|
||||
JU.Logger.warn ("cannot read line with FHI-aims lattice vector: " + this.line);
|
||||
} else if (this.nLatticeVectors == 3) {
|
||||
JU.Logger.warn ("more than 3 FHI-aims lattice vectors found with line: " + this.line);
|
||||
} else {
|
||||
this.addExplicitLatticeVector (this.nLatticeVectors++, Clazz.newFloatArray (-1, [this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]), this.parseFloatStr (tokens[3])]), 0);
|
||||
this.setFractionalCoordinates (this.nLatticeVectors == 3);
|
||||
}}, "~A");
|
||||
Clazz.defineMethod (c$, "readAtom",
|
||||
function (tokens, isFractional) {
|
||||
if (tokens.length < 5) {
|
||||
JU.Logger.warn ("cannot read line with FHI-aims line: " + this.line);
|
||||
return;
|
||||
}if (this.isFractional != isFractional) this.setFractionalCoordinates (this.isFractional = isFractional);
|
||||
this.addAtomXYZSymName (tokens, 1, tokens[4], null);
|
||||
}, "~A,~B");
|
||||
Clazz.defineMethod (c$, "readMultipole",
|
||||
function (tokens) {
|
||||
if (tokens.length < 6) {
|
||||
JU.Logger.warn ("cannot read line with FHI-aims atom data: " + this.line);
|
||||
return;
|
||||
}var order = this.parseIntStr (tokens[4]);
|
||||
if (order > 0) {
|
||||
JU.Logger.warn ("multipole line ignored since only monopoles are currently supported: " + this.line);
|
||||
return;
|
||||
}if (this.isFractional) this.setFractionalCoordinates (this.isFractional = false);
|
||||
this.addAtomXYZSymName (tokens, 1, null, null).partialCharge = this.parseFloatStr (tokens[5]);
|
||||
}, "~A");
|
||||
});
|
||||
@@ -0,0 +1,161 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.BilbaoReader", ["java.lang.Float", "JU.PT", "$.SB", "$.V3", "JU.Vibration"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.getHigh = false;
|
||||
this.getSym = false;
|
||||
this.normDispl = false;
|
||||
this.doDisplace = false;
|
||||
this.kvec = null;
|
||||
this.i0 = 0;
|
||||
this.nAtoms = 0;
|
||||
this.isBCSfile = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "BilbaoReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.normDispl = !this.checkFilterKey ("NONORM");
|
||||
this.doDisplace = this.isTrajectory;
|
||||
this.getSym = true;
|
||||
this.getHigh = this.checkFilterKey ("HIGH") && !this.doDisplace;
|
||||
this.asc.vibScale = 1;
|
||||
this.appendLoadNote ("Bilbao Crystallographic Server\ncryst@wm.lc.ehu.es");
|
||||
if (this.rd ().indexOf ("<") < 0) {
|
||||
this.readBilbaoDataFile ();
|
||||
this.continuing = false;
|
||||
}});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.contains (">Bilbao Crystallographic Server<")) {
|
||||
this.line = this.line.substring (this.line.lastIndexOf (">") + 1).trim ();
|
||||
if (this.line.length > 0) this.appendLoadNote (this.line + "\n");
|
||||
} else if (this.line.contains ("High symmetry structure<")) {
|
||||
if (this.getHigh) this.readBilbaoFormat ("high symmetry", NaN);
|
||||
} else if (this.line.contains ("Low symmetry structure<")) {
|
||||
if (!this.doDisplace) this.readBilbaoFormat ("low symmetry", NaN);
|
||||
} else if (this.line.contains ("structure in the subgroup basis<")) {
|
||||
if (!this.doDisplace) this.readBilbaoFormat ("high symmetry in the subgroup basis", NaN);
|
||||
} else if (this.line.contains ("Low symmetry structure after the origin shift<")) {
|
||||
this.readBilbaoFormat ("low symmetry after origin shift", NaN);
|
||||
} else if (this.line.contains ("<h3>Irrep:")) {
|
||||
this.readVirtual ();
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBilbaoDataFile",
|
||||
function () {
|
||||
this.isBCSfile = true;
|
||||
this.checkComment ();
|
||||
while (this.line != null) {
|
||||
this.readBilbaoFormat (null, NaN);
|
||||
if (this.rdLine () == null || this.line.indexOf ("##disp-par##") < 0) {
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
} else {
|
||||
this.readDisplacements (1);
|
||||
this.rdLine ();
|
||||
}}
|
||||
});
|
||||
Clazz.defineMethod (c$, "checkComment",
|
||||
function () {
|
||||
if (!this.line.startsWith ("#") || this.line.indexOf ("disp-par") >= 0) return false;
|
||||
if (this.isBCSfile) {
|
||||
this.appendLoadNote (this.line);
|
||||
if (this.line.startsWith ("# Title:")) this.asc.setAtomSetName (this.line.substring (8).trim ());
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBilbaoFormat",
|
||||
function (title, fAmp) {
|
||||
this.setFractionalCoordinates (true);
|
||||
if (!this.doGetModel (++this.modelNumber, title)) return;
|
||||
this.asc.newAtomSet ();
|
||||
if (this.line.startsWith ("Bilbao Crys:")) {
|
||||
title = this.line.substring (13).trim ();
|
||||
this.rdLine ();
|
||||
}this.setTitle (title);
|
||||
var ptPre = this.line.indexOf ("<pre>");
|
||||
if (ptPre >= 0) this.line = this.line.substring (ptPre + 5);
|
||||
var intTableNo = this.parseIntStr (this.line);
|
||||
if (intTableNo == 0) {
|
||||
this.setSpaceGroupName ("bilbao:" + this.line.substring (2));
|
||||
} else {
|
||||
while (intTableNo < 0 && this.rdLine () != null) intTableNo = this.parseIntStr (this.line);
|
||||
|
||||
this.setSpaceGroupName ("bilbao:" + intTableNo);
|
||||
}var data = Clazz.newFloatArray (6, 0);
|
||||
this.fillFloatArray (null, 0, data);
|
||||
for (var i = 0; i < 6; i++) this.setUnitCellItem (i, data[i]);
|
||||
|
||||
this.i0 = this.asc.ac;
|
||||
this.nAtoms = this.parseIntStr (this.rdLine ());
|
||||
for (var i = this.nAtoms; --i >= 0; ) {
|
||||
var tokens = JU.PT.getTokens (this.rdLine ());
|
||||
if (!this.getSym && tokens[1].contains ("_")) continue;
|
||||
if (tokens.length == 3) this.addAtomXYZSymName (tokens, 0, "Be", "Be1");
|
||||
else this.addAtomXYZSymName (tokens, 3, tokens[0], tokens[0] + tokens[1]);
|
||||
}
|
||||
if (Float.isNaN (fAmp)) {
|
||||
if (ptPre >= 0) this.applySymmetryAndSetTrajectory ();
|
||||
return;
|
||||
}this.line = null;
|
||||
this.readDisplacements (fAmp);
|
||||
}, "~S,~N");
|
||||
Clazz.defineMethod (c$, "readDisplacements",
|
||||
function (fAmp) {
|
||||
for (var i = 0; i < this.nAtoms; i++) {
|
||||
if (this.line == null) this.rdLine ();
|
||||
var tokens = JU.PT.split (this.line, "x|x");
|
||||
if (this.getSym || !tokens[0].contains ("_")) this.asc.atoms[this.i0 + i].vib = JU.V3.new3 (this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[2]), this.parseFloatStr (tokens[3]));
|
||||
this.line = null;
|
||||
}
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
for (var i = this.asc.ac; --i >= this.i0; ) {
|
||||
var a = this.asc.atoms[i];
|
||||
if (a.vib != null) {
|
||||
var v = new JU.Vibration ();
|
||||
v.setT (a.vib);
|
||||
a.vib = v;
|
||||
this.asc.getSymmetry ().toCartesian (v, true);
|
||||
v.scale (1 / fAmp);
|
||||
}}
|
||||
this.appendLoadNote ((this.asc.ac - this.i0) + " displacements");
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "setTitle",
|
||||
function (title) {
|
||||
if (title != null) {
|
||||
this.asc.setAtomSetName (title);
|
||||
this.appendLoadNote (title);
|
||||
}}, "~S");
|
||||
Clazz.defineMethod (c$, "rdLine",
|
||||
function () {
|
||||
while (this.rd () != null && (this.line.length == 0 || this.checkComment ())) {
|
||||
}
|
||||
return this.line;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readVirtual",
|
||||
function () {
|
||||
if (this.line.contains ("<h3>K-vector:")) this.kvec = this.line.substring (this.line.indexOf ("("), this.line.indexOf (")") + 1);
|
||||
var s = this.getLinesUntil ("\"BCS\"");
|
||||
var pt = s.indexOf ("The amplitude");
|
||||
pt = s.indexOf ("=", pt);
|
||||
var amp = s.substring (pt + 2, s.indexOf (" ", pt + 2));
|
||||
var fAmp = (this.normDispl ? this.parseFloatStr (amp) : 1);
|
||||
var irrep = this.getAttr (s, "irrep");
|
||||
if (irrep.indexOf (":") >= 0) irrep = irrep.substring (0, irrep.indexOf (":"));
|
||||
this.line = this.line.substring (this.line.indexOf ("value=") + 7);
|
||||
this.readBilbaoFormat (this.kvec + " " + irrep + " (" + amp + " Ang.)", fAmp);
|
||||
});
|
||||
Clazz.defineMethod (c$, "getAttr",
|
||||
function (s, key) {
|
||||
var pt = s.indexOf ("value", s.indexOf ("\"" + key + "\""));
|
||||
s = JU.PT.getQuotedStringAt (s, pt);
|
||||
s = JU.PT.rep (s, "<i>", "");
|
||||
s = JU.PT.rep (s, "</i>", "");
|
||||
return s.trim ();
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "getLinesUntil",
|
||||
function (key) {
|
||||
var sb = new JU.SB ();
|
||||
do {
|
||||
sb.append (this.line);
|
||||
} while (!this.rd ().contains (key));
|
||||
return sb.toString ();
|
||||
}, "~S");
|
||||
});
|
||||
@@ -0,0 +1,523 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.CastepReader", ["java.lang.Double", "$.Float", "JU.DF", "$.Lst", "$.M4", "$.P3", "$.PT", "$.V3", "J.adapter.smarter.Atom", "JU.Escape", "$.Logger", "$.Tensor"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.tokens = null;
|
||||
this.isPhonon = false;
|
||||
this.isTS = false;
|
||||
this.isOutput = false;
|
||||
this.isCell = false;
|
||||
this.a = 0;
|
||||
this.b = 0;
|
||||
this.c = 0;
|
||||
this.alpha = 0;
|
||||
this.beta = 0;
|
||||
this.gamma = 0;
|
||||
this.abc = null;
|
||||
this.ac = 0;
|
||||
this.atomPts = null;
|
||||
this.havePhonons = false;
|
||||
this.lastQPt = null;
|
||||
this.qpt2 = 0;
|
||||
this.desiredQpt = null;
|
||||
this.desiredQ = null;
|
||||
this.chargeType = "MULL";
|
||||
this.isAllQ = false;
|
||||
this.haveCharges = false;
|
||||
this.tsType = null;
|
||||
this.matSupercell = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "CastepReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.abc = new Array (3);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
if (this.filter != null) {
|
||||
this.chargeType = this.getFilter ("CHARGE=");
|
||||
if (this.chargeType != null && this.chargeType.length > 4) this.chargeType = this.chargeType.substring (0, 4);
|
||||
this.filter = this.filter.$replace ('(', '{').$replace (')', '}');
|
||||
this.filter = JU.PT.rep (this.filter, " ", " ");
|
||||
this.isAllQ = this.checkFilterKey ("Q=ALL");
|
||||
this.tsType = this.getFilter ("TSTYPE=");
|
||||
if (!this.isAllQ && this.filter.indexOf ("{") >= 0) this.setDesiredQpt (this.filter.substring (this.filter.indexOf ("{")));
|
||||
this.filter = JU.PT.rep (this.filter, "-PT", "");
|
||||
}this.continuing = this.readFileData ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "setDesiredQpt",
|
||||
function (s) {
|
||||
this.desiredQpt = new JU.V3 ();
|
||||
this.desiredQ = "";
|
||||
var num = 1;
|
||||
var denom = 1;
|
||||
var ipt = 0;
|
||||
var xyz = 0;
|
||||
var useSpace = (s.indexOf (',') < 0);
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
var c = s.charAt (i);
|
||||
switch (c) {
|
||||
case '{':
|
||||
ipt = i + 1;
|
||||
num = 1;
|
||||
denom = 1;
|
||||
break;
|
||||
case '/':
|
||||
num = this.parseFloatStr (s.substring (ipt, i));
|
||||
ipt = i + 1;
|
||||
denom = 0;
|
||||
break;
|
||||
case ',':
|
||||
case ' ':
|
||||
case '}':
|
||||
if (c == '}') this.desiredQ = s.substring (0, i + 1);
|
||||
else if ((c == ' ') != useSpace) break;
|
||||
if (denom == 0) {
|
||||
denom = this.parseFloatStr (s.substring (ipt, i));
|
||||
} else {
|
||||
num = this.parseFloatStr (s.substring (ipt, i));
|
||||
}num /= denom;
|
||||
switch (xyz++) {
|
||||
case 0:
|
||||
this.desiredQpt.x = num;
|
||||
break;
|
||||
case 1:
|
||||
this.desiredQpt.y = num;
|
||||
break;
|
||||
case 2:
|
||||
this.desiredQpt.z = num;
|
||||
break;
|
||||
}
|
||||
denom = 1;
|
||||
if (c == '}') i = s.length;
|
||||
ipt = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
JU.Logger.info ("Looking for q-pt=" + this.desiredQpt);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readFileData",
|
||||
function () {
|
||||
while (this.tokenizeCastepCell () > 0) if (this.tokens.length >= 2 && this.tokens[0].equalsIgnoreCase ("%BLOCK")) {
|
||||
JU.Logger.info (this.line);
|
||||
if (this.tokens[1].equalsIgnoreCase ("LATTICE_ABC")) {
|
||||
this.readLatticeAbc ();
|
||||
continue;
|
||||
}if (this.tokens[1].equalsIgnoreCase ("LATTICE_CART")) {
|
||||
this.readLatticeCart ();
|
||||
continue;
|
||||
}if (this.tokens[1].equalsIgnoreCase ("POSITIONS_FRAC")) {
|
||||
this.setFractionalCoordinates (true);
|
||||
this.readPositionsFrac ();
|
||||
continue;
|
||||
}if (this.tokens[1].equalsIgnoreCase ("POSITIONS_ABS")) {
|
||||
this.setFractionalCoordinates (false);
|
||||
this.readPositionsAbs ();
|
||||
continue;
|
||||
}}
|
||||
if (this.isPhonon || this.isOutput || this.isTS) {
|
||||
if (this.isPhonon) {
|
||||
this.isTrajectory = (this.desiredVibrationNumber <= 0);
|
||||
this.asc.allowMultiple = false;
|
||||
}return true;
|
||||
}return false;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.isOutput) {
|
||||
if (this.line.contains ("Real Lattice(A)")) {
|
||||
this.readOutputUnitCell ();
|
||||
} else if (this.line.contains ("Fractional coordinates of atoms")) {
|
||||
if (this.doGetModel (++this.modelNumber, null)) {
|
||||
this.readOutputAtoms ();
|
||||
}} else if (this.doProcessLines && (this.line.contains ("Atomic Populations (Mulliken)") || this.line.contains ("Hirshfield Charge (e)"))) {
|
||||
this.readOutputCharges ();
|
||||
} else if (this.doProcessLines && this.line.contains ("Born Effective Charges")) {
|
||||
this.readOutputBornChargeTensors ();
|
||||
} else if (this.line.contains ("Final energy ")) {
|
||||
this.readEnergy (3, null);
|
||||
} else if (this.line.contains ("Dispersion corrected final energy*")) {
|
||||
this.readEnergy (5, null);
|
||||
} else if (this.line.contains ("Total energy corrected")) {
|
||||
this.readEnergy (8, null);
|
||||
}return true;
|
||||
}if (this.line.contains ("<-- E")) {
|
||||
this.readPhononTrajectories ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Unit cell vectors") == 1) {
|
||||
this.readPhononUnitCell ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("Fractional Co-ordinates") >= 0) {
|
||||
this.readPhononFractionalCoord ();
|
||||
return true;
|
||||
}if (this.line.indexOf ("q-pt") >= 0) {
|
||||
this.readPhononFrequencies ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readOutputUnitCell",
|
||||
function () {
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.asc.newAtomSetClear (false);
|
||||
this.setFractionalCoordinates (true);
|
||||
this.abc = this.read3Vectors (false);
|
||||
this.setLatticeVectors ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readOutputAtoms",
|
||||
function () {
|
||||
this.readLines (2);
|
||||
while (this.rd ().indexOf ("xxx") < 0) {
|
||||
var atom = new J.adapter.smarter.Atom ();
|
||||
this.tokens = this.getTokens ();
|
||||
atom.elementSymbol = this.tokens[1];
|
||||
atom.atomName = this.tokens[1] + this.tokens[2];
|
||||
this.asc.addAtomWithMappedName (atom);
|
||||
this.setAtomCoordTokens (atom, this.tokens, 3);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readEnergy",
|
||||
function (pt, prefix) {
|
||||
if (this.isTrajectory) this.applySymmetryAndSetTrajectory ();
|
||||
this.tokens = this.getTokens ();
|
||||
try {
|
||||
var energy = Double.$valueOf (Double.parseDouble (this.tokens[pt]));
|
||||
this.asc.setAtomSetName (prefix + "Energy = " + energy + " eV");
|
||||
this.asc.setAtomSetEnergy ("" + energy, energy.floatValue ());
|
||||
this.asc.setCurrentModelInfo ("Energy", energy);
|
||||
} catch (e) {
|
||||
if (Clazz.exceptionOf (e, Exception)) {
|
||||
this.appendLoadNote ("CASTEP Energy could not be read: " + this.line);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}, "~N,~S");
|
||||
Clazz.defineMethod (c$, "readPhononTrajectories",
|
||||
function () {
|
||||
if (!this.isTS) this.isTrajectory = (this.desiredVibrationNumber <= 0);
|
||||
if (this.isTrajectory) this.asc.setTrajectory ();
|
||||
this.doApplySymmetry = true;
|
||||
while (this.line != null && this.line.contains ("<-- E")) {
|
||||
var skip = (this.isTS && this.tsType != null && this.prevline.indexOf (this.tsType) < 0);
|
||||
if (!skip) {
|
||||
this.asc.newAtomSetClear (false);
|
||||
if (this.isTS) this.readEnergy (0, JU.PT.getTokens (this.prevline + " -")[0] + " ");
|
||||
this.discardLinesUntilContains ("<-- h");
|
||||
this.setSpaceGroupName ("P1");
|
||||
this.abc = this.read3Vectors (true);
|
||||
this.setLatticeVectors ();
|
||||
this.setFractionalCoordinates (false);
|
||||
this.discardLinesUntilContains ("<-- R");
|
||||
while (this.line != null && this.line.contains ("<-- R")) {
|
||||
this.tokens = this.getTokens ();
|
||||
this.setAtomCoordScaled (null, this.tokens, 2, 0.5291772).elementSymbol = this.tokens[0];
|
||||
this.rd ();
|
||||
}
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
}this.discardLinesUntilContains ("<-- E");
|
||||
}
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
if (this.isPhonon || this.isOutput || this.isTS) {
|
||||
this.isTrajectory = false;
|
||||
} else {
|
||||
this.doApplySymmetry = true;
|
||||
this.setLatticeVectors ();
|
||||
var nAtoms = this.asc.ac;
|
||||
for (var i = 0; i < nAtoms; i++) this.setAtomCoord (this.asc.atoms[i]);
|
||||
|
||||
}this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "setLatticeVectors",
|
||||
function () {
|
||||
if (this.abc[0] == null) {
|
||||
this.setUnitCell (this.a, this.b, this.c, this.alpha, this.beta, this.gamma);
|
||||
return;
|
||||
}var lv = Clazz.newFloatArray (3, 0);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
lv[0] = this.abc[i].x;
|
||||
lv[1] = this.abc[i].y;
|
||||
lv[2] = this.abc[i].z;
|
||||
this.addExplicitLatticeVector (i, lv, 0);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readLatticeAbc",
|
||||
function () {
|
||||
if (this.tokenizeCastepCell () == 0) return;
|
||||
var factor = this.readLengthUnit (this.tokens[0]);
|
||||
if (this.tokens.length >= 3) {
|
||||
this.a = this.parseFloatStr (this.tokens[0]) * factor;
|
||||
this.b = this.parseFloatStr (this.tokens[1]) * factor;
|
||||
this.c = this.parseFloatStr (this.tokens[2]) * factor;
|
||||
} else {
|
||||
JU.Logger.warn ("error reading a,b,c in %BLOCK LATTICE_ABC in CASTEP .cell file");
|
||||
return;
|
||||
}if (this.tokenizeCastepCell () == 0) return;
|
||||
if (this.tokens.length >= 3) {
|
||||
this.alpha = this.parseFloatStr (this.tokens[0]);
|
||||
this.beta = this.parseFloatStr (this.tokens[1]);
|
||||
this.gamma = this.parseFloatStr (this.tokens[2]);
|
||||
} else {
|
||||
JU.Logger.warn ("error reading alpha,beta,gamma in %BLOCK LATTICE_ABC in CASTEP .cell file");
|
||||
}});
|
||||
Clazz.defineMethod (c$, "readLatticeCart",
|
||||
function () {
|
||||
if (this.tokenizeCastepCell () == 0) return;
|
||||
var factor = this.readLengthUnit (this.tokens[0]);
|
||||
var x;
|
||||
var y;
|
||||
var z;
|
||||
for (var i = 0; i < 3; i++) {
|
||||
if (this.tokens.length >= 3) {
|
||||
x = this.parseFloatStr (this.tokens[0]) * factor;
|
||||
y = this.parseFloatStr (this.tokens[1]) * factor;
|
||||
z = this.parseFloatStr (this.tokens[2]) * factor;
|
||||
this.abc[i] = JU.V3.new3 (x, y, z);
|
||||
} else {
|
||||
JU.Logger.warn ("error reading coordinates of lattice vector " + Integer.toString (i + 1) + " in %BLOCK LATTICE_CART in CASTEP .cell file");
|
||||
return;
|
||||
}if (this.tokenizeCastepCell () == 0) return;
|
||||
}
|
||||
this.a = this.abc[0].length ();
|
||||
this.b = this.abc[1].length ();
|
||||
this.c = this.abc[2].length ();
|
||||
this.alpha = (this.abc[1].angle (this.abc[2]) * 57.29578);
|
||||
this.beta = (this.abc[2].angle (this.abc[0]) * 57.29578);
|
||||
this.gamma = (this.abc[0].angle (this.abc[1]) * 57.29578);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPositionsFrac",
|
||||
function () {
|
||||
if (this.tokenizeCastepCell () == 0) return;
|
||||
this.readAtomData (1.0);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPositionsAbs",
|
||||
function () {
|
||||
if (this.tokenizeCastepCell () == 0) return;
|
||||
var factor = this.readLengthUnit (this.tokens[0]);
|
||||
this.readAtomData (factor);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readLengthUnit",
|
||||
function (units) {
|
||||
var factor = 1.0;
|
||||
for (var i = 0; i < J.adapter.readers.xtal.CastepReader.lengthUnitIds.length; i++) if (units.equalsIgnoreCase (J.adapter.readers.xtal.CastepReader.lengthUnitIds[i])) {
|
||||
factor = J.adapter.readers.xtal.CastepReader.lengthUnitFactors[i];
|
||||
this.tokenizeCastepCell ();
|
||||
break;
|
||||
}
|
||||
return factor;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readAtomData",
|
||||
function (factor) {
|
||||
do {
|
||||
if (this.tokens.length >= 4) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
var pt = this.tokens[0].indexOf (":");
|
||||
if (pt >= 0) {
|
||||
atom.elementSymbol = this.tokens[0].substring (0, pt);
|
||||
atom.atomName = this.tokens[0];
|
||||
} else {
|
||||
atom.elementSymbol = this.tokens[0];
|
||||
}atom.set (this.parseFloatStr (this.tokens[1]), this.parseFloatStr (this.tokens[2]), this.parseFloatStr (this.tokens[3]));
|
||||
atom.scale (factor);
|
||||
} else {
|
||||
JU.Logger.warn ("cannot read line with CASTEP atom data: " + this.line);
|
||||
}} while (this.tokenizeCastepCell () > 0 && !this.tokens[0].equalsIgnoreCase ("%ENDBLOCK"));
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "tokenizeCastepCell",
|
||||
function () {
|
||||
while (this.rd () != null) {
|
||||
if ((this.line = this.line.trim ()).length == 0 || this.line.startsWith ("#") || this.line.startsWith ("!")) continue;
|
||||
if (!this.isCell) {
|
||||
if (this.line.startsWith ("%")) {
|
||||
this.isCell = true;
|
||||
break;
|
||||
}if (this.line.startsWith ("LST")) {
|
||||
this.isTS = true;
|
||||
JU.Logger.info ("reading CASTEP .ts file");
|
||||
return -1;
|
||||
}if (this.line.startsWith ("BEGIN header")) {
|
||||
this.isPhonon = true;
|
||||
JU.Logger.info ("reading CASTEP .phonon file");
|
||||
return -1;
|
||||
}if (this.line.contains ("CASTEP")) {
|
||||
this.isOutput = true;
|
||||
JU.Logger.info ("reading CASTEP .castep file");
|
||||
return -1;
|
||||
}}break;
|
||||
}
|
||||
return (this.line == null ? 0 : (this.tokens = this.getTokens ()).length);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readOutputBornChargeTensors",
|
||||
function () {
|
||||
if (this.rd ().indexOf ("--------") < 0) return;
|
||||
var atoms = this.asc.atoms;
|
||||
this.appendLoadNote ("Ellipsoids: Born Charge Tensors");
|
||||
while (this.rd ().indexOf ('=') < 0) this.getTensor (atoms[this.readOutputAtomIndex ()], this.line.substring (12));
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "readOutputAtomIndex",
|
||||
function () {
|
||||
this.tokens = this.getTokens ();
|
||||
return this.asc.getAtomIndex (this.tokens[0] + this.tokens[1]);
|
||||
});
|
||||
Clazz.defineMethod (c$, "getTensor",
|
||||
function (atom, line0) {
|
||||
var data = Clazz.newFloatArray (9, 0);
|
||||
var a = Clazz.newDoubleArray (3, 3, 0);
|
||||
this.fillFloatArray (line0, 0, data);
|
||||
JU.Logger.info ("tensor " + atom.atomName + "\t" + JU.Escape.eAF (data));
|
||||
for (var p = 0, i = 0; i < 3; i++) for (var j = 0; j < 3; j++) a[i][j] = data[p++];
|
||||
|
||||
|
||||
atom.addTensor (( new JU.Tensor ()).setFromAsymmetricTensor (a, "charge", atom.atomName + " " + line0), null, false);
|
||||
if (!this.haveCharges) this.appendLoadNote ("Ellipsoids set \"charge\": Born Effective Charges");
|
||||
this.haveCharges = true;
|
||||
}, "J.adapter.smarter.Atom,~S");
|
||||
Clazz.defineMethod (c$, "readOutputCharges",
|
||||
function () {
|
||||
if (this.line.toUpperCase ().indexOf (this.chargeType) < 0) return;
|
||||
JU.Logger.info ("reading charges: " + this.line);
|
||||
this.readLines (2);
|
||||
var haveSpin = (this.line.indexOf ("Spin") >= 0);
|
||||
this.rd ();
|
||||
var atoms = this.asc.atoms;
|
||||
var spins = (haveSpin ? Clazz.newFloatArray (atoms.length, 0) : null);
|
||||
if (spins != null) for (var i = 0; i < spins.length; i++) spins[i] = 0;
|
||||
|
||||
while (this.rd () != null && this.line.indexOf ('=') < 0) {
|
||||
var index = this.readOutputAtomIndex ();
|
||||
var charge = this.parseFloatStr (this.tokens[haveSpin ? this.tokens.length - 2 : this.tokens.length - 1]);
|
||||
atoms[index].partialCharge = charge;
|
||||
if (haveSpin) spins[index] = this.parseFloatStr (this.tokens[this.tokens.length - 1]);
|
||||
}
|
||||
if (haveSpin) this.asc.setAtomProperties ("spin", spins, -1, false);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPhononUnitCell",
|
||||
function () {
|
||||
this.abc = this.read3Vectors (this.line.indexOf ("bohr") >= 0);
|
||||
this.setSpaceGroupName ("P1");
|
||||
this.setLatticeVectors ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPhononFractionalCoord",
|
||||
function () {
|
||||
this.setFractionalCoordinates (true);
|
||||
while (this.rd () != null && this.line.indexOf ("END") < 0) {
|
||||
this.tokens = this.getTokens ();
|
||||
this.addAtomXYZSymName (this.tokens, 1, this.tokens[4], null).bfactor = this.parseFloatStr (this.tokens[5]);
|
||||
}
|
||||
this.ac = this.asc.ac;
|
||||
this.atomPts = new Array (this.ac);
|
||||
var atoms = this.asc.atoms;
|
||||
for (var i = 0; i < this.ac; i++) this.atomPts[i] = JU.P3.newP (atoms[i]);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPhononFrequencies",
|
||||
function () {
|
||||
this.tokens = this.getTokens ();
|
||||
var v = new JU.V3 ();
|
||||
var qvec = JU.V3.new3 (this.parseFloatStr (this.tokens[2]), this.parseFloatStr (this.tokens[3]), this.parseFloatStr (this.tokens[4]));
|
||||
var fcoord = this.getFractionalCoord (qvec);
|
||||
var qtoks = "{" + this.tokens[2] + " " + this.tokens[3] + " " + this.tokens[4] + "}";
|
||||
if (fcoord == null) fcoord = qtoks;
|
||||
else fcoord = "{" + fcoord + "}";
|
||||
var isOK = this.isAllQ;
|
||||
var isSecond = (this.tokens[1].equals (this.lastQPt));
|
||||
this.qpt2 = (isSecond ? this.qpt2 + 1 : 1);
|
||||
this.lastQPt = this.tokens[1];
|
||||
if (!isOK && this.checkFilterKey ("Q=")) {
|
||||
if (this.desiredQpt != null) {
|
||||
v.sub2 (this.desiredQpt, qvec);
|
||||
if (v.length () < 0.001) fcoord = this.desiredQ;
|
||||
}isOK = (this.checkFilterKey ("Q=" + fcoord + "." + this.qpt2 + ";") || this.checkFilterKey ("Q=" + this.lastQPt + "." + this.qpt2 + ";") || !isSecond && this.checkFilterKey ("Q=" + fcoord + ";") || !isSecond && this.checkFilterKey ("Q=" + this.lastQPt + ";"));
|
||||
if (!isOK) return;
|
||||
}var isGammaPoint = (qvec.length () == 0);
|
||||
var nx = 1;
|
||||
var ny = 1;
|
||||
var nz = 1;
|
||||
if (this.ptSupercell != null && !isOK && !isSecond) {
|
||||
this.matSupercell = new JU.M4 ();
|
||||
this.matSupercell.m00 = this.ptSupercell.x;
|
||||
this.matSupercell.m11 = this.ptSupercell.y;
|
||||
this.matSupercell.m22 = this.ptSupercell.z;
|
||||
this.matSupercell.m33 = 1;
|
||||
JU.Logger.info ("Using supercell \n" + this.matSupercell);
|
||||
nx = this.ptSupercell.x;
|
||||
ny = this.ptSupercell.y;
|
||||
nz = this.ptSupercell.z;
|
||||
var dx = (qvec.x == 0 ? 1 : qvec.x) * nx;
|
||||
var dy = (qvec.y == 0 ? 1 : qvec.y) * ny;
|
||||
var dz = (qvec.z == 0 ? 1 : qvec.z) * nz;
|
||||
if ((nx != 1 || ny != 1 || nz != 1) && isGammaPoint || !J.adapter.readers.xtal.CastepReader.isInt (dx) || !J.adapter.readers.xtal.CastepReader.isInt (dy) || !J.adapter.readers.xtal.CastepReader.isInt (dz)) return;
|
||||
isOK = true;
|
||||
}if (this.ptSupercell == null || !this.havePhonons) this.appendLoadNote (this.line);
|
||||
if (!isOK && isSecond) return;
|
||||
if (!isOK && (this.ptSupercell == null) == !isGammaPoint) return;
|
||||
if (this.havePhonons && !this.isAllQ) return;
|
||||
this.havePhonons = true;
|
||||
var qname = "q=" + this.lastQPt + " " + fcoord;
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
if (isGammaPoint) qvec = null;
|
||||
var freqs = new JU.Lst ();
|
||||
while (this.rd () != null && this.line.indexOf ("Phonon") < 0) {
|
||||
this.tokens = this.getTokens ();
|
||||
freqs.addLast (Float.$valueOf (this.parseFloatStr (this.tokens[1])));
|
||||
}
|
||||
this.rd ();
|
||||
var frequencyCount = freqs.size ();
|
||||
var data = Clazz.newFloatArray (8, 0);
|
||||
var t = new JU.V3 ();
|
||||
this.asc.setCollectionName (qname);
|
||||
for (var i = 0; i < frequencyCount; i++) {
|
||||
if (!this.doGetVibration (++this.vibrationNumber)) {
|
||||
for (var j = 0; j < this.ac; j++) this.rd ();
|
||||
|
||||
continue;
|
||||
}if (this.desiredVibrationNumber <= 0) {
|
||||
if (!this.isTrajectory) {
|
||||
this.cloneLastAtomSet (this.ac, this.atomPts);
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
}}this.symmetry = this.asc.getSymmetry ();
|
||||
var iatom = this.asc.getLastAtomSetAtomIndex ();
|
||||
var freq = freqs.get (i).floatValue ();
|
||||
var atoms = this.asc.atoms;
|
||||
var aCount = this.asc.ac;
|
||||
for (var j = 0; j < this.ac; j++) {
|
||||
this.fillFloatArray (null, 0, data);
|
||||
for (var k = iatom++; k < aCount; k++) if (atoms[k].atomSite == j) {
|
||||
t.sub2 (atoms[k], atoms[atoms[k].atomSite]);
|
||||
if (this.matSupercell != null) this.matSupercell.rotTrans (t);
|
||||
this.setPhononVector (data, atoms[k], t, qvec, v);
|
||||
this.asc.addVibrationVectorWithSymmetry (k, v.x, v.y, v.z, true);
|
||||
}
|
||||
}
|
||||
if (this.isTrajectory) this.asc.setTrajectory ();
|
||||
this.asc.setAtomSetFrequency (null, null, "" + freq, null);
|
||||
this.asc.setAtomSetName (JU.DF.formatDecimal (freq, 2) + " cm-1 " + qname);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getFractionalCoord",
|
||||
function (qvec) {
|
||||
return (this.symmetry != null && J.adapter.readers.xtal.CastepReader.isInt (qvec.x * 12) && J.adapter.readers.xtal.CastepReader.isInt (qvec.y * 12) && J.adapter.readers.xtal.CastepReader.isInt (qvec.z * 12) ? this.symmetry.fcoord (qvec) : null);
|
||||
}, "JU.V3");
|
||||
c$.isInt = Clazz.defineMethod (c$, "isInt",
|
||||
function (f) {
|
||||
return (Math.abs (f - Math.round (f)) < 0.001);
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "setPhononVector",
|
||||
function (data, atom, rTrans, qvec, v) {
|
||||
if (qvec == null) {
|
||||
v.set (data[2], data[4], data[6]);
|
||||
} else {
|
||||
var phase = qvec.dot (rTrans);
|
||||
var cosph = Math.cos (6.283185307179586 * phase);
|
||||
var sinph = Math.sin (6.283185307179586 * phase);
|
||||
v.x = (cosph * data[2] - sinph * data[3]);
|
||||
v.y = (cosph * data[4] - sinph * data[5]);
|
||||
v.z = (cosph * data[6] - sinph * data[7]);
|
||||
}v.scale (Math.sqrt (1 / atom.bfactor));
|
||||
}, "~A,J.adapter.smarter.Atom,JU.V3,JU.V3,JU.V3");
|
||||
Clazz.defineStatics (c$,
|
||||
"RAD_TO_DEG", (57.29577951308232),
|
||||
"lengthUnitIds", Clazz.newArray (-1, ["bohr", "m", "cm", "nm", "ang", "a0"]),
|
||||
"lengthUnitFactors", Clazz.newFloatArray (-1, [0.5291772, 1E10, 1E8, 1E1, 1.0, 0.5291772]),
|
||||
"TWOPI", 6.283185307179586);
|
||||
});
|
||||
@@ -0,0 +1,165 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader", "JU.V3"], "J.adapter.readers.xtal.CgdReader", ["java.lang.Character", "java.util.Hashtable", "JU.Lst", "$.M3", "$.P3", "$.PT", "J.adapter.smarter.Bond", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.noBondSym = false;
|
||||
this.tokens = null;
|
||||
this.htEdges = null;
|
||||
this.lastName = null;
|
||||
this.edgeData = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "CgdReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.setFractionalCoordinates (true);
|
||||
this.asc.setNoAutoBond ();
|
||||
this.asc.vibScale = 1;
|
||||
this.forceSymmetry (!this.checkFilterKey ("NOPACK"));
|
||||
this.noBondSym = this.checkFilterKey ("NOBONDSYM");
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
this.line = this.line.trim ();
|
||||
if (this.line.length == 0 || this.line.startsWith ("#")) return true;
|
||||
if (!Character.isLetter (this.line.charAt (0))) this.line = this.lastName + " " + this.line;
|
||||
this.tokens = this.getTokens ();
|
||||
if (this.tokens.length > 0) {
|
||||
this.lastName = this.tokens[0].toUpperCase ();
|
||||
var pt = "NAME |CELL |GROUP|ATOM |EDGE |".indexOf (this.lastName);
|
||||
if (this.tokens.length > 1 && (pt == 0 || this.doProcessLines)) switch (pt) {
|
||||
case 0:
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.setFractionalCoordinates (true);
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetName (this.line.substring (6).trim ());
|
||||
this.htEdges = null;
|
||||
this.edgeData = null;
|
||||
break;
|
||||
case 6:
|
||||
for (var i = 0; i < 6; i++) this.setUnitCellItem (i, (i < 3 ? 10 : 1) * this.parseFloatStr (this.tokens[i + 1]));
|
||||
|
||||
break;
|
||||
case 12:
|
||||
this.setSpaceGroupName ("bilbao:" + this.group (this.tokens[1]));
|
||||
break;
|
||||
case 18:
|
||||
this.atom ();
|
||||
break;
|
||||
case 24:
|
||||
if (!this.doApplySymmetry) break;
|
||||
if (this.edgeData == null) this.edgeData = new JU.Lst ();
|
||||
this.edgeData.addLast (this.line);
|
||||
break;
|
||||
}
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "group",
|
||||
function (name) {
|
||||
var name0 = null;
|
||||
if (name.charAt (0) == '"') name = name.substring (1, name.length - 1);
|
||||
var pt = ";P2=P121;P21=P1211;C2=C121;A2=A121;I2=I121;Pm=P1m1;Pc=P1c1;Pn=P1n1;Pa=P1a1;Cm=C1m1;Am=A1m1;Im=I1m1;Cc=C1c1;An=A1n1;Ia=I1a1;Aa=A1a1;Cn=C1n1;Ic=I1c1;P2/m=P12/m1;P21/m=P121/m1;C2/m=C12/m1;A2/m=A12/m1;I2/m=I12/m1;P2/c=P12/c1;P2/n=P12/n1;P2/a=P12/a1;P21/c=P121/c1;P21/n=P121/n1;P21/a=P121/a1;C2/c=C12/c1;A2/n=A12/n1;I2/a=I12/a1;A2/a=A12/a1;C2/n=C12/n1;I2/c=I12/c1;Pm3=Pm-3;Pn3=Pn-3;Fm3=Fm-3;Fd3=Fd-3;Im3=Im-3;Pa3=Pa-3;Ia3=Ia-3;Pm3m=Pm-3m;Pn3n=Pn-3n;Pm3n=Pm-3n;Pn3m=Pn-3m;Fm3m=Fm-3m;Fm3c=Fm-3c;Fd3m=Fd-3m;Fd3c=Fd-3c;Im3m=Im-3m;Ia3d=Ia-3d;".indexOf (";" + name + "=");
|
||||
if (pt >= 0) {
|
||||
name0 = name;
|
||||
name = ";P2=P121;P21=P1211;C2=C121;A2=A121;I2=I121;Pm=P1m1;Pc=P1c1;Pn=P1n1;Pa=P1a1;Cm=C1m1;Am=A1m1;Im=I1m1;Cc=C1c1;An=A1n1;Ia=I1a1;Aa=A1a1;Cn=C1n1;Ic=I1c1;P2/m=P12/m1;P21/m=P121/m1;C2/m=C12/m1;A2/m=A12/m1;I2/m=I12/m1;P2/c=P12/c1;P2/n=P12/n1;P2/a=P12/a1;P21/c=P121/c1;P21/n=P121/n1;P21/a=P121/a1;C2/c=C12/c1;A2/n=A12/n1;I2/a=I12/a1;A2/a=A12/a1;C2/n=C12/n1;I2/c=I12/c1;Pm3=Pm-3;Pn3=Pn-3;Fm3=Fm-3;Fd3=Fd-3;Im3=Im-3;Pa3=Pa-3;Ia3=Ia-3;Pm3m=Pm-3m;Pn3n=Pn-3n;Pm3n=Pm-3n;Pn3m=Pn-3m;Fm3m=Fm-3m;Fm3c=Fm-3c;Fd3m=Fd-3m;Fd3c=Fd-3c;Im3m=Im-3m;Ia3d=Ia-3d;".substring (";P2=P121;P21=P1211;C2=C121;A2=A121;I2=I121;Pm=P1m1;Pc=P1c1;Pn=P1n1;Pa=P1a1;Cm=C1m1;Am=A1m1;Im=I1m1;Cc=C1c1;An=A1n1;Ia=I1a1;Aa=A1a1;Cn=C1n1;Ic=I1c1;P2/m=P12/m1;P21/m=P121/m1;C2/m=C12/m1;A2/m=A12/m1;I2/m=I12/m1;P2/c=P12/c1;P2/n=P12/n1;P2/a=P12/a1;P21/c=P121/c1;P21/n=P121/n1;P21/a=P121/a1;C2/c=C12/c1;A2/n=A12/n1;I2/a=I12/a1;A2/a=A12/a1;C2/n=C12/n1;I2/c=I12/c1;Pm3=Pm-3;Pn3=Pn-3;Fm3=Fm-3;Fd3=Fd-3;Im3=Im-3;Pa3=Pa-3;Ia3=Ia-3;Pm3m=Pm-3m;Pn3n=Pn-3n;Pm3n=Pm-3n;Pn3m=Pn-3m;Fm3m=Fm-3m;Fm3c=Fm-3c;Fd3m=Fd-3m;Fd3c=Fd-3c;Im3m=Im-3m;Ia3d=Ia-3d;".indexOf ("=", pt) + 1, ";P2=P121;P21=P1211;C2=C121;A2=A121;I2=I121;Pm=P1m1;Pc=P1c1;Pn=P1n1;Pa=P1a1;Cm=C1m1;Am=A1m1;Im=I1m1;Cc=C1c1;An=A1n1;Ia=I1a1;Aa=A1a1;Cn=C1n1;Ic=I1c1;P2/m=P12/m1;P21/m=P121/m1;C2/m=C12/m1;A2/m=A12/m1;I2/m=I12/m1;P2/c=P12/c1;P2/n=P12/n1;P2/a=P12/a1;P21/c=P121/c1;P21/n=P121/n1;P21/a=P121/a1;C2/c=C12/c1;A2/n=A12/n1;I2/a=I12/a1;A2/a=A12/a1;C2/n=C12/n1;I2/c=I12/c1;Pm3=Pm-3;Pn3=Pn-3;Fm3=Fm-3;Fd3=Fd-3;Im3=Im-3;Pa3=Pa-3;Ia3=Ia-3;Pm3m=Pm-3m;Pn3n=Pn-3n;Pm3n=Pm-3n;Pn3m=Pn-3m;Fm3m=Fm-3m;Fm3c=Fm-3c;Fd3m=Fd-3m;Fd3c=Fd-3c;Im3m=Im-3m;Ia3d=Ia-3d;".indexOf (";", pt + 1));
|
||||
}JU.Logger.info ("CgdReader using GROUP " + name + (name0 == null ? "" : " alias of " + name0));
|
||||
return name;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "atom",
|
||||
function () {
|
||||
var name = this.getName (this.tokens[1]);
|
||||
var edgeCount = this.parseIntStr (this.tokens[2]);
|
||||
for (var i = 3; i < 6; i++) if (this.tokens[i].indexOf ("/") >= 0) this.tokens[i] = "" + JU.PT.parseFloatFraction (this.tokens[i]);
|
||||
|
||||
var a = this.addAtomXYZSymName (this.tokens, 3, null, name);
|
||||
if (!this.doApplySymmetry) return;
|
||||
this.asc.atomSymbolicMap.put (name, a);
|
||||
this.asc.addVibrationVector (a.index, 1, 3, 7);
|
||||
if (this.htEdges == null) this.htEdges = new java.util.Hashtable ();
|
||||
this.htEdges.put (a, new Array (edgeCount));
|
||||
});
|
||||
Clazz.defineMethod (c$, "getName",
|
||||
function (name) {
|
||||
return (name.charAt (0) == '"' ? name.substring (1, name.length - 1) : Character.isDigit (name.charAt (0)) ? "C" + name : name);
|
||||
}, "~S");
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.finalizeReaderASCR ();
|
||||
if (this.doApplySymmetry) this.finalizeNet ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "finalizeEdges",
|
||||
function () {
|
||||
var p;
|
||||
var name;
|
||||
var a;
|
||||
var atomEdges;
|
||||
for (var j = 0; j < this.edgeData.size (); j++) {
|
||||
this.tokens = JU.PT.getTokens (this.line = this.edgeData.get (j));
|
||||
switch (this.tokens.length) {
|
||||
case 3:
|
||||
name = this.getName (this.tokens[1]);
|
||||
a = this.asc.getAtomFromName (name);
|
||||
atomEdges = this.htEdges.get (a);
|
||||
p = this.asc.getAtomFromName (this.getName (this.tokens[2]));
|
||||
break;
|
||||
case 5:
|
||||
name = this.getName (this.tokens[1]);
|
||||
a = this.asc.getAtomFromName (name);
|
||||
atomEdges = this.htEdges.get (a);
|
||||
p = this.getCoord (2);
|
||||
break;
|
||||
case 7:
|
||||
atomEdges = this.htEdges.get (this.findAtom (this.getCoord (1)));
|
||||
p = this.getCoord (4);
|
||||
break;
|
||||
default:
|
||||
JU.Logger.error ("EDGE record skipped: " + this.line);
|
||||
continue;
|
||||
}
|
||||
for (var i = 0, n = atomEdges.length; i < n; i++) if (atomEdges[i] == null) {
|
||||
atomEdges[i] = JU.V3.newV (p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getCoord",
|
||||
function (i) {
|
||||
return JU.P3.new3 (JU.PT.parseFloatFraction (this.tokens[i++]), JU.PT.parseFloatFraction (this.tokens[i++]), JU.PT.parseFloatFraction (this.tokens[i++]));
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "finalizeNet",
|
||||
function () {
|
||||
this.finalizeEdges ();
|
||||
var m = new JU.M3 ();
|
||||
var pt = new JU.P3 ();
|
||||
for (var i = 0, n = this.asc.ac; i < n; i++) {
|
||||
var a = this.asc.atoms[i];
|
||||
var a0 = this.asc.atoms[a.atomSite];
|
||||
if (this.noBondSym && a !== a0) continue;
|
||||
var edges = this.htEdges.get (a0);
|
||||
if (edges == null) continue;
|
||||
var ix = Clazz.floatToInt (a.vib.x) + 7;
|
||||
var iy = Clazz.floatToInt (a.vib.y) + 7;
|
||||
var iz = Clazz.floatToInt (a.vib.z) + 7;
|
||||
m.setRowV (0, J.adapter.readers.xtal.CgdReader.vecs[ix]);
|
||||
m.setRowV (1, J.adapter.readers.xtal.CgdReader.vecs[iy]);
|
||||
m.setRowV (2, J.adapter.readers.xtal.CgdReader.vecs[iz]);
|
||||
for (var j = 0, n1 = edges.length; j < n1; j++) {
|
||||
pt.sub2 (edges[j], a0);
|
||||
m.rotate (pt);
|
||||
pt.add (a);
|
||||
var b = this.findAtom (pt);
|
||||
if (b != null) this.asc.addBond ( new J.adapter.smarter.Bond (a.index, b.index, 1));
|
||||
else if (pt.x >= 0 && pt.x <= 1 && pt.y >= 0 && pt.y <= 1 && pt.z >= 0 && pt.z <= 1) JU.Logger.error (" not found: i=" + i + " pt=" + pt + " for a=" + a + "\n a0=" + a0 + " edge[" + j + "]=" + edges[j] + "\n a.vib=" + a.vib + "\n m=" + m);
|
||||
}
|
||||
a.vib = null;
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "findAtom",
|
||||
function (pt) {
|
||||
for (var i = this.asc.ac; --i >= 0; ) if (this.asc.atoms[i].distanceSquared (pt) < 0.00001) return this.asc.atoms[i];
|
||||
|
||||
return null;
|
||||
}, "JU.P3");
|
||||
Clazz.defineStatics (c$,
|
||||
"SG_ALIASES", ";P2=P121;P21=P1211;C2=C121;A2=A121;I2=I121;Pm=P1m1;Pc=P1c1;Pn=P1n1;Pa=P1a1;Cm=C1m1;Am=A1m1;Im=I1m1;Cc=C1c1;An=A1n1;Ia=I1a1;Aa=A1a1;Cn=C1n1;Ic=I1c1;P2/m=P12/m1;P21/m=P121/m1;C2/m=C12/m1;A2/m=A12/m1;I2/m=I12/m1;P2/c=P12/c1;P2/n=P12/n1;P2/a=P12/a1;P21/c=P121/c1;P21/n=P121/n1;P21/a=P121/a1;C2/c=C12/c1;A2/n=A12/n1;I2/a=I12/a1;A2/a=A12/a1;C2/n=C12/n1;I2/c=I12/c1;Pm3=Pm-3;Pn3=Pn-3;Fm3=Fm-3;Fd3=Fd-3;Im3=Im-3;Pa3=Pa-3;Ia3=Ia-3;Pm3m=Pm-3m;Pn3n=Pn-3n;Pm3n=Pm-3n;Pn3m=Pn-3m;Fm3m=Fm-3m;Fm3c=Fm-3c;Fd3m=Fd-3m;Fd3c=Fd-3c;Im3m=Im-3m;Ia3d=Ia-3d;");
|
||||
c$.vecs = c$.prototype.vecs = Clazz.newArray (-1, [JU.V3.new3 (0, 0, -1), JU.V3.new3 (1, 0, -1), null, JU.V3.new3 (0, 1, -1), JU.V3.new3 (0, -1, 0), JU.V3.new3 (1, -1, 0), JU.V3.new3 (-1, 0, 0), null, JU.V3.new3 (1, 0, 0), JU.V3.new3 (-1, 1, 0), JU.V3.new3 (0, 1, 0), JU.V3.new3 (0, -1, 1), null, JU.V3.new3 (-1, 0, 1), JU.V3.new3 (0, 0, 1)]);
|
||||
});
|
||||
@@ -0,0 +1,553 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader", "JU.P3"], "J.adapter.readers.xtal.CrystalReader", ["java.lang.Character", "$.Double", "java.util.Arrays", "JU.BS", "$.DF", "$.Lst", "$.M3", "$.PT", "$.Quat", "$.SB", "$.V3", "JU.Logger", "$.Tensor"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.isVersion3 = false;
|
||||
this.$isPrimitive = false;
|
||||
this.isPolymer = false;
|
||||
this.isSlab = false;
|
||||
this.$isMolecular = false;
|
||||
this.haveCharges = false;
|
||||
this.inputOnly = false;
|
||||
this.isLongMode = false;
|
||||
this.getLastConventional = false;
|
||||
this.havePrimitiveMapping = false;
|
||||
this.isProperties = false;
|
||||
this.ac = 0;
|
||||
this.atomIndexLast = 0;
|
||||
this.atomFrag = null;
|
||||
this.primitiveToIndex = null;
|
||||
this.nuclearCharges = null;
|
||||
this.vCoords = null;
|
||||
this.energy = null;
|
||||
this.ptOriginShift = null;
|
||||
this.primitiveToCryst = null;
|
||||
this.directLatticeVectors = null;
|
||||
this.spaceGroupName = null;
|
||||
this.primitiveVolume = 0;
|
||||
this.primitiveDensity = 0;
|
||||
this.vPrimitiveMapping = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "CrystalReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.ptOriginShift = new JU.P3 ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.doProcessLines = false;
|
||||
this.inputOnly = this.checkFilterKey ("INPUT");
|
||||
this.$isPrimitive = !this.inputOnly && !this.checkFilterKey ("CONV");
|
||||
this.addVibrations = new Boolean (this.addVibrations & !this.inputOnly).valueOf ();
|
||||
this.getLastConventional = (!this.$isPrimitive && this.desiredModelNumber == 0);
|
||||
this.setFractionalCoordinates (this.readHeader ());
|
||||
this.asc.checkLatticeOnly = true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.startsWith (" LATTICE PARAMETER")) {
|
||||
var isConvLattice = (this.line.indexOf ("- CONVENTIONAL") >= 0);
|
||||
if (isConvLattice) {
|
||||
if (this.$isPrimitive) return true;
|
||||
this.readLatticeParams (true);
|
||||
} else if (!this.$isPrimitive && !this.havePrimitiveMapping && !this.getLastConventional) {
|
||||
this.readLines (3);
|
||||
this.readPrimitiveMapping ();
|
||||
if (this.setPrimitiveMapping ()) return true;
|
||||
}this.readLatticeParams (true);
|
||||
if (!this.$isPrimitive) {
|
||||
this.discardLinesUntilContains (" TRANSFORMATION");
|
||||
this.readTransformationMatrix ();
|
||||
this.discardLinesUntilContains (" CRYSTALLOGRAPHIC");
|
||||
this.readLatticeParams (false);
|
||||
this.discardLinesUntilContains (" CRYSTALLOGRAPHIC");
|
||||
this.readCoordLines ();
|
||||
if (!this.getLastConventional) {
|
||||
if (this.doGetModel (++this.modelNumber, null)) {
|
||||
this.createAtomsFromCoordLines ();
|
||||
} else {
|
||||
this.vCoords = null;
|
||||
this.checkLastModel ();
|
||||
}}}return true;
|
||||
}if (!this.$isPrimitive) {
|
||||
if (this.line.startsWith (" SHIFT OF THE ORIGIN")) return this.readShift ();
|
||||
if (this.line.startsWith (" INPUT COORDINATES")) {
|
||||
this.readCoordLines ();
|
||||
if (this.inputOnly) this.continuing = false;
|
||||
return true;
|
||||
}}if (this.line.startsWith (" DIRECT LATTICE VECTOR")) return this.setDirect ();
|
||||
if (this.line.indexOf ("DIMENSIONALITY OF THE SYSTEM") >= 0) {
|
||||
if (this.line.indexOf ("2") >= 0) this.isSlab = true;
|
||||
if (this.line.indexOf ("1") >= 0) this.isPolymer = true;
|
||||
return true;
|
||||
}if (this.addVibrations && this.line.startsWith (" FREQUENCIES COMPUTED ON A FRAGMENT")) return this.readFreqFragments ();
|
||||
if (this.line.indexOf ("CONSTRUCTION OF A NANOTUBE FROM A SLAB") >= 0) {
|
||||
this.isPolymer = true;
|
||||
this.isSlab = false;
|
||||
return true;
|
||||
}if (this.line.indexOf ("* CLUSTER CALCULATION") >= 0) {
|
||||
this.$isMolecular = true;
|
||||
this.isSlab = false;
|
||||
this.isPolymer = false;
|
||||
return true;
|
||||
}if (((this.$isPrimitive || this.$isMolecular) && this.line.startsWith (" ATOMS IN THE ASYMMETRIC UNIT")) || this.isProperties && this.line.startsWith (" ATOM N.AT.")) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
return this.readAtoms ();
|
||||
}if (this.line.startsWith (" * SUPERCELL OPTION")) {
|
||||
this.discardLinesUntilContains ("GENERATED");
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.startsWith (" TOTAL ENERGY(")) {
|
||||
this.line = JU.PT.rep (this.line, "( ", "(");
|
||||
var tokens = this.getTokens ();
|
||||
this.energy = Double.$valueOf (Double.parseDouble (tokens[2]));
|
||||
this.setEnergy ();
|
||||
this.rd ();
|
||||
if (this.line.startsWith (" ********")) this.discardLinesUntilContains ("SYMMETRY ALLOWED");
|
||||
else if (this.line.startsWith (" TTTTTTTT")) this.discardLinesUntilContains2 ("PREDICTED ENERGY CHANGE", "HHHHHHH");
|
||||
return true;
|
||||
}if (this.line.startsWith (" TYPE OF CALCULATION")) {
|
||||
this.calculationType = this.line.substring (this.line.indexOf (":") + 1).trim ();
|
||||
return true;
|
||||
}if (this.line.startsWith (" MULLIKEN POPULATION ANALYSIS")) return this.readPartialCharges ();
|
||||
if (this.line.startsWith (" TOTAL ATOMIC CHARGES")) return this.readTotalAtomicCharges ();
|
||||
if (this.addVibrations && this.line.contains (this.isVersion3 ? "EIGENVALUES (EV) OF THE MASS" : "EIGENVALUES (EIGV) OF THE MASS") || this.line.indexOf ("LONGITUDINAL OPTICAL (LO)") >= 0) {
|
||||
this.createAtomsFromCoordLines ();
|
||||
this.isLongMode = (this.line.indexOf ("LONGITUDINAL OPTICAL (LO)") >= 0);
|
||||
return this.readFrequencies ();
|
||||
}if (this.line.startsWith (" MAX GRADIENT")) return this.readGradient ();
|
||||
if (this.line.startsWith (" ATOMIC SPINS SET")) return this.readData ("spin", 3);
|
||||
if (this.line.startsWith (" TOTAL ATOMIC SPINS :")) return this.readData ("magneticMoment", 1);
|
||||
if (this.line.startsWith (" BORN CHARGE TENSOR.")) return this.readBornChargeTensors ();
|
||||
if (!this.isProperties) return true;
|
||||
if (this.line.startsWith (" DEFINITION OF TRACELESS")) return this.getQuadrupoleTensors ();
|
||||
if (this.line.startsWith (" MULTIPOLE ANALYSIS BY ATOMS")) {
|
||||
this.appendLoadNote ("Multipole Analysis");
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.createAtomsFromCoordLines ();
|
||||
if (this.energy != null) this.setEnergy ();
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "setDirect",
|
||||
function () {
|
||||
var isBohr = (this.line.indexOf ("(BOHR") >= 0);
|
||||
this.directLatticeVectors = this.read3Vectors (isBohr);
|
||||
var a = new JU.V3 ();
|
||||
var b = new JU.V3 ();
|
||||
if (this.$isPrimitive) {
|
||||
a = this.directLatticeVectors[0];
|
||||
b = this.directLatticeVectors[1];
|
||||
} else {
|
||||
if (this.primitiveToCryst == null) return true;
|
||||
var mp = new JU.M3 ();
|
||||
mp.setColumnV (0, this.directLatticeVectors[0]);
|
||||
mp.setColumnV (1, this.directLatticeVectors[1]);
|
||||
mp.setColumnV (2, this.directLatticeVectors[2]);
|
||||
mp.mul (this.primitiveToCryst);
|
||||
a = new JU.V3 ();
|
||||
b = new JU.V3 ();
|
||||
mp.getColumnV (0, a);
|
||||
mp.getColumnV (1, b);
|
||||
}this.matUnitCellOrientation = JU.Quat.getQuaternionFrame ( new JU.P3 (), a, b).getMatrix ();
|
||||
JU.Logger.info ("oriented unit cell is in model " + this.asc.atomSetCount);
|
||||
return !this.isProperties;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readTransformationMatrix",
|
||||
function () {
|
||||
this.primitiveToCryst = JU.M3.newA9 (this.fillFloatArray (null, 0, Clazz.newFloatArray (9, 0)));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readShift",
|
||||
function () {
|
||||
var tokens = this.getTokens ();
|
||||
var pt = tokens.length - 3;
|
||||
this.ptOriginShift.set (JU.PT.parseFloatFraction (tokens[pt++]), JU.PT.parseFloatFraction (tokens[pt++]), JU.PT.parseFloatFraction (tokens[pt]));
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setPrimitiveVolumeAndDensity",
|
||||
function () {
|
||||
if (this.primitiveVolume != 0) this.asc.setAtomSetModelProperty ("volumePrimitive", JU.DF.formatDecimal (this.primitiveVolume, 3));
|
||||
if (this.primitiveDensity != 0) this.asc.setAtomSetModelProperty ("densityPrimitive", JU.DF.formatDecimal (this.primitiveDensity, 3));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readHeader",
|
||||
function () {
|
||||
this.discardLinesUntilContains ("*******************************************************************************");
|
||||
this.readLines (2);
|
||||
this.isVersion3 = (this.line.indexOf ("CRYSTAL03") >= 0);
|
||||
this.discardLinesUntilContains ("EEEEEEEEEE");
|
||||
var name;
|
||||
if (this.rd ().length == 0) {
|
||||
name = this.readLines (2).trim ();
|
||||
} else {
|
||||
name = this.line.trim ();
|
||||
this.rd ();
|
||||
}var type = this.rd ().trim ();
|
||||
var pt = type.indexOf ("- PROPERTIES");
|
||||
if (pt >= 0) {
|
||||
this.isProperties = true;
|
||||
type = type.substring (0, pt).trim ();
|
||||
}if (type.indexOf ("EXTERNAL FILE") >= 0) {
|
||||
type = this.rd ().trim ();
|
||||
this.isPolymer = (type.equals ("1D - POLYMER"));
|
||||
this.isSlab = (type.equals ("2D - SLAB"));
|
||||
} else {
|
||||
this.isPolymer = (type.equals ("POLYMER CALCULATION"));
|
||||
this.isSlab = (type.equals ("SLAB CALCULATION"));
|
||||
}this.asc.setCollectionName (name + (!this.isProperties && this.desiredModelNumber == 0 ? " (optimized)" : ""));
|
||||
this.asc.setInfo ("symmetryType", type);
|
||||
if ((this.isPolymer || this.isSlab) && !this.$isPrimitive) {
|
||||
JU.Logger.error ("Cannot use FILTER \"conventional\" with POLYMER or SLAB");
|
||||
this.$isPrimitive = true;
|
||||
}this.asc.setInfo ("unitCellType", (this.$isPrimitive ? "primitive" : "conventional"));
|
||||
if (type.indexOf ("MOLECULAR") >= 0) {
|
||||
this.$isMolecular = this.doProcessLines = true;
|
||||
this.rd ();
|
||||
this.asc.setInfo ("molecularCalculationPointGroup", this.line.substring (this.line.indexOf (" OR ") + 4).trim ());
|
||||
return false;
|
||||
}this.spaceGroupName = "P1";
|
||||
if (!this.$isPrimitive) {
|
||||
this.discardLinesUntilContains2 ("SPACE GROUP", "****");
|
||||
pt = this.line.indexOf (":");
|
||||
if (pt >= 0) this.spaceGroupName = this.line.substring (pt + 1).trim ();
|
||||
}this.doApplySymmetry = this.isProperties;
|
||||
return !this.isProperties;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readLatticeParams",
|
||||
function (isNewSet) {
|
||||
var f = (this.line.indexOf ("(BOHR") >= 0 ? 0.5291772 : 1);
|
||||
if (isNewSet) this.newAtomSet ();
|
||||
if (this.isPolymer && !this.$isPrimitive) {
|
||||
this.setUnitCell (this.parseFloatStr (this.line.substring (this.line.indexOf ("CELL") + 4)) * f, -1, -1, 90, 90, 90);
|
||||
} else {
|
||||
while (this.rd ().indexOf ("GAMMA") < 0) if (this.line.indexOf ("VOLUME=") >= 0) {
|
||||
this.primitiveVolume = this.parseFloatStr (this.line.substring (43));
|
||||
this.primitiveDensity = this.parseFloatStr (this.line.substring (66));
|
||||
}
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
if (this.isSlab) {
|
||||
if (this.$isPrimitive) this.setUnitCell (this.parseFloatStr (tokens[0]) * f, this.parseFloatStr (tokens[1]) * f, -1, this.parseFloatStr (tokens[3]), this.parseFloatStr (tokens[4]), this.parseFloatStr (tokens[5]));
|
||||
else this.setUnitCell (this.parseFloatStr (tokens[0]) * f, this.parseFloatStr (tokens[1]) * f, -1, 90, 90, this.parseFloatStr (tokens[2]));
|
||||
} else if (this.isPolymer) {
|
||||
this.setUnitCell (this.parseFloatStr (tokens[0]) * f, -1, -1, this.parseFloatStr (tokens[3]), this.parseFloatStr (tokens[4]), this.parseFloatStr (tokens[5]));
|
||||
} else {
|
||||
this.setUnitCell (this.parseFloatStr (tokens[0]) * f, this.parseFloatStr (tokens[1]) * f, this.parseFloatStr (tokens[2]) * f, this.parseFloatStr (tokens[3]), this.parseFloatStr (tokens[4]), this.parseFloatStr (tokens[5]));
|
||||
}}}, "~B");
|
||||
Clazz.defineMethod (c$, "readPrimitiveMapping",
|
||||
function () {
|
||||
if (this.havePrimitiveMapping) return;
|
||||
this.vPrimitiveMapping = new JU.Lst ();
|
||||
while (this.rd () != null && this.line.indexOf ("NUMBER") < 0) this.vPrimitiveMapping.addLast (this.line);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "setPrimitiveMapping",
|
||||
function () {
|
||||
if (this.vCoords == null || this.vPrimitiveMapping == null || this.havePrimitiveMapping) return false;
|
||||
this.havePrimitiveMapping = true;
|
||||
var bsInputAtomsIgnore = new JU.BS ();
|
||||
var n = this.vCoords.size ();
|
||||
var indexToPrimitive = Clazz.newIntArray (n, 0);
|
||||
this.primitiveToIndex = Clazz.newIntArray (n, 0);
|
||||
for (var i = 0; i < n; i++) indexToPrimitive[i] = -1;
|
||||
|
||||
var nPrim = 0;
|
||||
for (var iLine = 0; iLine < this.vPrimitiveMapping.size (); iLine++) {
|
||||
this.line = this.vPrimitiveMapping.get (iLine);
|
||||
if (this.line.indexOf (" NOT IRREDUCIBLE") >= 0) {
|
||||
bsInputAtomsIgnore.set (this.parseIntRange (this.line, 21, 25) - 1);
|
||||
continue;
|
||||
}while (this.rd () != null && this.line.indexOf ("NUMBER") < 0) {
|
||||
if (this.line.length < 2 || this.line.indexOf ("ATOM") >= 0) continue;
|
||||
var iAtom = this.parseIntRange (this.line, 4, 8) - 1;
|
||||
if (indexToPrimitive[iAtom] < 0) {
|
||||
indexToPrimitive[iAtom] = nPrim++;
|
||||
}}
|
||||
}
|
||||
if (bsInputAtomsIgnore.nextSetBit (0) >= 0) for (var i = n; --i >= 0; ) if (bsInputAtomsIgnore.get (i)) this.vCoords.removeItemAt (i);
|
||||
|
||||
this.ac = this.vCoords.size ();
|
||||
JU.Logger.info (nPrim + " primitive atoms and " + this.ac + " conventionalAtoms");
|
||||
this.primitiveToIndex = Clazz.newIntArray (nPrim, 0);
|
||||
for (var i = 0; i < nPrim; i++) this.primitiveToIndex[i] = -1;
|
||||
|
||||
for (var i = this.ac; --i >= 0; ) {
|
||||
var iPrim = indexToPrimitive[this.parseIntStr (this.vCoords.get (i).substring (0, 4)) - 1];
|
||||
if (iPrim >= 0) this.primitiveToIndex[iPrim] = i;
|
||||
}
|
||||
this.vPrimitiveMapping = null;
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
if (this.$isMolecular) this.newAtomSet ();
|
||||
this.vCoords = null;
|
||||
while (this.rd () != null && this.line.indexOf ("*") < 0) {
|
||||
if (this.line.indexOf ("X(ANGSTROM") >= 0) {
|
||||
this.setFractionalCoordinates (false);
|
||||
this.$isMolecular = true;
|
||||
}}
|
||||
var i = this.atomIndexLast;
|
||||
var doNormalizePrimitive = false;
|
||||
this.atomIndexLast = this.asc.ac;
|
||||
while (this.rd () != null && this.line.length > 0 && this.line.indexOf (this.$isPrimitive ? "*" : "=") < 0) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
var tokens = this.getTokens ();
|
||||
var pt = (this.isProperties ? 1 : 2);
|
||||
atom.elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (this.getAtomicNumber (tokens[pt++]));
|
||||
atom.atomName = J.adapter.readers.xtal.CrystalReader.fixAtomName (tokens[pt++]);
|
||||
if (this.isProperties) pt++;
|
||||
var x = this.parseFloatStr (tokens[pt++]);
|
||||
var y = this.parseFloatStr (tokens[pt++]);
|
||||
var z = this.parseFloatStr (tokens[pt]);
|
||||
if (this.haveCharges) atom.partialCharge = this.asc.atoms[i++].partialCharge;
|
||||
if (this.iHaveFractionalCoordinates && !this.isProperties) {
|
||||
if (x < 0 && (this.isPolymer || this.isSlab || doNormalizePrimitive)) x += 1;
|
||||
if (y < 0 && (this.isSlab || doNormalizePrimitive)) y += 1;
|
||||
if (z < 0 && doNormalizePrimitive) z += 1;
|
||||
}this.setAtomCoordXYZ (atom, x, y, z);
|
||||
}
|
||||
this.ac = this.asc.ac - this.atomIndexLast;
|
||||
return true;
|
||||
});
|
||||
c$.fixAtomName = Clazz.defineMethod (c$, "fixAtomName",
|
||||
function (s) {
|
||||
return (s.length > 1 && JU.PT.isLetter (s.charAt (1)) ? s.substring (0, 1) + Character.toLowerCase (s.charAt (1)) + s.substring (2) : s);
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "getAtomicNumber",
|
||||
function (token) {
|
||||
return this.parseIntStr (token) % 100;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "readCoordLines",
|
||||
function () {
|
||||
this.rd ();
|
||||
this.rd ();
|
||||
this.vCoords = new JU.Lst ();
|
||||
while (this.rd () != null && this.line.length > 0) this.vCoords.addLast (this.line);
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "createAtomsFromCoordLines",
|
||||
function () {
|
||||
if (this.vCoords == null) return;
|
||||
this.ac = this.vCoords.size ();
|
||||
for (var i = 0; i < this.ac; i++) {
|
||||
var atom = this.asc.addNewAtom ();
|
||||
var tokens = JU.PT.getTokens (this.vCoords.get (i));
|
||||
atom.atomSerial = this.parseIntStr (tokens[0]);
|
||||
var atomicNumber;
|
||||
var offset;
|
||||
if (tokens.length == 7) {
|
||||
atomicNumber = this.getAtomicNumber (tokens[2]);
|
||||
offset = 2;
|
||||
} else {
|
||||
atomicNumber = this.getAtomicNumber (tokens[1]);
|
||||
offset = 0;
|
||||
}var x = this.parseFloatStr (tokens[2 + offset]) + this.ptOriginShift.x;
|
||||
var y = this.parseFloatStr (tokens[3 + offset]) + this.ptOriginShift.y;
|
||||
var z = this.parseFloatStr (tokens[4 + offset]) + this.ptOriginShift.z;
|
||||
this.setAtomCoordXYZ (atom, x, y, z);
|
||||
atom.elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (atomicNumber);
|
||||
}
|
||||
this.vCoords = null;
|
||||
this.setPrimitiveVolumeAndDensity ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "newAtomSet",
|
||||
function () {
|
||||
if (this.ac > 0 && this.asc.ac > 0) {
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.asc.newAtomSet ();
|
||||
}if (this.spaceGroupName != null) this.setSpaceGroupName (this.spaceGroupName);
|
||||
this.ac = 0;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setEnergy",
|
||||
function () {
|
||||
this.asc.setAtomSetEnergy ("" + this.energy, this.energy.floatValue ());
|
||||
this.asc.setCurrentModelInfo ("Energy", this.energy);
|
||||
this.asc.setInfo ("Energy", this.energy);
|
||||
this.asc.setAtomSetName ("Energy = " + this.energy + " Hartree");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readPartialCharges",
|
||||
function () {
|
||||
if (this.haveCharges || this.asc.ac == 0) return true;
|
||||
this.haveCharges = true;
|
||||
this.readLines (3);
|
||||
var atoms = this.asc.atoms;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
var iPrim = 0;
|
||||
while (this.rd () != null && this.line.length > 3) if (this.line.charAt (3) != ' ') {
|
||||
var iConv = this.getAtomIndexFromPrimitiveIndex (iPrim);
|
||||
if (iConv >= 0) atoms[i0 + iConv].partialCharge = this.parseFloatRange (this.line, 9, 11) - this.parseFloatRange (this.line, 12, 18);
|
||||
iPrim++;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readTotalAtomicCharges",
|
||||
function () {
|
||||
var data = new JU.SB ();
|
||||
while (this.rd () != null && this.line.indexOf ("T") < 0) data.append (this.line);
|
||||
|
||||
var tokens = JU.PT.getTokens (data.toString ());
|
||||
var charges = Clazz.newFloatArray (tokens.length, 0);
|
||||
if (this.nuclearCharges == null) this.nuclearCharges = charges;
|
||||
if (this.asc.ac == 0) return true;
|
||||
var atoms = this.asc.atoms;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
for (var i = 0; i < charges.length; i++) {
|
||||
var iConv = this.getAtomIndexFromPrimitiveIndex (i);
|
||||
if (iConv >= 0) {
|
||||
charges[i] = this.parseFloatStr (tokens[i]);
|
||||
atoms[i0 + iConv].partialCharge = this.nuclearCharges[i] - charges[i];
|
||||
}}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "getAtomIndexFromPrimitiveIndex",
|
||||
function (iPrim) {
|
||||
return (this.primitiveToIndex == null ? iPrim : this.primitiveToIndex[iPrim]);
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "readFreqFragments",
|
||||
function () {
|
||||
var numAtomsFrag = this.parseIntRange (this.line, 39, 44);
|
||||
if (numAtomsFrag < 0) return true;
|
||||
this.atomFrag = Clazz.newIntArray (numAtomsFrag, 0);
|
||||
var Sfrag = "";
|
||||
while (this.rd () != null && this.line.indexOf ("(") >= 0) Sfrag += this.line;
|
||||
|
||||
Sfrag = JU.PT.rep (Sfrag, "(", " ");
|
||||
Sfrag = JU.PT.rep (Sfrag, ")", " ");
|
||||
var tokens = JU.PT.getTokens (Sfrag);
|
||||
for (var i = 0, pos = 0; i < numAtomsFrag; i++, pos += 3) this.atomFrag[i] = this.getAtomIndexFromPrimitiveIndex (this.parseIntStr (tokens[pos]) - 1);
|
||||
|
||||
java.util.Arrays.sort (this.atomFrag);
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFrequencies",
|
||||
function () {
|
||||
this.energy = null;
|
||||
this.discardLinesUntilContains ("MODES");
|
||||
var haveIntensities = (this.line.indexOf ("INTENS") >= 0);
|
||||
this.rd ();
|
||||
var vData = new JU.Lst ();
|
||||
var freqAtomCount = this.ac;
|
||||
while (this.rd () != null && this.line.length > 0) {
|
||||
var i0 = this.parseIntRange (this.line, 1, 5);
|
||||
var i1 = this.parseIntRange (this.line, 6, 10);
|
||||
var irrep = (this.isLongMode ? this.line.substring (48, 51) : this.line.substring (49, 52)).trim ();
|
||||
var intens = (!haveIntensities ? "not available" : (this.isLongMode ? this.line.substring (53, 61) : this.line.substring (59, 69).$replace (')', ' ')).trim ());
|
||||
var irActivity = (this.isLongMode ? "A" : this.line.substring (55, 58).trim ());
|
||||
var ramanActivity = (this.isLongMode ? "I" : this.line.substring (71, 73).trim ());
|
||||
var data = Clazz.newArray (-1, [irrep, intens, irActivity, ramanActivity]);
|
||||
for (var i = i0; i <= i1; i++) vData.addLast (data);
|
||||
|
||||
}
|
||||
this.discardLinesUntilContains (this.isLongMode ? "LO MODES FOR IRREP" : this.isVersion3 ? "THE CORRESPONDING MODES" : "NORMAL MODES NORMALIZED TO CLASSICAL AMPLITUDES");
|
||||
this.rd ();
|
||||
var lastAtomCount = -1;
|
||||
while (this.rd () != null && this.line.startsWith (" FREQ(CM**-1)")) {
|
||||
var tokens = JU.PT.getTokens (this.line.substring (15));
|
||||
var frequencies = Clazz.newFloatArray (tokens.length, 0);
|
||||
var frequencyCount = frequencies.length;
|
||||
for (var i = 0; i < frequencyCount; i++) {
|
||||
frequencies[i] = this.parseFloatStr (tokens[i]);
|
||||
if (this.debugging) JU.Logger.debug ((this.vibrationNumber + i) + " frequency=" + frequencies[i]);
|
||||
}
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
var iAtom0 = 0;
|
||||
var nData = vData.size ();
|
||||
for (var i = 0; i < frequencyCount; i++) {
|
||||
tokens = vData.get (this.vibrationNumber % nData);
|
||||
ignore[i] = (!this.doGetVibration (++this.vibrationNumber) || tokens == null);
|
||||
if (ignore[i]) continue;
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
lastAtomCount = this.cloneLastAtomSet (this.ac, null);
|
||||
if (i == 0) iAtom0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
this.setFreqValue (frequencies[i], tokens);
|
||||
}
|
||||
this.rd ();
|
||||
this.fillFrequencyData (iAtom0, freqAtomCount, lastAtomCount, ignore, false, 14, 10, this.atomFrag, 0);
|
||||
this.rd ();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setFreqValue",
|
||||
function (freq, data) {
|
||||
var activity = "IR: " + data[2] + ", Ram.: " + data[3];
|
||||
this.asc.setAtomSetFrequency (null, activity, "" + freq, null);
|
||||
this.asc.setAtomSetModelProperty ("IRintensity", data[1] + " km/Mole");
|
||||
this.asc.setAtomSetModelProperty ("vibrationalSymmetry", data[0]);
|
||||
this.asc.setAtomSetModelProperty ("IRactivity", data[2]);
|
||||
this.asc.setAtomSetModelProperty ("Ramanactivity", data[3]);
|
||||
this.asc.setAtomSetName ((this.isLongMode ? "LO " : "") + data[0] + " " + JU.DF.formatDecimal (freq, 2) + " cm-1 (" + JU.DF.formatDecimal (JU.PT.fVal (data[1]), 0) + " km/Mole), " + activity);
|
||||
}, "~N,~A");
|
||||
Clazz.defineMethod (c$, "readGradient",
|
||||
function () {
|
||||
var key = null;
|
||||
while (this.line != null) {
|
||||
var tokens = this.getTokens ();
|
||||
if (this.line.indexOf ("MAX GRAD") >= 0) key = "maxGradient";
|
||||
else if (this.line.indexOf ("RMS GRAD") >= 0) key = "rmsGradient";
|
||||
else if (this.line.indexOf ("MAX DISP") >= 0) key = "maxDisplacement";
|
||||
else if (this.line.indexOf ("RMS DISP") >= 0) key = "rmsDisplacement";
|
||||
else break;
|
||||
if (this.asc.ac > 0) this.asc.setAtomSetModelProperty (key, tokens[2]);
|
||||
this.rd ();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readData",
|
||||
function (name, nfields) {
|
||||
this.createAtomsFromCoordLines ();
|
||||
var f = Clazz.newFloatArray (this.ac, 0);
|
||||
for (var i = 0; i < this.ac; i++) f[i] = 0;
|
||||
|
||||
var data = "";
|
||||
while (this.rd () != null && (this.line.length < 4 || JU.PT.isDigit (this.line.charAt (3)))) data += this.line;
|
||||
|
||||
data = JU.PT.rep (data, "-", " -");
|
||||
var tokens = JU.PT.getTokens (data);
|
||||
for (var i = 0, pt = nfields - 1; i < this.ac; i++, pt += nfields) {
|
||||
var iConv = this.getAtomIndexFromPrimitiveIndex (i);
|
||||
if (iConv >= 0) f[iConv] = this.parseFloatStr (tokens[pt]);
|
||||
}
|
||||
this.asc.setAtomProperties (name, f, -1, false);
|
||||
return true;
|
||||
}, "~S,~N");
|
||||
Clazz.defineMethod (c$, "getQuadrupoleTensors",
|
||||
function () {
|
||||
this.readLines (6);
|
||||
var atoms = this.asc.atoms;
|
||||
while (this.rd () != null && this.line.startsWith (" *** ATOM")) {
|
||||
var tokens = this.getTokens ();
|
||||
var index = this.parseIntStr (tokens[3]) - 1;
|
||||
tokens = JU.PT.getTokens (this.readLines (3));
|
||||
var vectors = new Array (3);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
vectors[i] = JU.V3.newV (this.directLatticeVectors[i]);
|
||||
vectors[i].normalize ();
|
||||
}
|
||||
atoms[index].addTensor ( new JU.Tensor ().setFromEigenVectors (vectors, Clazz.newFloatArray (-1, [this.parseFloatStr (tokens[1]), this.parseFloatStr (tokens[3]), this.parseFloatStr (tokens[5])]), "quadrupole", atoms[index].atomName, null), null, false);
|
||||
this.rd ();
|
||||
}
|
||||
this.appendLoadNote ("Ellipsoids set \"quadrupole\": Quadrupole tensors");
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readBornChargeTensors",
|
||||
function () {
|
||||
this.createAtomsFromCoordLines ();
|
||||
this.rd ();
|
||||
var atoms = this.asc.atoms;
|
||||
while (this.rd ().startsWith (" ATOM")) {
|
||||
var index = this.parseIntAt (this.line, 5) - 1;
|
||||
var atom = atoms[index];
|
||||
this.readLines (2);
|
||||
var a = Clazz.newDoubleArray (3, 3, 0);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
for (var j = 0; j < 3; j++) a[i][j] = this.parseFloatStr (tokens[j + 1]);
|
||||
|
||||
}
|
||||
atom.addTensor ( new JU.Tensor ().setFromAsymmetricTensor (a, "charge", atom.elementSymbol + (index + 1)), null, false);
|
||||
this.rd ();
|
||||
}
|
||||
this.appendLoadNote ("Ellipsoids set \"charge\": Born charge tensors");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,103 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.DmolReader", ["java.lang.Double", "JU.DF", "$.PT", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.unitCellData = null;
|
||||
this.totE = null;
|
||||
this.geomOpt = false;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "DmolReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.contains ("** GEOMETRY OPTIMIZATION IN DELOCALIZED COORDINATES **")) {
|
||||
this.geomOpt = true;
|
||||
} else if (this.line.contains ("INCOOR, atomic coordinates")) {
|
||||
this.geomOpt = false;
|
||||
} else if (!this.geomOpt ? this.line.contains ("$cell vectors") : this.line.contains ("Lattice:")) {
|
||||
this.readCellParam ();
|
||||
} else if (!this.geomOpt ? this.line.contains ("$coordinates") : this.line.contains ("Input Coordinates")) {
|
||||
this.readCoord ();
|
||||
} else if (this.line.contains (" Total Energy")) {
|
||||
this.readEnergy ();
|
||||
} else if (this.line.contains ("Frequencies (cm-1)")) {
|
||||
this.readFreq ();
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCellParam",
|
||||
function () {
|
||||
this.unitCellData = Clazz.newFloatArray (9, 0);
|
||||
for (var n = 0, i = 0; n < 3; n++) {
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
this.unitCellData[i++] = this.parseFloatStr (!this.geomOpt ? tokens[0] : tokens[4]) * 0.5291772;
|
||||
this.unitCellData[i++] = this.parseFloatStr (!this.geomOpt ? tokens[1] : tokens[5]) * 0.5291772;
|
||||
this.unitCellData[i++] = this.parseFloatStr (!this.geomOpt ? tokens[2] : tokens[6]) * 0.5291772;
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "newAtomSet",
|
||||
function () {
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.asc.newAtomSet ();
|
||||
if (this.totE != null) this.setEnergy ();
|
||||
this.doApplySymmetry = true;
|
||||
if (this.unitCellData != null) {
|
||||
this.addExplicitLatticeVector (0, this.unitCellData, 0);
|
||||
this.addExplicitLatticeVector (1, this.unitCellData, 3);
|
||||
this.addExplicitLatticeVector (2, this.unitCellData, 6);
|
||||
this.setSpaceGroupName ("P1");
|
||||
}this.setFractionalCoordinates (false);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCoord",
|
||||
function () {
|
||||
this.newAtomSet ();
|
||||
if (this.geomOpt) this.readLines (2);
|
||||
while (this.rd () != null && !this.geomOpt ? !this.line.contains ("$end") : !this.line.contains ("-----")) {
|
||||
var tokens = this.getTokens ();
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.atomName = !this.geomOpt ? tokens[0] : tokens[1];
|
||||
var factor = (!this.geomOpt ? 0.5291772 : 1.00);
|
||||
var x = this.parseFloatStr (!this.geomOpt ? tokens[1] : tokens[2]) * factor;
|
||||
var y = this.parseFloatStr (!this.geomOpt ? tokens[2] : tokens[3]) * factor;
|
||||
var z = this.parseFloatStr (!this.geomOpt ? tokens[3] : tokens[4]) * factor;
|
||||
atom.set (x, y, z);
|
||||
this.setAtomCoord (atom);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readEnergy",
|
||||
function () {
|
||||
this.rd ();
|
||||
if (this.line.contains ("Ef")) this.totE = Double.$valueOf (Double.parseDouble (JU.PT.getTokens (this.line.substring (this.line.indexOf ("Ef") + 1, this.line.indexOf ("Ha")))[1]));
|
||||
});
|
||||
Clazz.defineMethod (c$, "setEnergy",
|
||||
function () {
|
||||
this.asc.setAtomSetEnergy ("" + this.totE, this.totE.floatValue ());
|
||||
this.asc.setInfo ("Energy", this.totE);
|
||||
this.asc.setAtomSetName ("E = " + this.totE + " Hartree");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readFreq",
|
||||
function () {
|
||||
var lastAtomCount = 0;
|
||||
var ac = this.asc.getLastAtomSetAtomCount ();
|
||||
while (this.rd () != null && this.line.charAt (1) == ' ') {
|
||||
var tokens = this.getTokens ();
|
||||
var frequencyCount = Clazz.doubleToInt (tokens.length / 2);
|
||||
var frequencies = Clazz.newFloatArray (frequencyCount, 0);
|
||||
for (var i = 1, n = 0; i < tokens.length; i += 2, n++) {
|
||||
frequencies[n] = this.parseFloatStr (tokens[i]);
|
||||
if (this.debugging) JU.Logger.debug ((this.vibrationNumber + n) + " frequency=" + frequencies[n]);
|
||||
}
|
||||
var ignore = Clazz.newBooleanArray (frequencyCount, false);
|
||||
var iAtom0 = 0;
|
||||
for (var i = 0; i < frequencyCount; i++) {
|
||||
ignore[i] = (!this.doGetVibration (++this.vibrationNumber));
|
||||
if (ignore[i]) continue;
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
lastAtomCount = this.cloneLastAtomSet (ac, null);
|
||||
if (i == 0) iAtom0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
this.asc.setAtomSetFrequency (null, null, String.valueOf (frequencies[i]), null);
|
||||
this.asc.setAtomSetName (JU.DF.formatDecimal (frequencies[i], 2) + " cm-1");
|
||||
}
|
||||
this.rd ();
|
||||
this.fillFrequencyData (iAtom0, ac, lastAtomCount, ignore, false, 5, 13, null, 0);
|
||||
this.readLines (2);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.EspressoReader", ["java.lang.Double", "JU.PT"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.cellParams = null;
|
||||
this.totEnergy = null;
|
||||
this.endFlag = false;
|
||||
this.aPar = 0;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "EspressoReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.setSpaceGroupName ("P1");
|
||||
this.doApplySymmetry = true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.contains ("lattice parameter (a_0)") || this.line.contains ("lattice parameter (alat)")) {
|
||||
this.readAparam ();
|
||||
} else if (this.line.contains ("crystal axes:")) {
|
||||
this.readCellParam (false);
|
||||
} else if (this.line.contains ("CELL_PARAMETERS (")) {
|
||||
this.readCellParam (true);
|
||||
} else if (this.line.contains ("Cartesian axes")) {
|
||||
this.discardLinesUntilContains ("positions (");
|
||||
if (this.doGetModel (++this.modelNumber, null)) this.readAtoms ();
|
||||
} else if (this.line.contains ("POSITIONS (")) {
|
||||
if (this.doGetModel (++this.modelNumber, null)) this.readAtoms ();
|
||||
} else if (this.line.contains ("! total energy")) {
|
||||
this.readEnergy ();
|
||||
} else if (this.line.contains ("A final scf")) {
|
||||
this.endFlag = true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAparam",
|
||||
function () {
|
||||
this.aPar = this.parseFloatStr (this.getTokens ()[4]) * 0.5291772;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCellParam",
|
||||
function (andAPar) {
|
||||
var i0 = (andAPar ? 0 : 3);
|
||||
if (this.line.contains ("bohr")) this.aPar = 0.5291772;
|
||||
if (andAPar && this.line.contains ("=")) this.aPar = this.parseFloatStr (this.line.substring (this.line.indexOf ("=") + 1)) * 0.5291772;
|
||||
this.cellParams = Clazz.newFloatArray (9, 0);
|
||||
for (var n = 0, i = 0; n < 3; n++) {
|
||||
var tokens = JU.PT.getTokens (this.rd ());
|
||||
this.cellParams[i++] = this.parseFloatStr (tokens[i0]) * this.aPar;
|
||||
this.cellParams[i++] = this.parseFloatStr (tokens[i0 + 1]) * this.aPar;
|
||||
this.cellParams[i++] = this.parseFloatStr (tokens[i0 + 2]) * this.aPar;
|
||||
}
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "newAtomSet",
|
||||
function () {
|
||||
this.asc.newAtomSet ();
|
||||
if (this.totEnergy != null) this.setEnergy ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "setCellParams",
|
||||
function () {
|
||||
if (this.cellParams != null) {
|
||||
this.addExplicitLatticeVector (0, this.cellParams, 0);
|
||||
this.addExplicitLatticeVector (1, this.cellParams, 3);
|
||||
this.addExplicitLatticeVector (2, this.cellParams, 6);
|
||||
this.setSpaceGroupName ("P1");
|
||||
}});
|
||||
Clazz.defineMethod (c$, "readAtoms",
|
||||
function () {
|
||||
this.newAtomSet ();
|
||||
var isAlat = (this.line.contains ("alat") || this.line.contains ("a_0"));
|
||||
var firstStr = (this.line.contains ("site n."));
|
||||
var isFractional = this.line.contains ("crystal");
|
||||
var isBohr = this.line.contains ("bohr");
|
||||
var isAngstrom = this.line.contains ("angstrom");
|
||||
if (isAlat || isFractional || isAngstrom) this.setCellParams ();
|
||||
this.setFractionalCoordinates (isFractional);
|
||||
while (this.rd () != null && this.line.length > 45) {
|
||||
var tokens = this.getTokens ();
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.atomName = tokens[(isBohr || tokens.length == 4 || !firstStr ? 0 : 1)];
|
||||
var i1 = (isBohr || tokens.length == 4 || !firstStr ? 1 : tokens.length - 4);
|
||||
var x = this.parseFloatStr (tokens[i1++]);
|
||||
var y = this.parseFloatStr (tokens[i1++]);
|
||||
var z = this.parseFloatStr (tokens[i1++]);
|
||||
atom.set (x, y, z);
|
||||
if (isBohr) {
|
||||
atom.scale (0.5291772);
|
||||
} else if (isAlat) {
|
||||
atom.scale (this.aPar);
|
||||
}this.setAtomCoord (atom);
|
||||
}
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
if (this.endFlag) this.discardLinesUntilContains ("Harris-Foulkes estimate");
|
||||
});
|
||||
Clazz.defineMethod (c$, "readEnergy",
|
||||
function () {
|
||||
this.totEnergy = Double.$valueOf (Double.parseDouble (JU.PT.getTokens (this.line.substring (this.line.indexOf ("=") + 1))[0]));
|
||||
});
|
||||
Clazz.defineMethod (c$, "setEnergy",
|
||||
function () {
|
||||
this.asc.setAtomSetEnergy ("" + this.totEnergy, this.totEnergy.floatValue ());
|
||||
this.asc.setInfo ("Energy", this.totEnergy);
|
||||
this.asc.setAtomSetName ("E = " + this.totEnergy + " Ry");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,248 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.GulpReader", ["java.lang.Double", "$.Float", "java.util.Hashtable", "JU.PT", "$.V3"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.isSlab = false;
|
||||
this.isPolymer = false;
|
||||
this.$isPrimitive = false;
|
||||
this.sep = "-------";
|
||||
this.coordinatesArePrimitive = false;
|
||||
this.atomCharges = null;
|
||||
this.bTest = false;
|
||||
this.a = 0;
|
||||
this.b = 0;
|
||||
this.c = 0;
|
||||
this.alpha = 0;
|
||||
this.beta = 0;
|
||||
this.gamma = 0;
|
||||
this.primitiveData = null;
|
||||
this.totEnergy = null;
|
||||
this.energyUnits = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "GulpReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.$isPrimitive = !this.checkFilterKey ("CONV");
|
||||
this.coordinatesArePrimitive = true;
|
||||
this.setFractionalCoordinates (this.readDimensionality ());
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
if (this.atomCharges == null) return;
|
||||
var atoms = this.asc.atoms;
|
||||
var f;
|
||||
for (var i = this.asc.ac; --i >= 0; ) if ((f = this.atomCharges.get (atoms[i].atomName)) != null || (f = this.atomCharges.get (atoms[i].getElementSymbol ())) != null) atoms[i].partialCharge = f.floatValue ();
|
||||
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.contains ("Space group ")) {
|
||||
this.readSpaceGroup ();
|
||||
return true;
|
||||
}if (this.isSlab ? this.line.contains ("Surface cell parameters") : this.isPolymer ? this.line.contains ("Polymer cell parameter") : (this.bTest = this.line.contains ("Cartesian lattice vectors")) || this.line.contains ("Cell parameters (Angstroms/Degrees)") || this.line.contains ("Primitive cell parameters")) {
|
||||
this.readCellParameters (this.bTest);
|
||||
return true;
|
||||
}if (this.line.contains ("Monopole - monopole (total)")) {
|
||||
this.readEnergy ();
|
||||
return true;
|
||||
}if (this.line.contains ("Fractional coordinates of asymmetric unit :") || (this.bTest = this.line.contains ("Final asymmetric unit coordinates")) || (this.bTest = this.line.contains ("Final fractional coordinates ")) || this.line.contains ("Mixed fractional/Cartesian coordinates") || this.line.contains ("Cartesian coordinates of cluster ") || this.line.contains ("Final cartesian coordinates of atoms :") && this.isMolecular) {
|
||||
if (this.doGetModel (++this.modelNumber, null)) this.readAtomicPos (!this.bTest);
|
||||
return true;
|
||||
}if (this.line.contains ("Species output for all configurations")) {
|
||||
this.readPartialCharges ();
|
||||
return true;
|
||||
}if (!this.doProcessLines) return true;
|
||||
if (this.line.contains ("Final cell parameters and derivatives")) {
|
||||
this.readFinalCell ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readDimensionality",
|
||||
function () {
|
||||
this.discardLinesUntilContains ("Dimensionality");
|
||||
var tokens = this.getTokens ();
|
||||
switch (this.parseIntStr (tokens[2])) {
|
||||
case 0:
|
||||
this.isMolecular = true;
|
||||
this.$isPrimitive = false;
|
||||
return false;
|
||||
case 1:
|
||||
this.isPolymer = true;
|
||||
this.$isPrimitive = false;
|
||||
break;
|
||||
case 2:
|
||||
this.isSlab = true;
|
||||
this.$isPrimitive = false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readSpaceGroup",
|
||||
function () {
|
||||
this.sgName = this.line.substring (this.line.indexOf (":") + 1).trim ();
|
||||
});
|
||||
c$.parameterIndex = Clazz.defineMethod (c$, "parameterIndex",
|
||||
function (key) {
|
||||
for (var i = J.adapter.readers.xtal.GulpReader.tags.length; --i >= 0; ) if (J.adapter.readers.xtal.GulpReader.tags[i].equals (key)) return i;
|
||||
|
||||
return -1;
|
||||
}, "~S");
|
||||
Clazz.defineMethod (c$, "setParameter",
|
||||
function (key, value) {
|
||||
switch (J.adapter.readers.xtal.GulpReader.parameterIndex (key)) {
|
||||
case 0:
|
||||
this.a = value;
|
||||
break;
|
||||
case 1:
|
||||
this.b = value;
|
||||
break;
|
||||
case 2:
|
||||
this.c = value;
|
||||
break;
|
||||
case 3:
|
||||
this.alpha = value;
|
||||
break;
|
||||
case 4:
|
||||
this.beta = value;
|
||||
break;
|
||||
case 5:
|
||||
this.gamma = value;
|
||||
break;
|
||||
}
|
||||
}, "~S,~N");
|
||||
Clazz.defineMethod (c$, "newAtomSet",
|
||||
function (doSetUnitCell) {
|
||||
this.asc.newAtomSet ();
|
||||
if (doSetUnitCell) {
|
||||
this.setModelParameters (this.coordinatesArePrimitive);
|
||||
if (this.totEnergy != null) this.setEnergy ();
|
||||
}}, "~B");
|
||||
Clazz.defineMethod (c$, "setModelParameters",
|
||||
function (isPrimitive) {
|
||||
if (this.sgName != null) this.setSpaceGroupName (isPrimitive ? "P1" : this.sgName);
|
||||
if (isPrimitive && this.primitiveData != null) {
|
||||
this.addExplicitLatticeVector (0, this.primitiveData, 0);
|
||||
this.addExplicitLatticeVector (1, this.primitiveData, 3);
|
||||
this.addExplicitLatticeVector (2, this.primitiveData, 6);
|
||||
} else if (this.a != 0) {
|
||||
if (this.isSlab) {
|
||||
this.c = -1;
|
||||
this.beta = this.gamma = 90;
|
||||
} else if (this.isPolymer) {
|
||||
this.b = this.c = -1;
|
||||
this.alpha = this.beta = this.gamma = 90;
|
||||
}this.setUnitCell (this.a, this.b, this.c, this.alpha, this.beta, this.gamma);
|
||||
}}, "~B");
|
||||
Clazz.defineMethod (c$, "readCellParameters",
|
||||
function (isLatticeVectors) {
|
||||
if (isLatticeVectors) {
|
||||
this.rd ();
|
||||
this.primitiveData = this.fillFloatArray (null, 0, Clazz.newFloatArray (9, 0));
|
||||
this.a = 0;
|
||||
return;
|
||||
}var i0 = (this.line.indexOf ("Full cell") < 0 ? 0 : 4);
|
||||
this.coordinatesArePrimitive = (i0 == 0);
|
||||
this.rd ();
|
||||
while (this.rd () != null && this.line.contains ("=")) {
|
||||
var tokens = JU.PT.getTokens (this.line.$replace ('=', ' '));
|
||||
for (var i = i0; i < i0 + 4; i += 2) if (tokens.length > i + 1) this.setParameter (tokens[i], this.parseFloatStr (tokens[i + 1]));
|
||||
|
||||
}
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "readFinalCell",
|
||||
function () {
|
||||
this.discardLinesUntilContains (this.sep);
|
||||
var tokens;
|
||||
while (this.rd () != null && (tokens = this.getTokens ()).length >= 2) this.setParameter (tokens[0], this.parseFloatStr (tokens[1]));
|
||||
|
||||
if (this.primitiveData != null) {
|
||||
this.scalePrimitiveData (0, this.a);
|
||||
this.scalePrimitiveData (3, this.b);
|
||||
this.scalePrimitiveData (6, this.c);
|
||||
if (!this.coordinatesArePrimitive) while (this.rd () != null && this.line.indexOf ("Final") < 0) if (this.line.indexOf ("Non-primitive lattice parameters") > 0) {
|
||||
this.rd ();
|
||||
for (var i = 0; i < 2; i++) {
|
||||
tokens = JU.PT.getTokens (this.rd ().$replace ('=', ' '));
|
||||
this.setParameter (tokens[0], this.parseFloatStr (tokens[1]));
|
||||
this.setParameter (tokens[2], this.parseFloatStr (tokens[3]));
|
||||
this.setParameter (tokens[4], this.parseFloatStr (tokens[5]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}this.setModelParameters (this.coordinatesArePrimitive);
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
if (this.totEnergy != null) this.setEnergy ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "scalePrimitiveData",
|
||||
function (i, value) {
|
||||
var v = JU.V3.new3 (this.primitiveData[i], this.primitiveData[i + 1], this.primitiveData[i + 2]);
|
||||
v.normalize ();
|
||||
v.scale (value);
|
||||
this.primitiveData[i++] = v.x;
|
||||
this.primitiveData[i++] = v.y;
|
||||
this.primitiveData[i++] = v.z;
|
||||
}, "~N,~N");
|
||||
Clazz.overrideMethod (c$, "applySymmetryAndSetTrajectory",
|
||||
function () {
|
||||
if (this.coordinatesArePrimitive && this.iHaveUnitCell && this.doCheckUnitCell && this.primitiveData != null && !this.$isPrimitive) {
|
||||
this.setModelParameters (false);
|
||||
var symFull = this.symmetry;
|
||||
this.setModelParameters (true);
|
||||
var atoms = this.asc.atoms;
|
||||
var i0 = this.asc.getLastAtomSetAtomIndex ();
|
||||
var i1 = this.asc.ac;
|
||||
for (var i = i0; i < i1; i++) {
|
||||
var atom = atoms[i];
|
||||
this.symmetry.toCartesian (atom, true);
|
||||
symFull.toFractional (atom, true);
|
||||
if (this.fixJavaFloat) JU.PT.fixPtFloats (atom, 100000.0);
|
||||
}
|
||||
this.setModelParameters (false);
|
||||
}this.applySymTrajASCR ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtomicPos",
|
||||
function (finalizeSymmetry) {
|
||||
this.newAtomSet (finalizeSymmetry);
|
||||
this.discardLinesUntilContains (this.sep);
|
||||
this.discardLinesUntilContains (this.sep);
|
||||
while (this.rd () != null) {
|
||||
if (this.line.indexOf (this.sep) >= 0 && this.rd ().indexOf ("Region") < 0) break;
|
||||
if (this.line.indexOf ("Region") >= 0) {
|
||||
this.rd ();
|
||||
continue;
|
||||
}this.line = this.line.$replace ('*', ' ');
|
||||
var tokens = this.getTokens ();
|
||||
if (tokens[2].equals ("c")) this.addAtomXYZSymName (tokens, 3, null, tokens[1]);
|
||||
}
|
||||
if (finalizeSymmetry) this.applySymmetryAndSetTrajectory ();
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "readPartialCharges",
|
||||
function () {
|
||||
this.atomCharges = new java.util.Hashtable ();
|
||||
this.discardLinesUntilContains (this.sep);
|
||||
this.discardLinesUntilContains (this.sep);
|
||||
var tokens;
|
||||
while ((tokens = JU.PT.getTokens (this.rd ())).length > 5) {
|
||||
var species = tokens[0];
|
||||
var charge = this.atomCharges.get (species);
|
||||
var f = (charge == null ? 0 : charge.floatValue ());
|
||||
this.atomCharges.put (species, Float.$valueOf ((f + this.parseFloatStr (tokens[4]))));
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readEnergy",
|
||||
function () {
|
||||
if (this.line.indexOf ("=") < 0) this.discardLinesUntilContains ("=");
|
||||
var tokens = JU.PT.getTokens (this.line.substring (this.line.indexOf ("=")));
|
||||
this.totEnergy = Double.$valueOf (Double.parseDouble (tokens[1]));
|
||||
this.energyUnits = tokens[2];
|
||||
this.discardLinesUntilContains (this.sep);
|
||||
});
|
||||
Clazz.defineMethod (c$, "setEnergy",
|
||||
function () {
|
||||
this.asc.setAtomSetEnergy ("" + this.totEnergy, this.totEnergy.floatValue ());
|
||||
this.asc.setInfo ("Energy", this.totEnergy);
|
||||
this.asc.setAtomSetName ("E = " + this.totEnergy + " " + this.energyUnits);
|
||||
this.totEnergy = null;
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"tags", Clazz.newArray (-1, ["a", "b", "c", "alpha", "beta", "gamma"]));
|
||||
});
|
||||
@@ -0,0 +1,575 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.JanaReader", ["java.lang.Boolean", "$.Exception", "$.Float", "java.util.Hashtable", "JU.A4", "$.BS", "$.Lst", "$.Matrix", "$.P3", "$.PT", "$.Quat", "$.Rdr", "$.V3", "J.adapter.smarter.Atom", "J.api.Interface", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.lattvecs = null;
|
||||
this.thisSub = 0;
|
||||
this.modAxes = null;
|
||||
this.modDim = 0;
|
||||
this.haveM40Data = false;
|
||||
this.qicount = 0;
|
||||
this.molName = null;
|
||||
this.molAtoms = null;
|
||||
this.molTtypes = null;
|
||||
this.modelMolecule = null;
|
||||
this.molHasTLS = false;
|
||||
this.matR = null;
|
||||
this.rho = null;
|
||||
this.firstPosition = false;
|
||||
this.vR = null;
|
||||
this.v0Cart = null;
|
||||
this.isLegendre = false;
|
||||
this.floats = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "JanaReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.floats = Clazz.newFloatArray (6, 0);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.modAxes = this.getFilter ("MODAXES=");
|
||||
this.setFractionalCoordinates (true);
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setCurrentModelInfo ("autoBondUsingOccupation", Boolean.TRUE);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.length < 3) return true;
|
||||
JU.Logger.info (this.line);
|
||||
this.parseTokenStr (this.line);
|
||||
switch ("tit cell ndim qi lat sym spg end wma".indexOf (this.line.substring (0, 3))) {
|
||||
case 0:
|
||||
this.asc.setAtomSetName (this.line.substring (5).trim ());
|
||||
break;
|
||||
case 5:
|
||||
this.cell ();
|
||||
this.setSymmetryOperator ("x,y,z");
|
||||
break;
|
||||
case 10:
|
||||
this.ndim ();
|
||||
break;
|
||||
case 20:
|
||||
if (this.lattvecs == null) this.lattvecs = new JU.Lst ();
|
||||
if (!this.ms.addLatticeVector (this.lattvecs, this.line.substring (8))) this.appendLoadNote (this.line + " not supported");
|
||||
break;
|
||||
case 30:
|
||||
this.setSpaceGroupName (this.getTokens ()[1]);
|
||||
break;
|
||||
case 25:
|
||||
this.symmetry ();
|
||||
break;
|
||||
case 15:
|
||||
this.qi ();
|
||||
break;
|
||||
case 35:
|
||||
while (this.rd () != null) {
|
||||
if (this.line.startsWith ("command") || this.parseIntStr (this.line) >= 0) {
|
||||
this.readM40Data (true);
|
||||
break;
|
||||
}}
|
||||
this.continuing = false;
|
||||
break;
|
||||
case 40:
|
||||
var n = 3 + this.modDim;
|
||||
var m;
|
||||
if (this.thisSub++ == 0) {
|
||||
m = JU.Matrix.identity (n, n);
|
||||
this.ms.addSubsystem ("" + this.thisSub++, m);
|
||||
}m = new JU.Matrix (null, n, n);
|
||||
var a = m.getArray ();
|
||||
var data = Clazz.newFloatArray (n * n, 0);
|
||||
this.fillFloatArray (null, 0, data);
|
||||
for (var i = 0, pt = 0; i < n; i++) for (var j = 0; j < n; j++, pt++) a[i][j] = data[pt];
|
||||
|
||||
|
||||
this.ms.addSubsystem ("" + this.thisSub, m);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "doPreSymmetry",
|
||||
function () {
|
||||
if (this.ms != null) this.ms.setModulation (false, null);
|
||||
if (this.vibsFractional) this.asc.getXSymmetry ().scaleFractionalVibs ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
if (!this.haveM40Data) this.readM40Data (false);
|
||||
if (this.lattvecs != null && this.lattvecs.size () > 0) this.asc.getSymmetry ().addLatticeVectors (this.lattvecs);
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.finalizeReaderASCR ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassSymmetry",
|
||||
function (haveSymmetry) {
|
||||
this.adjustM40Occupancies ();
|
||||
if (this.ms != null && haveSymmetry) {
|
||||
this.ms.setModulation (true, this.asc.getXSymmetry ().getBaseSymmetry ());
|
||||
this.ms.finalizeModulation ();
|
||||
}}, "~B");
|
||||
Clazz.defineMethod (c$, "cell",
|
||||
function () {
|
||||
for (var ipt = 0; ipt < 6; ipt++) this.setUnitCellItem (ipt, this.parseFloat ());
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "ndim",
|
||||
function () {
|
||||
this.ms = J.api.Interface.getOption ("adapter.readers.cif.MSRdr", this.vwr, "file");
|
||||
this.modDim = this.ms.initialize (this, (this.parseIntStr (this.getTokens ()[1]) - 3));
|
||||
});
|
||||
Clazz.defineMethod (c$, "qi",
|
||||
function () {
|
||||
var pt = Clazz.newDoubleArray (this.modDim, 0);
|
||||
pt[this.qicount] = 1;
|
||||
var a = Clazz.newDoubleArray (-1, [this.parseFloat (), this.parseFloat (), this.parseFloat ()]);
|
||||
this.parseTokenStr (this.rd ());
|
||||
for (var i = 0; i < 3; i++) a[i] += this.parseFloat ();
|
||||
|
||||
this.ms.addModulation (null, "W_" + (++this.qicount), a, -1);
|
||||
this.ms.addModulation (null, "F_" + this.qicount + "_coefs_", pt, -1);
|
||||
});
|
||||
Clazz.defineMethod (c$, "symmetry",
|
||||
function () {
|
||||
this.setSymmetryOperator (JU.PT.rep (this.line.substring (9).trim (), " ", ","));
|
||||
});
|
||||
Clazz.defineMethod (c$, "readM40Data",
|
||||
function (haveReader) {
|
||||
if (haveReader) {
|
||||
this.parseM40Floats ();
|
||||
} else {
|
||||
var m40File = this.filePath;
|
||||
var ipt = m40File.lastIndexOf (".");
|
||||
if (ipt < 0) return;
|
||||
m40File = m40File.substring (0, ipt + 2) + "40";
|
||||
var id = m40File.substring (0, ipt);
|
||||
this.reader.close ();
|
||||
this.reader = JU.Rdr.getBR (this.vwr.getLigandModel (id, m40File, "_file", "----"));
|
||||
if (this.out != null) this.out.append ("******************************* M40 DATA *******************************\n");
|
||||
this.readM40Floats ();
|
||||
}this.haveM40Data = true;
|
||||
if (this.line.startsWith ("command")) this.readM40WaveVectors ();
|
||||
var nFree = 0;
|
||||
var nGroups = 0;
|
||||
var isAxial = false;
|
||||
var newSub = (this.thisSub == 0 ? null : new JU.BS ());
|
||||
var iSub = (this.thisSub == 0 ? 1 : this.thisSub);
|
||||
for (var i = 0, n = 0, pt = 0; i < iSub; i++, pt += 10) {
|
||||
nFree = this.getInt (pt, pt + 5);
|
||||
nGroups = this.getInt (pt + 5, pt + 10);
|
||||
isAxial = (this.getInt (pt + 15, pt + 20) == 1);
|
||||
if (nGroups != 0 && i > 0) {
|
||||
throw new Exception ("Jmol cannot read rigid body M40 files for composites");
|
||||
}if (newSub != null) newSub.set (n = n + nFree);
|
||||
}
|
||||
iSub = (newSub == null ? 0 : 1);
|
||||
var nAtoms = -1;
|
||||
var refAtomName = null;
|
||||
this.rho = null;
|
||||
if (nGroups > 0) {
|
||||
JU.Logger.info ("JanaReader found " + nFree + " free atoms and " + nGroups + " groups");
|
||||
this.molName = null;
|
||||
this.molAtoms = new JU.Lst ();
|
||||
this.molTtypes = new JU.Lst ();
|
||||
}while (this.skipToNextAtom () != null) {
|
||||
nAtoms++;
|
||||
var atom = new J.adapter.smarter.Atom ();
|
||||
JU.Logger.info (this.line);
|
||||
var name = this.line.substring (0, 9).trim ();
|
||||
atom.atomName = name;
|
||||
var isRefAtom = name.equals (refAtomName);
|
||||
atom.foccupancy = this.floats[2];
|
||||
var isJanaMolecule = Float.isNaN (atom.foccupancy);
|
||||
if (isJanaMolecule) {
|
||||
var pointGroup = this.getStr (12, 18);
|
||||
if (pointGroup.length > 0 && !pointGroup.equals ("1")) {
|
||||
throw new Exception ("Jmol cannot process M40 files with molecule positions based on point-group symmetry.");
|
||||
}refAtomName = null;
|
||||
if (Float.isNaN (this.floats[4])) refAtomName = this.getStr (28, 37);
|
||||
else this.rho = JU.P3.new3 (this.floats[3], this.floats[4], this.floats[5]);
|
||||
this.molName = name;
|
||||
this.molAtoms.clear ();
|
||||
this.molTtypes.clear ();
|
||||
this.molHasTLS = false;
|
||||
this.firstPosition = true;
|
||||
this.modelMolecule = new JU.Lst ();
|
||||
continue;
|
||||
}var isExcluded = false;
|
||||
var posName = (name.startsWith ("pos#") ? name : null);
|
||||
if (posName == null) {
|
||||
if (!this.filterAtom (atom, 0)) {
|
||||
if (!isRefAtom) continue;
|
||||
isExcluded = true;
|
||||
}this.setAtomCoordXYZ (atom, this.floats[3], this.floats[4], this.floats[5]);
|
||||
if (isRefAtom) {
|
||||
this.rho = JU.P3.newP (atom);
|
||||
if (isExcluded) continue;
|
||||
}this.asc.addAtom (atom);
|
||||
if (iSub > 0) {
|
||||
if (newSub.get (nAtoms)) iSub++;
|
||||
atom.altLoc = ("" + iSub).charAt (0);
|
||||
}this.readAtomRecord (atom, null, null, false);
|
||||
if (this.molAtoms != null) this.molAtoms.addLast (atom);
|
||||
} else {
|
||||
if (this.molAtoms.size () == 0) continue;
|
||||
this.processPosition (posName, atom, isAxial);
|
||||
}}
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "getInt",
|
||||
function (col1, col2) {
|
||||
var n = this.line.length;
|
||||
return (n > col1 ? this.parseIntStr (this.getStr (col1, col2)) : 0);
|
||||
}, "~N,~N");
|
||||
Clazz.defineMethod (c$, "getStr",
|
||||
function (col1, col2) {
|
||||
var n = this.line.length;
|
||||
return (n > col1 ? this.line.substring (col1, Math.min (n, col2)).trim () : "");
|
||||
}, "~N,~N");
|
||||
Clazz.defineMethod (c$, "getFlag",
|
||||
function (i) {
|
||||
return (this.getInt (i, i + 1) > 0);
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "skipToNextAtom",
|
||||
function () {
|
||||
while (this.readM40Floats () != null && (this.line.length == 0 || this.line.charAt (0) == ' ' || this.line.charAt (0) == '-')) {
|
||||
}
|
||||
return this.line;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readM40WaveVectors",
|
||||
function () {
|
||||
while (!this.readM40Floats ().contains ("end")) if (this.line.startsWith ("wave")) {
|
||||
var tokens = this.getTokens ();
|
||||
var pt = Clazz.newDoubleArray (this.modDim, 0);
|
||||
for (var i = 0; i < this.modDim; i++) pt[i] = this.parseFloatStr (tokens[i + 2]);
|
||||
|
||||
this.ms.addModulation (null, "F_" + this.parseIntStr (tokens[1]) + "_coefs_", pt, -1);
|
||||
}
|
||||
this.readM40Floats ();
|
||||
});
|
||||
Clazz.defineMethod (c$, "processPosition",
|
||||
function (posName, pos, isAxial) {
|
||||
pos.atomName = this.molName + "_" + posName;
|
||||
var isImproper = (this.getInt (9, 11) == -1);
|
||||
var systType = this.getInt (13, 14);
|
||||
var rm = (systType == 0 ? null : new JU.P3 ());
|
||||
var rp = (systType == 0 ? null : new JU.P3 ());
|
||||
if (systType != 0) {
|
||||
throw new Exception ("Jmol can only read rigid body groups with basic crystallographic settings.");
|
||||
}var rotData = this.readAtomRecord (pos, rm, rp, true);
|
||||
var name = pos.atomName;
|
||||
var n = this.molAtoms.size ();
|
||||
JU.Logger.info (name + " Molecular group " + this.molName + " has " + n + " atoms");
|
||||
var ext = "_" + posName.substring (4);
|
||||
var vTrans = JU.V3.new3 (pos.anisoBorU[3], pos.anisoBorU[4], pos.anisoBorU[5]);
|
||||
var phi = JU.Quat.newAA (JU.A4.newVA (JU.V3.new3 (0, 0, 1), (pos.anisoBorU[0] / 180 * 3.141592653589793)));
|
||||
var chi = JU.Quat.newAA (JU.A4.newVA (isAxial ? JU.V3.new3 (0, 1, 0) : JU.V3.new3 (1, 0, 0), (pos.anisoBorU[1] / 180 * 3.141592653589793)));
|
||||
var psi = JU.Quat.newAA (JU.A4.newVA (isAxial ? JU.V3.new3 (1, 0, 0) : JU.V3.new3 (0, 0, 1), (pos.anisoBorU[2] / 180 * 3.141592653589793)));
|
||||
this.matR = phi.mulQ (chi).mulQ (psi).getMatrix ();
|
||||
if (isImproper) this.matR.scale (-1);
|
||||
var script = "";
|
||||
for (var i = 0; i < n; i++) {
|
||||
var a = this.molAtoms.get (i);
|
||||
var newName = a.atomName;
|
||||
script += ", " + newName;
|
||||
if (this.firstPosition) {
|
||||
newName += ext;
|
||||
this.modelMolecule.addLast (JU.P3.newP (a));
|
||||
} else {
|
||||
a = this.asc.newCloneAtom (a);
|
||||
newName = newName.substring (0, newName.lastIndexOf ("_")) + ext;
|
||||
}a.atomName = newName;
|
||||
var v0 = JU.V3.newVsub (this.modelMolecule.get (i), this.rho);
|
||||
this.getSymmetry ().toCartesian (this.v0Cart = JU.V3.newV (v0), true);
|
||||
this.vR = JU.V3.newV (v0);
|
||||
this.cartesianProduct (this.vR, null);
|
||||
a.setT (this.rho);
|
||||
a.add (vTrans);
|
||||
a.add (this.vR);
|
||||
this.copyModulations (";" + pos.atomName, ";" + newName);
|
||||
if (rotData != null) this.setRigidBodyRotations (";" + newName, rotData);
|
||||
}
|
||||
this.firstPosition = false;
|
||||
script = "@" + this.molName + ext + script.substring (1);
|
||||
this.addJmolScript (script);
|
||||
this.appendLoadNote (script);
|
||||
}, "~S,J.adapter.smarter.Atom,~B");
|
||||
Clazz.defineMethod (c$, "cartesianProduct",
|
||||
function (vA, vB) {
|
||||
this.symmetry.toCartesian (vA, true);
|
||||
if (vB == null) this.matR.rotate2 (vA, vA);
|
||||
else vA.cross (vA, vB);
|
||||
this.symmetry.toFractional (vA, true);
|
||||
}, "JU.T3,JU.T3");
|
||||
Clazz.defineMethod (c$, "readAtomRecord",
|
||||
function (atom, rm, rp, isPos) {
|
||||
var label = ";" + atom.atomName;
|
||||
var tType = (isPos ? -1 : this.getInt (13, 14));
|
||||
if (!isPos && this.molTtypes != null) this.molTtypes.addLast (Integer.$valueOf (tType));
|
||||
var haveSpecialOcc = this.getFlag (60);
|
||||
var haveSpecialDisp = this.getFlag (61);
|
||||
var haveSpecialUij = this.getFlag (62);
|
||||
var nOcc = this.getInt (65, 68);
|
||||
var nDisp = this.getInt (68, 71);
|
||||
var nUij = this.getInt (71, 74);
|
||||
if (rm != null) {
|
||||
this.readM40Floats ();
|
||||
rm.set (this.floats[0], this.floats[1], this.floats[2]);
|
||||
rp.set (this.floats[3], this.floats[4], this.floats[5]);
|
||||
}if (tType > 2) this.readM40Floats ();
|
||||
this.readM40Floats ();
|
||||
switch (tType) {
|
||||
case 6:
|
||||
case 5:
|
||||
case 4:
|
||||
case 3:
|
||||
this.readLines (tType - 1);
|
||||
this.appendLoadNote ("Skipping temperature factors with order > 2");
|
||||
case 2:
|
||||
case -1:
|
||||
for (var j = 0; j < 6; j++) this.asc.setU (atom, j, this.floats[j]);
|
||||
|
||||
break;
|
||||
case 1:
|
||||
if (this.floats[0] != 0) this.asc.setU (atom, 7, this.floats[0]);
|
||||
break;
|
||||
case 0:
|
||||
this.molHasTLS = true;
|
||||
this.appendLoadNote ("Jmol cannot process molecular TLS parameters");
|
||||
break;
|
||||
}
|
||||
if (this.modDim == 0) return null;
|
||||
if (isPos && this.molHasTLS) this.readLines (4);
|
||||
var pt;
|
||||
var o_0 = (nOcc > 0 && !haveSpecialOcc ? this.parseFloatStr (this.rd ()) : 1);
|
||||
if (o_0 != 1) this.ms.addModulation (null, "J_O#0" + label, Clazz.newDoubleArray (-1, [atom.foccupancy, o_0, 0]), -1);
|
||||
atom.foccupancy *= o_0;
|
||||
var wv = 0;
|
||||
var a1;
|
||||
var a2;
|
||||
this.isLegendre = false;
|
||||
for (var j = 0; j < nOcc; j++) {
|
||||
if (haveSpecialOcc) {
|
||||
var data = this.readM40FloatLines (2, 1);
|
||||
a2 = data[0][0];
|
||||
a1 = data[1][0];
|
||||
} else {
|
||||
wv = j + 1;
|
||||
this.readM40Floats ();
|
||||
a1 = this.floats[0];
|
||||
a2 = this.floats[1];
|
||||
}pt = Clazz.newDoubleArray (-1, [a1, a2, 0]);
|
||||
if (a1 != 0 || a2 != 0) this.ms.addModulation (null, "O_" + wv + "#0" + label, pt, -1);
|
||||
}
|
||||
for (var j = 0; j < nDisp; j++) {
|
||||
if (haveSpecialDisp) {
|
||||
this.readM40Floats ();
|
||||
var c = this.floats[3];
|
||||
var w = this.floats[4];
|
||||
for (var k = 0; k < 3; k++) if (this.floats[k] != 0) this.ms.addModulation (null, "D_S#" + J.adapter.readers.xtal.JanaReader.XYZ[k] + label, Clazz.newDoubleArray (-1, [c, w, this.floats[k]]), -1);
|
||||
|
||||
} else {
|
||||
this.addSinCos (j, "D_", label, isPos);
|
||||
}}
|
||||
var rotData = (isPos && nDisp > 0 ? this.readM40FloatLines (nDisp, 6) : null);
|
||||
if (!isPos) {
|
||||
if (this.isLegendre) nUij *= 2;
|
||||
for (var j = 0; j < nUij; j++) {
|
||||
if (tType == 1) {
|
||||
this.addSinCos (j, "U_", label, false);
|
||||
} else {
|
||||
if (haveSpecialUij) {
|
||||
JU.Logger.error ("JanaReader -- not interpreting SpecialUij flag: " + this.line);
|
||||
} else if (this.isLegendre) {
|
||||
var data = this.readM40FloatLines (1, 6);
|
||||
var order = j + 1;
|
||||
var coeff = 0;
|
||||
for (var k = 0, p = 0; k < 6; k++, p += 3) {
|
||||
if ((coeff = data[0][k]) != 0) this.ms.addModulation (null, "U_L" + order + "#" + "U11U22U33U12U13U23UISO".substring (p, p + 3) + label, Clazz.newDoubleArray (-1, [coeff, order, 0]), -1);
|
||||
}
|
||||
} else {
|
||||
var data = this.readM40FloatLines (2, 6);
|
||||
for (var k = 0, p = 0; k < 6; k++, p += 3) {
|
||||
var csin = data[1][k];
|
||||
var ccos = data[0][k];
|
||||
this.ms.addModulation (null, "U_" + (j + 1) + "#" + "U11U22U33U12U13U23UISO".substring (p, p + 3) + label, Clazz.newDoubleArray (-1, [csin, ccos, 0]), -1);
|
||||
}
|
||||
}}}
|
||||
}return rotData;
|
||||
}, "J.adapter.smarter.Atom,JU.P3,JU.P3,~B");
|
||||
Clazz.defineMethod (c$, "addSinCos",
|
||||
function (j, key, label, isPos) {
|
||||
this.readM40Floats ();
|
||||
if (this.isLegendre) {
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var order = (j * 2 + i + 1);
|
||||
for (var k = 0; k < 3; ++k) {
|
||||
var coeff = this.floats[3 * i + k];
|
||||
if (coeff == 0) {
|
||||
continue;
|
||||
}var axis = J.adapter.readers.xtal.JanaReader.XYZ[k % 3];
|
||||
if (this.modAxes != null && this.modAxes.indexOf (axis.toUpperCase ()) < 0) continue;
|
||||
var id = key + "L#" + axis + order + label;
|
||||
this.ms.addModulation (null, id, Clazz.newDoubleArray (-1, [coeff, order, 0]), -1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}this.ensureFourier (j);
|
||||
for (var k = 0; k < 3; ++k) {
|
||||
var csin = this.floats[k];
|
||||
var ccos = this.floats[k + 3];
|
||||
if (csin == 0 && ccos == 0) {
|
||||
if (!isPos) continue;
|
||||
csin = 1e-10;
|
||||
}var axis = J.adapter.readers.xtal.JanaReader.XYZ[k % 3];
|
||||
if (this.modAxes != null && this.modAxes.indexOf (axis.toUpperCase ()) < 0) continue;
|
||||
var id = key + (j + 1) + "#" + axis + label;
|
||||
this.ms.addModulation (null, id, Clazz.newDoubleArray (-1, [csin, ccos, 0]), -1);
|
||||
}
|
||||
}, "~N,~S,~S,~B");
|
||||
Clazz.defineMethod (c$, "ensureFourier",
|
||||
function (j) {
|
||||
var pt;
|
||||
if (j > 0 && this.ms.getMod ("F_" + (++j) + "_coefs_") == null && (pt = this.ms.getMod ("F_1_coefs_")) != null) {
|
||||
var p = Clazz.newDoubleArray (this.modDim, 0);
|
||||
for (var i = this.modDim; --i >= 0; ) p[i] = pt[i] * j;
|
||||
|
||||
this.ms.addModulation (null, "F_" + j + "_coefs_", p, -1);
|
||||
}}, "~N");
|
||||
Clazz.defineMethod (c$, "readM40Floats",
|
||||
function () {
|
||||
if ((this.line = this.rd ()) == null || this.line.indexOf ("-------") >= 0) return (this.line = null);
|
||||
if (this.debugging) JU.Logger.debug (this.line);
|
||||
this.parseM40Floats ();
|
||||
return this.line;
|
||||
});
|
||||
Clazz.defineMethod (c$, "parseM40Floats",
|
||||
function () {
|
||||
var ptLast = this.line.length - 9;
|
||||
for (var i = 0, pt = 0; i < 6; i++, pt += 9) {
|
||||
this.floats[i] = (pt <= ptLast ? this.parseFloatStr (this.line.substring (pt, pt + 9)) : NaN);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "readM40FloatLines",
|
||||
function (nLines, nFloats) {
|
||||
var data = Clazz.newFloatArray (nLines, nFloats, 0);
|
||||
for (var i = 0; i < nLines; i++) {
|
||||
this.readM40Floats ();
|
||||
if (this.line.indexOf ("Legendre") == 19) this.isLegendre = true;
|
||||
for (var j = 0; j < nFloats; j++) data[i][j] = this.floats[j];
|
||||
|
||||
}
|
||||
return data;
|
||||
}, "~N,~N");
|
||||
Clazz.defineMethod (c$, "adjustM40Occupancies",
|
||||
function () {
|
||||
var htSiteMult = new java.util.Hashtable ();
|
||||
var atoms = this.asc.atoms;
|
||||
var symmetry = this.asc.getSymmetry ();
|
||||
for (var i = this.asc.ac; --i >= 0; ) {
|
||||
var a = atoms[i];
|
||||
var ii = htSiteMult.get (a.atomName);
|
||||
if (ii == null) htSiteMult.put (a.atomName, ii = Integer.$valueOf (symmetry.getSiteMultiplicity (a)));
|
||||
a.foccupancy *= ii.intValue ();
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "copyModulations",
|
||||
function (label, newLabel) {
|
||||
var mapTemp = new java.util.Hashtable ();
|
||||
for (var e, $e = this.ms.getModulationMap ().entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) {
|
||||
var key = e.getKey ();
|
||||
if (!key.contains (label)) continue;
|
||||
key = JU.PT.rep (key, label, newLabel);
|
||||
var val = e.getValue ();
|
||||
switch (key.charAt (0)) {
|
||||
case 'O':
|
||||
this.setRigidBodyPhase (key, val = Clazz.newDoubleArray (-1, [val[0], val[1], 0]));
|
||||
break;
|
||||
case 'D':
|
||||
break;
|
||||
case 'U':
|
||||
continue;
|
||||
}
|
||||
mapTemp.put (key, val);
|
||||
}
|
||||
for (var e, $e = mapTemp.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) this.ms.addModulation (null, e.getKey (), e.getValue (), -1);
|
||||
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "setRigidBodyPhase",
|
||||
function (key, v) {
|
||||
var isCenter = false;
|
||||
switch (this.ms.getModType (key)) {
|
||||
case 'o':
|
||||
case 'f':
|
||||
case 'u':
|
||||
break;
|
||||
case 'c':
|
||||
case 's':
|
||||
isCenter = true;
|
||||
break;
|
||||
}
|
||||
var nqDotD = 0;
|
||||
var n = -1;
|
||||
var qcoefs = this.ms.getQCoefs (key);
|
||||
for (var i = this.modDim; --i >= 0; ) {
|
||||
if (qcoefs[i] != 0) {
|
||||
n = qcoefs[i];
|
||||
var q = this.ms.getMod ("W_" + (i + 1));
|
||||
nqDotD = n * (q[0] * this.vR.x + q[1] * this.vR.y + q[2] * this.vR.z);
|
||||
break;
|
||||
}}
|
||||
if (isCenter) {
|
||||
v[0] += nqDotD;
|
||||
} else {
|
||||
var sA = v[0];
|
||||
var cA = v[1];
|
||||
var sX = Math.sin (2 * 3.141592653589793 * nqDotD);
|
||||
var cX = Math.cos (2 * 3.141592653589793 * nqDotD);
|
||||
v[0] = sA * cX + cA * sX;
|
||||
v[1] = -sA * sX + cA * cX;
|
||||
}return v;
|
||||
}, "~S,~A");
|
||||
Clazz.defineMethod (c$, "setRigidBodyRotations",
|
||||
function (label, params) {
|
||||
var n = params.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
this.ensureFourier (i);
|
||||
var key = "D_" + (i + 1);
|
||||
var data = params[i];
|
||||
var vsin = JU.V3.new3 (data[0], data[1], data[2]);
|
||||
var vcos = JU.V3.new3 (data[3], data[4], data[5]);
|
||||
this.cartesianProduct (vcos, this.v0Cart);
|
||||
this.cartesianProduct (vsin, this.v0Cart);
|
||||
var keyx = key + "#x" + label;
|
||||
var keyy = key + "#y" + label;
|
||||
var keyz = key + "#z" + label;
|
||||
var vx = this.combineModulation (keyx, vsin.x, vcos.x);
|
||||
var vy = this.combineModulation (keyy, vsin.y, vcos.y);
|
||||
var vz = this.combineModulation (keyz, vsin.z, vcos.z);
|
||||
vsin.set (vx[0], vy[0], vz[0]);
|
||||
vcos.set (vx[1], vy[1], vz[1]);
|
||||
this.cartesianProduct (vsin, null);
|
||||
this.cartesianProduct (vcos, null);
|
||||
this.setMolecularModulation (keyx, vsin.x, vcos.x);
|
||||
this.setMolecularModulation (keyy, vsin.y, vcos.y);
|
||||
this.setMolecularModulation (keyz, vsin.z, vcos.z);
|
||||
}
|
||||
}, "~S,~A");
|
||||
Clazz.defineMethod (c$, "combineModulation",
|
||||
function (key, csin, ccos) {
|
||||
var v = this.ms.getMod (key);
|
||||
return Clazz.newDoubleArray (-1, [v[0] + csin, v[1] + ccos, 0]);
|
||||
}, "~S,~N,~N");
|
||||
Clazz.defineMethod (c$, "setMolecularModulation",
|
||||
function (key, csin, ccos) {
|
||||
this.ms.addModulation (null, key, this.setRigidBodyPhase (key, Clazz.newDoubleArray (-1, [csin, ccos, 0])), -1);
|
||||
}, "~S,~N,~N");
|
||||
Clazz.defineStatics (c$,
|
||||
"records", "tit cell ndim qi lat sym spg end wma",
|
||||
"TITLE", 0,
|
||||
"CELL", 5,
|
||||
"NDIM", 10,
|
||||
"QI", 15,
|
||||
"LATT", 20,
|
||||
"SYM", 25,
|
||||
"SPG", 30,
|
||||
"END", 35,
|
||||
"WMATRIX", 40,
|
||||
"U_LIST", "U11U22U33U12U13U23UISO",
|
||||
"XYZ", Clazz.newArray (-1, ["x", "y", "z"]));
|
||||
});
|
||||
@@ -0,0 +1,184 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader", "java.util.Hashtable", "JU.Lst", "$.SB"], "J.adapter.readers.xtal.MagresReader", ["java.lang.Double", "JU.PT", "J.adapter.smarter.Atom", "JU.Escape", "$.Logger", "$.Tensor"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.currentBlock = -1;
|
||||
this.cellParams = null;
|
||||
this.magresUnits = null;
|
||||
this.interactionTensors = null;
|
||||
this.header = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "MagresReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.magresUnits = new java.util.Hashtable ();
|
||||
this.interactionTensors = new JU.Lst ();
|
||||
this.header = new JU.SB ();
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.setFractionalCoordinates (false);
|
||||
this.ignoreFileSpaceGroupName = true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "finalizeSubclassReader",
|
||||
function () {
|
||||
this.asc.setInfo ("fileHeader", this.header.toString ());
|
||||
this.finalizeReaderASCR ();
|
||||
if (this.interactionTensors.size () > 0) this.asc.setCurrentModelInfo ("interactionTensors", this.interactionTensors);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (!this.trimLine ()) return true;
|
||||
switch (this.checkBlock ()) {
|
||||
case 0:
|
||||
this.header.append (this.line).append ("\n");
|
||||
this.appendLoadNote (this.line);
|
||||
break;
|
||||
case 1:
|
||||
if (this.cellParams == null && this.line.startsWith ("lattice")) return this.readCellParams ();
|
||||
if (this.line.startsWith ("symmetry")) return this.readSymmetry ();
|
||||
if (this.line.startsWith ("units")) return this.setUnits (false);
|
||||
if (this.line.startsWith ("atom")) return this.readAtom ();
|
||||
break;
|
||||
case 2:
|
||||
if (this.line.startsWith ("units")) return this.setUnits (true);
|
||||
return this.readTensor ();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "trimLine",
|
||||
function () {
|
||||
var pt = this.line.indexOf ("#");
|
||||
if (pt >= 0) this.line = this.line.substring (0, pt);
|
||||
this.line = this.line.trim ();
|
||||
return (this.line.length > 0);
|
||||
});
|
||||
Clazz.defineMethod (c$, "checkBlock",
|
||||
function () {
|
||||
if (!(this.line.startsWith ("<") && this.line.endsWith (">")) && !(this.line.startsWith ("[") && this.line.endsWith ("]"))) return this.currentBlock;
|
||||
this.line = JU.PT.rep (this.line, "<", "[");
|
||||
this.line = JU.PT.rep (this.line, ">", "]");
|
||||
switch (Clazz.doubleToInt (("...............[calculation]..[/calculation].[atoms]........[/atoms].......[magres].......[/magres]......").indexOf (this.line + ".") / 15)) {
|
||||
case 0:
|
||||
JU.Logger.info ("block indicator ignored: " + this.line);
|
||||
break;
|
||||
case 1:
|
||||
if (this.currentBlock == -1) this.currentBlock = 0;
|
||||
break;
|
||||
case 2:
|
||||
if (this.currentBlock == 0) this.currentBlock = -1;
|
||||
break;
|
||||
case 3:
|
||||
if (this.currentBlock == -1) {
|
||||
this.currentBlock = 1;
|
||||
this.asc.newAtomSet ();
|
||||
this.magresUnits = new java.util.Hashtable ();
|
||||
}break;
|
||||
case 4:
|
||||
if (this.currentBlock == 1) this.currentBlock = -1;
|
||||
break;
|
||||
case 5:
|
||||
if (this.currentBlock == -1) {
|
||||
this.currentBlock = 2;
|
||||
this.magresUnits = new java.util.Hashtable ();
|
||||
this.asc.setCurrentModelInfo ("magresUnits", this.magresUnits);
|
||||
}break;
|
||||
case 6:
|
||||
if (this.currentBlock == 2) this.currentBlock = -1;
|
||||
break;
|
||||
}
|
||||
return -2;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setUnits",
|
||||
function (isMagresBlock) {
|
||||
var tokens = this.getTokens ();
|
||||
var id = tokens[1];
|
||||
if (isMagresBlock) this.appendLoadNote ("Ellipsoid set " + JU.PT.esc (id) + ": " + (id.startsWith ("ms") ? "Magnetic Shielding" : id.startsWith ("efg") ? "Electric Field Gradient" : id.startsWith ("isc") ? "J-Coupling" : "?"));
|
||||
this.magresUnits.put (id, tokens[2]);
|
||||
return true;
|
||||
}, "~B");
|
||||
Clazz.defineMethod (c$, "readSymmetry",
|
||||
function () {
|
||||
this.setSymmetryOperator (this.getTokens ()[1]);
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCellParams",
|
||||
function () {
|
||||
var tokens = this.getTokens ();
|
||||
this.cellParams = Clazz.newFloatArray (9, 0);
|
||||
for (var i = 0; i < 9; i++) this.cellParams[i] = this.parseFloatStr (tokens[i + 1]);
|
||||
|
||||
this.addExplicitLatticeVector (0, this.cellParams, 0);
|
||||
this.addExplicitLatticeVector (1, this.cellParams, 3);
|
||||
this.addExplicitLatticeVector (2, this.cellParams, 6);
|
||||
this.setSpaceGroupName ("P1");
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtom",
|
||||
function () {
|
||||
var units = this.magresUnits.get ("atom");
|
||||
if (units == null) return true;
|
||||
var f = (units.startsWith ("A") ? 1 : 0.5291772);
|
||||
var tokens = this.getTokens ();
|
||||
var atom = new J.adapter.smarter.Atom ();
|
||||
var pt = 1;
|
||||
atom.elementSymbol = tokens[pt++];
|
||||
atom.atomName = J.adapter.readers.xtal.MagresReader.getAtomName (tokens[pt++], tokens[pt++]);
|
||||
this.asc.addAtomWithMappedName (atom);
|
||||
var x = this.parseFloatStr (tokens[pt++]) * f;
|
||||
var y = this.parseFloatStr (tokens[pt++]) * f;
|
||||
var z = this.parseFloatStr (tokens[pt++]) * f;
|
||||
atom.set (x, y, z);
|
||||
this.setAtomCoord (atom);
|
||||
return true;
|
||||
});
|
||||
c$.getAtomName = Clazz.defineMethod (c$, "getAtomName",
|
||||
function (name, index) {
|
||||
return name + "_" + index;
|
||||
}, "~S,~S");
|
||||
Clazz.defineMethod (c$, "readTensor",
|
||||
function () {
|
||||
var tokens = this.getTokens ();
|
||||
var type = tokens[0];
|
||||
var units = this.magresUnits.get (type);
|
||||
if (units == null) {
|
||||
JU.Logger.warn (type + " ignored; no units defined; line: " + this.line);
|
||||
return true;
|
||||
}var isIsc = type.startsWith ("isc");
|
||||
if (tokens.length == 10) {
|
||||
this.magresUnits.remove (type);
|
||||
var data = Clazz.newFloatArray (9, 0);
|
||||
for (var i = 0; i < 9; ) data[i] = this.parseFloatStr (tokens[++i]);
|
||||
|
||||
JU.Logger.info ("Magres reader creating magres_" + type + ": " + JU.Escape.eAF (data));
|
||||
this.asc.setCurrentModelInfo ("magres_" + type, data);
|
||||
}var atomName1 = J.adapter.readers.xtal.MagresReader.getAtomName (tokens[1], tokens[2]);
|
||||
var pt = 3;
|
||||
var atomName2 = (isIsc ? J.adapter.readers.xtal.MagresReader.getAtomName (tokens[pt++], tokens[pt++]) : null);
|
||||
if (atomName1.equals (atomName2)) {
|
||||
JU.Logger.warn (type + " ignored; atom1 == atom2 for " + atomName1 + " line: " + this.line);
|
||||
return true;
|
||||
}var id = atomName1;
|
||||
if (atomName2 != null) id += "//" + atomName2;
|
||||
var a = Clazz.newDoubleArray (3, 3, 0);
|
||||
for (var i = 0; i < 3; i++) for (var j = 0; j < 3; j++) a[i][j] = Double.$valueOf (tokens[pt++]).doubleValue ();
|
||||
|
||||
|
||||
var a1 = this.asc.getAtomFromName (atomName1);
|
||||
if (a1 == null) return true;
|
||||
var a2 = null;
|
||||
var t = new JU.Tensor ().setFromAsymmetricTensor (a, type, id);
|
||||
if (atomName2 == null) {
|
||||
a1.addTensor (t, null, false);
|
||||
} else {
|
||||
a2 = this.asc.getAtomFromName (atomName2);
|
||||
if (a2 == null) return true;
|
||||
this.interactionTensors.addLast (t);
|
||||
}t.setAtomIndexes (a1.index, (a2 == null ? -1 : a2.index));
|
||||
return true;
|
||||
});
|
||||
Clazz.defineStatics (c$,
|
||||
"BLOCK_NEW", -2,
|
||||
"BLOCK_NONE", -1,
|
||||
"BLOCK_CALC", 0,
|
||||
"BLOCK_ATOMS", 1,
|
||||
"BLOCK_MAGRES", 2);
|
||||
});
|
||||
@@ -0,0 +1,183 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.ShelxReader", ["java.lang.Float", "JU.AU", "$.PT", "J.adapter.smarter.Atom", "JU.Logger"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.sfacElementSymbols = null;
|
||||
this.isCmdf = false;
|
||||
this.tokens = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "ShelxReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.setFractionalCoordinates (true);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
var lineLength;
|
||||
while ((lineLength = (this.line = this.line.trim ()).length) > 0 && this.line.charAt (lineLength - 1) == '=') this.line = this.line.substring (0, lineLength - 1) + this.rd ();
|
||||
|
||||
this.tokens = this.getTokens ();
|
||||
if (this.tokens.length == 0) return true;
|
||||
var command = this.tokens[0].toUpperCase ();
|
||||
if (command.equals ("TITL")) {
|
||||
if (!this.doGetModel (++this.modelNumber, null)) return this.checkLastModel ();
|
||||
this.sfacElementSymbols = null;
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.setFractionalCoordinates (true);
|
||||
this.asc.newAtomSet ();
|
||||
this.asc.setAtomSetName (this.line.substring (4).trim ());
|
||||
return true;
|
||||
}if (!this.doProcessLines || lineLength < 3) return true;
|
||||
if (";ZERR;DISP;UNIT;LAUE;REM;MORE;TIME;HKLF;OMIT;SHEL;BASF;TWIN;EXTI;SWAT;HOPE;MERG;SPEC;RESI;MOVE;ANIS;AFIX;HFIX;FRAG;FEND;EXYZ;EXTI;EADP;EQIV;CONN;PART;BIND;FREE;DFIX;DANG;BUMP;SAME;SADI;CHIV;FLAT;DELU;SIMU;DEFS;ISOR;NCSY;SUMP;L.S.;CGLS;BLOC;DAMP;STIR;WGHT;FVAR;BOND;CONF;MPLA;RTAB;HTAB;LIST;ACTA;SIZE;TEMP;WPDB;FMAP;GRID;PLAN;MOLE;".indexOf (";" + command + ";") >= 0) return true;
|
||||
for (var i = J.adapter.readers.xtal.ShelxReader.supportedRecordTypes.length; --i >= 0; ) if (command.equals (J.adapter.readers.xtal.ShelxReader.supportedRecordTypes[i])) {
|
||||
this.processSupportedRecord (i);
|
||||
return true;
|
||||
}
|
||||
if (!this.isCmdf) this.assumeAtomRecord ();
|
||||
return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "processSupportedRecord",
|
||||
function (recordIndex) {
|
||||
switch (recordIndex) {
|
||||
case 0:
|
||||
case 8:
|
||||
break;
|
||||
case 1:
|
||||
this.cell ();
|
||||
this.setSymmetryOperator ("x,y,z");
|
||||
break;
|
||||
case 2:
|
||||
this.setSpaceGroupName (JU.PT.parseTrimmedAt (this.line, 4));
|
||||
break;
|
||||
case 3:
|
||||
this.parseSfacRecord ();
|
||||
break;
|
||||
case 4:
|
||||
this.parseLattRecord ();
|
||||
break;
|
||||
case 5:
|
||||
this.parseSymmRecord ();
|
||||
break;
|
||||
case 6:
|
||||
this.isCmdf = true;
|
||||
break;
|
||||
case 7:
|
||||
this.isCmdf = true;
|
||||
this.processCmdfAtoms ();
|
||||
break;
|
||||
}
|
||||
}, "~N");
|
||||
Clazz.defineMethod (c$, "parseLattRecord",
|
||||
function () {
|
||||
this.asc.getXSymmetry ().setLatticeParameter (this.parseIntStr (this.tokens[1]));
|
||||
});
|
||||
Clazz.defineMethod (c$, "parseSymmRecord",
|
||||
function () {
|
||||
this.setSymmetryOperator (this.line.substring (4).trim ());
|
||||
});
|
||||
Clazz.defineMethod (c$, "cell",
|
||||
function () {
|
||||
var ioff = this.tokens.length - 6;
|
||||
if (ioff == 2) this.asc.setInfo ("wavelength", Float.$valueOf (this.parseFloatStr (this.tokens[1])));
|
||||
for (var ipt = 0; ipt < 6; ipt++) this.setUnitCellItem (ipt, this.parseFloatStr (this.tokens[ipt + ioff]));
|
||||
|
||||
});
|
||||
Clazz.defineMethod (c$, "parseSfacRecord",
|
||||
function () {
|
||||
var allElementSymbols = true;
|
||||
for (var i = this.tokens.length; allElementSymbols && --i >= 1; ) {
|
||||
var token = this.tokens[i];
|
||||
allElementSymbols = J.adapter.readers.xtal.ShelxReader.isValidElementSymbolNoCaseSecondChar (token);
|
||||
}
|
||||
var sfacTokens = JU.PT.getTokens (this.line.substring (4));
|
||||
if (allElementSymbols) this.parseSfacElementSymbols (sfacTokens);
|
||||
else this.parseSfacCoefficients (sfacTokens);
|
||||
});
|
||||
Clazz.defineMethod (c$, "parseSfacElementSymbols",
|
||||
function (sfacTokens) {
|
||||
if (this.sfacElementSymbols == null) {
|
||||
this.sfacElementSymbols = sfacTokens;
|
||||
} else {
|
||||
var oldCount = this.sfacElementSymbols.length;
|
||||
var tokenCount = sfacTokens.length;
|
||||
this.sfacElementSymbols = JU.AU.arrayCopyS (this.sfacElementSymbols, oldCount + tokenCount);
|
||||
for (var i = tokenCount; --i >= 0; ) this.sfacElementSymbols[oldCount + i] = sfacTokens[i];
|
||||
|
||||
}}, "~A");
|
||||
Clazz.defineMethod (c$, "parseSfacCoefficients",
|
||||
function (sfacTokens) {
|
||||
var a1 = this.parseFloatStr (sfacTokens[1]);
|
||||
var a2 = this.parseFloatStr (sfacTokens[3]);
|
||||
var a3 = this.parseFloatStr (sfacTokens[5]);
|
||||
var a4 = this.parseFloatStr (sfacTokens[7]);
|
||||
var c = this.parseFloatStr (sfacTokens[9]);
|
||||
var z = Math.round (a1 + a2 + a3 + a4 + c);
|
||||
var elementSymbol = J.adapter.smarter.AtomSetCollectionReader.getElementSymbol (z);
|
||||
var oldCount = 0;
|
||||
if (this.sfacElementSymbols == null) {
|
||||
this.sfacElementSymbols = new Array (1);
|
||||
} else {
|
||||
oldCount = this.sfacElementSymbols.length;
|
||||
this.sfacElementSymbols = JU.AU.arrayCopyS (this.sfacElementSymbols, oldCount + 1);
|
||||
this.sfacElementSymbols[oldCount] = elementSymbol;
|
||||
}this.sfacElementSymbols[oldCount] = elementSymbol;
|
||||
}, "~A");
|
||||
Clazz.defineMethod (c$, "assumeAtomRecord",
|
||||
function () {
|
||||
var atomName = this.tokens[0];
|
||||
var elementIndex = this.parseIntStr (this.tokens[1]);
|
||||
var x = this.parseFloatStr (this.tokens[2]);
|
||||
var y = this.parseFloatStr (this.tokens[3]);
|
||||
var z = this.parseFloatStr (this.tokens[4]);
|
||||
if (Float.isNaN (x) || Float.isNaN (y) || Float.isNaN (z)) {
|
||||
JU.Logger.error ("skipping line " + this.line);
|
||||
return;
|
||||
}elementIndex--;
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.atomName = atomName;
|
||||
if (this.sfacElementSymbols != null && elementIndex >= 0 && elementIndex < this.sfacElementSymbols.length) atom.elementSymbol = this.sfacElementSymbols[elementIndex];
|
||||
this.setAtomCoordXYZ (atom, x, y, z);
|
||||
if (this.tokens.length == 12) {
|
||||
var data = Clazz.newFloatArray (8, 0);
|
||||
data[0] = this.parseFloatStr (this.tokens[6]);
|
||||
data[1] = this.parseFloatStr (this.tokens[7]);
|
||||
data[2] = this.parseFloatStr (this.tokens[8]);
|
||||
data[3] = this.parseFloatStr (this.tokens[11]);
|
||||
data[4] = this.parseFloatStr (this.tokens[10]);
|
||||
data[5] = this.parseFloatStr (this.tokens[9]);
|
||||
for (var i = 0; i < 6; i++) if (Float.isNaN (data[i])) {
|
||||
JU.Logger.error ("Bad anisotropic Uij data: " + this.line);
|
||||
return;
|
||||
}
|
||||
this.asc.setAnisoBorU (atom, data, 8);
|
||||
}});
|
||||
Clazz.defineMethod (c$, "processCmdfAtoms",
|
||||
function () {
|
||||
while (this.rd () != null && this.line.length > 10) {
|
||||
this.tokens = this.getTokens ();
|
||||
this.addAtomXYZSymName (this.tokens, 2, this.getSymbol (this.tokens[0]), this.tokens[1]);
|
||||
}
|
||||
});
|
||||
Clazz.defineMethod (c$, "getSymbol",
|
||||
function (sym) {
|
||||
if (sym == null) return "Xx";
|
||||
var len = sym.length;
|
||||
if (len < 2) return sym;
|
||||
var ch1 = sym.charAt (1);
|
||||
if (ch1 >= 'a' && ch1 <= 'z') return sym.substring (0, 2);
|
||||
return "" + sym.charAt (0);
|
||||
}, "~S");
|
||||
c$.isValidElementSymbolNoCaseSecondChar = Clazz.defineMethod (c$, "isValidElementSymbolNoCaseSecondChar",
|
||||
function (str) {
|
||||
if (str == null) return false;
|
||||
var length = str.length;
|
||||
if (length == 0) return false;
|
||||
var chFirst = str.charAt (0);
|
||||
if (length == 1) return J.adapter.smarter.Atom.isValidSym1 (chFirst);
|
||||
if (length > 2) return false;
|
||||
var chSecond = str.charAt (1);
|
||||
return J.adapter.smarter.Atom.isValidSymNoCase (chFirst, chSecond);
|
||||
}, "~S");
|
||||
Clazz.defineStatics (c$,
|
||||
"unsupportedRecordTypes", ";ZERR;DISP;UNIT;LAUE;REM;MORE;TIME;HKLF;OMIT;SHEL;BASF;TWIN;EXTI;SWAT;HOPE;MERG;SPEC;RESI;MOVE;ANIS;AFIX;HFIX;FRAG;FEND;EXYZ;EXTI;EADP;EQIV;CONN;PART;BIND;FREE;DFIX;DANG;BUMP;SAME;SADI;CHIV;FLAT;DELU;SIMU;DEFS;ISOR;NCSY;SUMP;L.S.;CGLS;BLOC;DAMP;STIR;WGHT;FVAR;BOND;CONF;MPLA;RTAB;HTAB;LIST;ACTA;SIZE;TEMP;WPDB;FMAP;GRID;PLAN;MOLE;",
|
||||
"supportedRecordTypes", Clazz.newArray (-1, ["TITL", "CELL", "SPGR", "SFAC", "LATT", "SYMM", "NOTE", "ATOM", "END"]));
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.smarter.AtomSetCollectionReader"], "J.adapter.readers.xtal.SiestaReader", ["java.lang.Double"], function () {
|
||||
c$ = Clazz.decorateAsClass (function () {
|
||||
this.noAtoms = 0;
|
||||
this.unitCellData = null;
|
||||
Clazz.instantialize (this, arguments);
|
||||
}, J.adapter.readers.xtal, "SiestaReader", J.adapter.smarter.AtomSetCollectionReader);
|
||||
Clazz.prepareFields (c$, function () {
|
||||
this.unitCellData = Clazz.newFloatArray (9, 0);
|
||||
});
|
||||
Clazz.overrideMethod (c$, "initializeReader",
|
||||
function () {
|
||||
this.doApplySymmetry = true;
|
||||
});
|
||||
Clazz.overrideMethod (c$, "checkLine",
|
||||
function () {
|
||||
if (this.line.contains ("%block LatticeVectors")) {
|
||||
if (this.doGetModel (++this.modelNumber, null)) this.readCellThenAtomsCartesian ();
|
||||
return true;
|
||||
} else if (this.line.contains ("outcoor: Atomic coordinates")) {
|
||||
if (this.doGetModel (++this.modelNumber, null)) this.readAtomsCartGeomThenCell ();
|
||||
return true;
|
||||
}return true;
|
||||
});
|
||||
Clazz.defineMethod (c$, "setCell",
|
||||
function () {
|
||||
this.fillFloatArray (null, 0, this.unitCellData);
|
||||
this.addExplicitLatticeVector (0, this.unitCellData, 0);
|
||||
this.addExplicitLatticeVector (1, this.unitCellData, 3);
|
||||
this.addExplicitLatticeVector (2, this.unitCellData, 6);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readCellThenAtomsCartesian",
|
||||
function () {
|
||||
this.newAtomSet ();
|
||||
this.setCell ();
|
||||
this.discardLinesUntilContains ("AtomicCoordinatesFormat Ang");
|
||||
this.rd ();
|
||||
this.setFractionalCoordinates (false);
|
||||
while (this.rd () != null && this.line.indexOf ("%endblock Atomic") < 0) {
|
||||
var tokens = this.getTokens ();
|
||||
this.addAtomXYZSymName (tokens, 0, null, tokens[4]);
|
||||
}
|
||||
this.noAtoms = this.asc.ac;
|
||||
});
|
||||
Clazz.defineMethod (c$, "newAtomSet",
|
||||
function () {
|
||||
this.applySymmetryAndSetTrajectory ();
|
||||
this.asc.newAtomSet ();
|
||||
this.setSpaceGroupName ("P1");
|
||||
this.setFractionalCoordinates (false);
|
||||
});
|
||||
Clazz.defineMethod (c$, "readAtomsCartGeomThenCell",
|
||||
function () {
|
||||
this.readLines (1);
|
||||
this.newAtomSet ();
|
||||
var atom0 = this.asc.ac;
|
||||
for (var i = 0; i < this.noAtoms; i++) {
|
||||
var tokens = this.getTokens ();
|
||||
var atom = this.asc.addNewAtom ();
|
||||
atom.atomName = tokens[4];
|
||||
var x = this.parseFloatStr (tokens[0]);
|
||||
var y = this.parseFloatStr (tokens[1]);
|
||||
var z = this.parseFloatStr (tokens[2]);
|
||||
atom.set (x, y, z);
|
||||
this.rd ();
|
||||
}
|
||||
this.discardLinesUntilContains ("outcell: Unit cell vectors");
|
||||
this.setCell ();
|
||||
var atoms = this.asc.atoms;
|
||||
var ac = this.asc.ac;
|
||||
for (var i = atom0; i < ac; i++) this.setAtomCoord (atoms[i]);
|
||||
|
||||
this.discardLinesUntilContains ("siesta: E_KS(eV) = ");
|
||||
var tokens = this.getTokens ();
|
||||
var energy = Double.$valueOf (Double.parseDouble (tokens[3]));
|
||||
this.asc.setAtomSetEnergy ("" + energy, energy.floatValue ());
|
||||
this.asc.setCurrentModelInfo ("Energy", energy);
|
||||
this.asc.setInfo ("Energy", energy);
|
||||
this.asc.setAtomSetName ("Energy = " + energy + " eV");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
Clazz.declarePackage ("J.adapter.readers.xtal");
|
||||
Clazz.load (["J.adapter.readers.xtal.VaspPoscarReader"], "J.adapter.readers.xtal.VaspChgcarReader", null, function () {
|
||||
c$ = Clazz.declareType (J.adapter.readers.xtal, "VaspChgcarReader", J.adapter.readers.xtal.VaspPoscarReader);
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user