import jalview.datamodel.SequenceI;
import jalview.io.FileParse;
import jalview.io.StructureFile;
-import jalview.structure.StructureImportSettings;
import jalview.util.MessageManager;
import java.io.IOException;
break;
}
if (line.indexOf("ATOM") == 0
- || (StructureImportSettings.isProcessHETATMs()
- && line.indexOf("HETATM") == 0 && !terFlag))
+ || (line.indexOf("HETATM") == 0 && !terFlag))
{
terFlag = false;
StructureImportSettings
.setDefaultPDBFileParser(jalview.bin.Cache.getDefault(
"DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
- StructureImportSettings.setProcessHETATMs(jalview.bin.Cache.getDefault(
- "PROCESS_HETATM", false));
// jnlpVersion will be null if we're using InstallAnywhere
// Dont do this check if running in headless mode
if (jnlpVersion == null
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
private List<Atom> convertSignificantAtoms(ModelSet ms)
{
List<Atom> significantAtoms = new ArrayList<Atom>();
+ HashMap<String, org.jmol.modelset.Atom> chainTerMap = new HashMap<String, org.jmol.modelset.Atom>();
+ org.jmol.modelset.Atom prevAtom = null;
for (org.jmol.modelset.Atom atom : ms.at)
{
- // System.out.println("Seq Id : " + atom.getSeqID());
- // System.out.println("To String : " + atom.toString());
- if (!StructureImportSettings.isProcessHETATMs() && atom.isHetero())
- {
- continue;
- }
if (atom.getAtomName().equalsIgnoreCase("CA")
|| atom.getAtomName().equalsIgnoreCase("P"))
{
+ if (!atomValidated(atom, prevAtom, chainTerMap))
+ {
+ continue;
+ }
Atom curAtom = new Atom(atom.x, atom.y, atom.z);
curAtom.atomIndex = atom.getIndex();
curAtom.chain = atom.getChainIDStr();
curAtom.tfactor = atom.getBfactor100() / 100f;
curAtom.type = 0;
significantAtoms.add(curAtom);
+ prevAtom = atom;
}
}
return significantAtoms;
}
+ private boolean atomValidated(org.jmol.modelset.Atom curAtom,
+ org.jmol.modelset.Atom prevAtom,
+ HashMap<String, org.jmol.modelset.Atom> chainTerMap)
+ {
+ if (chainTerMap == null || prevAtom == null)
+ {
+ return true;
+ }
+ String curAtomChId = curAtom.getChainIDStr();
+ String prevAtomChId = prevAtom.getChainIDStr();
+ // new chain encoutered
+ if (!prevAtomChId.equals(curAtomChId))
+ {
+ // On chain switch add previous chain termination to xTerMap if not exists
+ if (!chainTerMap.containsKey(prevAtomChId))
+ {
+ chainTerMap.put(prevAtomChId, prevAtom);
+ }
+ // if current atom belongs to an already terminated chain and the resNum
+ // diff < 5 then mark as valid and update termination Atom
+ if (chainTerMap.containsKey(curAtomChId))
+ {
+ if ((curAtom.getResno() - chainTerMap.get(curAtomChId).getResno()) < 5)
+ {
+ chainTerMap.put(curAtomChId, curAtom);
+ return true;
+ }
+ return false;
+ }
+ }
+ // atom with previously terminated chain encountered
+ else if (chainTerMap.containsKey(curAtomChId))
+ {
+ if ((curAtom.getResno() - chainTerMap.get(curAtomChId).getResno()) < 5)
+ {
+ chainTerMap.put(curAtomChId, curAtom);
+ return true;
+ }
+ return false;
+ }
+ // HETATM with resNum jump > 2
+ return !(curAtom.isHetero() && ((curAtom.getResno() - prevAtom
+ .getResno()) > 2));
+ }
+
private void createAnnotation(SequenceI sequence, PDBChain chain,
org.jmol.modelset.Atom[] jmolAtoms)
{
private static boolean showSeqFeatures = true;
- private static boolean processHETATMs = false;
-
public static final String JMOL_PARSER = "JMolParser";
public static final String JALVIEW_PARSER = "JalViewParser";
StructureImportSettings.defaultStructureFileFormat = defaultStructureFileFormat;
}
- public static boolean isProcessHETATMs()
- {
- return processHETATMs;
- }
-
- public static void setProcessHETATMs(boolean processHETATMs)
- {
- StructureImportSettings.processHETATMs = processHETATMs;
- }
-
public static String getDefaultPDBFileParser()
{
return defaultPDBFileParser;
@Test(groups = { "Functional" })
public void testFileParser() throws Exception
{
- StructureImportSettings.setProcessHETATMs(false);
for (String pdbStr : testFile)
{
PDBfile mctest = new PDBfile(false, false, false, pdbStr,
validateSecStrRows(al);
}
}
- StructureImportSettings.setProcessHETATMs(true);
- for (String pdbStr : testFile)
- {
- PDBfile mctest = new PDBfile(false, false, false, pdbStr,
- AppletFormatAdapter.FILE);
- JmolParser jtest = new JmolParser(false, false, false, pdbStr,
- jalview.io.AppletFormatAdapter.FILE);
- Vector<SequenceI> seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs();
- assertTrue(
- "No sequences extracted from testfile\n"
- + (jtest.hasWarningMessage() ? jtest.getWarningMessage()
- : "(No warnings raised)"), seqs != null
- && seqs.size() > 0);
- for (SequenceI sq : seqs)
- {
- assertEquals("JMol didn't process " + pdbStr
- + " to the same sequence as MCView",
- sq.getSequenceAsString(), mcseqs.remove(0)
- .getSequenceAsString());
- AlignmentI al = new Alignment(new SequenceI[] { sq });
- validateSecStrRows(al);
- }
- }
}
private void validateSecStrRows(AlignmentI al)