- int nmatched = 0;
- for (boolean b : matched)
- {
- if (b)
- {
- nmatched++;
- }
- }
- if (nmatched < 4)
- {
- // TODO: bail out here because superposition illdefined?
- }
-
- /*
- * Generate select statements to select regions to superimpose structures
- */
- String[] selcom = new String[files.length];
- for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
- {
- String chainCd = "." + structures[pdbfnum].chain;
- int lpos = -1;
- boolean run = false;
- StringBuilder molsel = new StringBuilder();
- for (int r = 0; r < matched.length; r++)
- {
- if (matched[r])
- {
- int pdbResNum = structures[pdbfnum].pdbResNo[r];
- if (lpos != pdbResNum - 1)
- {
- /*
- * discontiguous - append last residue now
- */
- if (lpos != -1)
- {
- molsel.append(String.valueOf(lpos));
- molsel.append(chainCd);
- molsel.append(",");
- }
- run = false;
- }
- else
- {
- /*
- * extending a contiguous run
- */
- if (!run)
- {
- /*
- * start the range selection
- */
- molsel.append(String.valueOf(lpos));
- molsel.append("-");
- }
- run = true;
- }
- lpos = pdbResNum;
- }
- }
-
- /*
- * and terminate final selection
- */
- if (lpos != -1)
- {
- molsel.append(String.valueOf(lpos));
- molsel.append(chainCd);
- }
- if (molsel.length() > 1)
- {
- selcom[pdbfnum] = molsel.toString();
- selectioncom.append("#").append(String.valueOf(pdbfnum))
- .append(":");
- 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. (50 residues, chain B/A, alphacarbons):
- *
- * match #1:1-30.B,81-100.B@CA #0:21-40.A,61-90.A@CA
- *
- * @see
- * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
- */
- command.append("match ").append(getModelSpec(pdbfnum)).append(":");
- command.append(selcom[pdbfnum]);
- command.append("@").append(
- structures[pdbfnum].isRna ? PHOSPHORUS : ALPHACARBON);
- // JAL-1757 exclude alternate CA locations
- command.append(NO_ALTLOCS);
- command.append(" ").append(getModelSpec(refStructure)).append(":");
- command.append(selcom[refStructure]);
- command.append("@").append(
- structures[refStructure].isRna ? PHOSPHORUS : ALPHACARBON);
- command.append(NO_ALTLOCS);
- }
- if (selectioncom.length() > 0)
- {
- if (debug)
- {
- 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 ")
- .append(selectioncom.toString())
- .append(";" + command.toString());
- }
- }
- if (selectioncom.length() > 0)