- StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);
- // RACE CONDITION - getMapping only returns Jmol loaded filenames once
- // Jmol callback has completed.
- if (mapping == null || mapping.length < 1)
- {
- throw new Error(
- "Implementation error - Jmol seems to be still working on getting its data - report at http://issues.jalview.org/browse/JAL-1016");
- }
- int lastPos = -1;
- for (int s = 0; s < sequence[pdbfnum].length; s++)
- {
- for (int sp, m = 0; m < mapping.length; m++)
- {
- if (mapping[m].getSequence() == sequence[pdbfnum][s]
- && (sp = alignment.findIndex(sequence[pdbfnum][s])) > -1)
- {
- if (refStructure == -1)
- {
- refStructure = pdbfnum;
- }
- SequenceI asp = alignment.getSequenceAt(sp);
- for (int r = 0; r < matched.length; r++)
- {
- if (!matched[r])
- {
- continue;
- }
- matched[r] = false; // assume this is not a good site
- if (r >= asp.getLength())
- {
- continue;
- }
-
- if (jalview.util.Comparison.isGap(asp.getCharAt(r)))
- {
- // no mapping to gaps in sequence
- continue;
- }
- int t = asp.findPosition(r); // sequence position
- int apos = mapping[m].getAtomNum(t);
- int pos = mapping[m].getPDBResNum(t);
-
- if (pos < 1 || pos == lastPos)
- {
- // can't align unmapped sequence
- continue;
- }
- matched[r] = true; // this is a good ite
- lastPos = pos;
- // just record this residue position
- commonrpositions[pdbfnum][r] = pos;
- }
- // create model selection suffix
- isel[pdbfnum] = "/" + (pdbfnum + 1) + ".1";
- if (mapping[m].getChain() == null
- || mapping[m].getChain().trim().length() == 0)
- {
- targetC[pdbfnum] = "";
- }
- else
- {
- targetC[pdbfnum] = ":" + mapping[m].getChain();
- }
- chainNames[pdbfnum] = mapping[m].getPdbId()
- + targetC[pdbfnum];
- // move on to next pdb file
- s = sequence[pdbfnum].length;
- break;
- }
- }
- }