From: <ha...@us...> - 2006-03-15 13:52:36
|
Revision: 4614 Author: hansonr Date: 2006-03-15 05:52:29 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/jmol/?rev=4614&view=rev Log Message: ----------- (1) generalizes "#jmolscript" in AtomSetCollectionReader (2) moves #jmolscript to proper place (comment, line 3) in MOL files (3) adds checkLineForScript() in REMARK lines of PDB files (4) allows for multi-line concatenation of longer scripts if desired (5) adds comments about MOL file structure from http://nicolas.job.free.fr/ressources/mdl/ctfile.pdf Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/adapter/smarter/MolReader.java trunk/Jmol/src/org/jmol/adapter/smarter/PdbReader.java trunk/Jmol/src/org/jmol/adapter/smarter/XyzReader.java Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2006-03-15 13:31:46 UTC (rev 4613) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2006-03-15 13:52:29 UTC (rev 4614) @@ -315,6 +315,10 @@ atomSetCollectionProperties.put(key, value); } + Object getAtomSetCollectionProperty(String key) { + return atomSetCollectionProperties.get(key); + } + //////////////////////////////////////////////////////////////// // atomSet stuff //////////////////////////////////////////////////////////////// Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2006-03-15 13:31:46 UTC (rev 4613) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2006-03-15 13:52:29 UTC (rev 4614) @@ -377,4 +377,20 @@ elementNumber = 0; return JmolConstants.elementSymbols[elementNumber]; } + + String checkLineForScript(String line){ + int pt = line.indexOf("#jmolscript:"); + if (pt >= 0) { + String script = line.substring(pt + 12, line.length()); + String previousScript = (String) atomSetCollection.getAtomSetCollectionProperty("jmolscript"); + if (previousScript == null) + previousScript = ""; + else + previousScript += ";"; + atomSetCollection.setAtomSetCollectionProperty("jmolscript", previousScript + script); + line = line.substring(0, pt).trim(); + } + return line; + } + } Modified: trunk/Jmol/src/org/jmol/adapter/smarter/MolReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/MolReader.java 2006-03-15 13:31:46 UTC (rev 4613) +++ trunk/Jmol/src/org/jmol/adapter/smarter/MolReader.java 2006-03-15 13:52:29 UTC (rev 4614) @@ -57,23 +57,65 @@ void processMolSdHeader(BufferedReader reader, String firstLine) throws Exception { + /* + * obviously we aren't being this strict, but for the record: + * + * from ctfile.pdf (October 2003): + * + * Line 1: Molecule name. This line is unformatted, but like all + * other lines in a molfile may not extend beyond column 80. + * If no name is available, a blank line must be present. + * Caution: This line must not contain any of the reserved + * tags that identify any of the other CTAB file types + * such as $MDL (RGfile), $$$$ (SDfile record separator), + * $RXN (rxnfile), or $RDFILE (RDfile headers). + * + * Line 2: This line has the format: + * IIPPPPPPPPMMDDYYHHmmddSSssssssssssEEEEEEEEEEEERRRRRR + * (FORTRAN: A2<--A8--><---A10-->A2I2<--F10.5-><---F12.5--><-I6-> ) + * User's first and last initials (l), program name (P), + * date/time (M/D/Y,H:m), dimensional codes (d), scaling factors (S, s), + * energy (E) if modeling program input, internal + * registry number (R) if input through MDL form. A blank line can be + * substituted for line 2. If the internal registry number is more than + * 6 digits long, it is stored in an M REG line (described in Chapter 3). + * + * Line 3: A line for comments. If no comment is entered, a blank line + * must be present. + */ String header = firstLine+"\n"; atomSetCollection.setCollectionName(firstLine); - String name = reader.readLine(); - header += name + "\n"; - int pt = name.indexOf("#jmolscript:"); - if (pt >= 0) { - String script = name.substring(pt + 12, name.length()); - atomSetCollection.setAtomSetCollectionProperty("jmolscript", script); - name = name.substring(0, pt).trim(); - } header += reader.readLine() + "\n"; + //line 3: + String comment = reader.readLine(); + header += comment + "\n"; + checkLineForScript(comment); atomSetCollection.setAtomSetCollectionProperty("fileHeader", header); } void processRgHeader(BufferedReader reader, String firstLine) throws Exception { + /* + * from ctfile.pdf: + * + * $MDL REV 1 date/time + * $MOL + * $HDR + * [Molfile Header Block (see Chapter 4) = name, pgm info, comment] + * $END HDR + * $CTAB + * [Ctab Block (see Chapter 2) = count + atoms + bonds + lists + props] + * $END CTAB + * $RGP + * rrr [where rrr = Rgroup number] + * $CTAB + * [Ctab Block] + * $END CTAB + * $END RGP + * $END MOL + */ + String line; while ((line = reader.readLine()) != null && !line.startsWith("$HDR")) Modified: trunk/Jmol/src/org/jmol/adapter/smarter/PdbReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/PdbReader.java 2006-03-15 13:31:46 UTC (rev 4613) +++ trunk/Jmol/src/org/jmol/adapter/smarter/PdbReader.java 2006-03-15 13:52:29 UTC (rev 4614) @@ -94,6 +94,10 @@ formul(); continue; } + if (line.startsWith("REMARK")) { + checkLineForScript(line); + continue; + } if (line.startsWith("HEADER") && lineLength >= 66) { atomSetCollection.setCollectionName(line.substring(62, 66)); continue; Modified: trunk/Jmol/src/org/jmol/adapter/smarter/XyzReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/XyzReader.java 2006-03-15 13:31:46 UTC (rev 4613) +++ trunk/Jmol/src/org/jmol/adapter/smarter/XyzReader.java 2006-03-15 13:52:29 UTC (rev 4614) @@ -61,18 +61,13 @@ } void readAtomSetName(BufferedReader reader) throws Exception { - String name = reader.readLine().trim(); - if (name.endsWith("#noautobond")) { - name = name.substring(0, name.lastIndexOf('#')).trim(); + String firstline = reader.readLine().trim(); + if (firstline.endsWith("#noautobond")) { + firstline = firstline.substring(0, firstline.lastIndexOf('#')).trim(); atomSetCollection.setAtomSetCollectionProperty("noautobond", "true"); } - int pt = name.indexOf("#jmolscript:"); - if (pt >= 0) { - String script = name.substring(pt + 12, name.length()); - atomSetCollection.setAtomSetCollectionProperty("jmolscript", script); - name = name.substring(0, pt).trim(); - } - atomSetCollection.setAtomSetName(name); + firstline = checkLineForScript(firstline); + atomSetCollection.setAtomSetName(firstline); } final float[] chargeAndOrVector = new float[4]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |