- // TODO: consider bailing if nmatched less than 4 because superposition
- // not
- // well defined.
- // TODO: refactor superposable position search (above) from jmol selection
- // construction (below)
-
- String[] selcom = new String[files.length];
- int nmatched = 0;
- String sep = "";
- // generate select statements to select regions to superimpose structures
- {
- for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
- {
- String chainCd = targetC[pdbfnum];
- int lpos = -1;
- boolean run = false;
- StringBuffer molsel = new StringBuffer();
- for (int r = 0; r < matched.length; r++)
- {
- if (matched[r])
- {
- if (pdbfnum == 0)
- {
- nmatched++;
- }
- if (lpos != commonrpositions[pdbfnum][r] - 1)
- {
- // discontinuity
- if (lpos != -1)
- {
- molsel.append((run ? "" : ":") + lpos);
- molsel.append(chainCd);
- molsel.append(",");
- }
- }
- else
- {
- // continuous run - and lpos >-1
- if (!run)
- {
- // at the beginning, so add dash
- molsel.append(":" + lpos);
- molsel.append("-");
- }
- run = true;
- }
- lpos = commonrpositions[pdbfnum][r];
- // molsel.append(lpos);
- }
- }
- // add final selection phrase
- if (lpos != -1)
- {
- molsel.append((run ? "" : ":") + lpos);
- molsel.append(chainCd);
- // molsel.append("");
- }
- if (molsel.length() > 1)
- {
- selcom[pdbfnum] = molsel.toString();
- selectioncom.append("#" + pdbfnum);
- selectioncom.append(selcom[pdbfnum]);
- selectioncom.append(" ");
- if (pdbfnum < files.length - 1)
- {
- selectioncom.append("| ");
- }
- }
- else
- {
- selcom[pdbfnum] = null;
- }
- }
- }
- StringBuilder command = new StringBuilder(256);
- for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
- {
- if (pdbfnum == refStructure || selcom[pdbfnum] == null
- || selcom[refStructure] == null)
- {
- continue;
- }
- if (command.length() > 0)
- {
- command.append(";");
- }
-
- /*
- * Form Chimera match command, from the 'new' structure to the
- * 'reference' structure e.g. (residues 1-91, chain B/A, alphacarbons):
- *
- * match #1:1-91.B@CA #0:1-91.A@CA
- *
- * @see
- * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
- */
- command.append("match #" + pdbfnum /* +".1" */);
- // TODO: handle sub-models
- command.append(selcom[pdbfnum]);
- command.append("@" + atomSpec[pdbfnum]);
- command.append(" #" + refStructure /* +".1" */);
- command.append(selcom[refStructure]);
- command.append("@" + atomSpec[refStructure]);
- }
- if (selectioncom.length() > 0)
- {
- // TODO remove debug output
- System.out.println("Select regions:\n" + selectioncom.toString());
- System.out
- .println("Superimpose command(s):\n" + command.toString());
- allComs.append("~display all; chain @CA|P; ribbon "
- + selectioncom.toString() + ";"+command.toString());
- // selcom.append("; ribbons; ");
- }
- }
- if (selectioncom.length() > 0)
- {// finally, mark all regions that were superposed.
- if (selectioncom.substring(selectioncom.length() - 1).equals("|"))
- {
- selectioncom.setLength(selectioncom.length() - 1);
- }
- System.out.println("Select regions:\n" + selectioncom.toString());
- allComs.append("; ~display all; chain @CA|P; ribbon "
- + selectioncom.toString() + "; focus");
- // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString());
- evalStateCommand(allComs.toString(), true /* false */);
- }
-
- }
-
- private void checkLaunched()
- {
- if (!viewer.isChimeraLaunched())