+
+ // open the structure (from same PDB file or given PDBfile)
+ if (m.get(Arg.NOSTRUCTURE) == null
+ || !m.get(Arg.NOQUESTIONNAIRE).getBoolean())
+ {
+ AlignFrame af = afMap.get(id);
+ if (m.get(Arg.STRUCTURE) != null)
+ {
+ STRUCTURE: for (String val : m.get(Arg.STRUCTURE).getValues())
+ {
+ SubId subId = new SubId(val);
+ SequenceI seq = getSpecifiedSequence(af, subId);
+ if (seq == null)
+ {
+ Console.warn("Could not find sequence for argument --"
+ + Arg.STRUCTURE + "=" + val);
+ break STRUCTURE;
+ }
+ File structureFile = null;
+ if (subId.content != null && subId.content.length() != 0)
+ {
+ structureFile = new File(subId.content);
+ Console.debug("Using structure file (from argument) '"
+ + structureFile.getAbsolutePath() + "'");
+ }
+ /* THIS DOESN'T WORK */
+ else if (seq.getAllPDBEntries() != null
+ && seq.getAllPDBEntries().size() > 0)
+ {
+ structureFile = new File(
+ seq.getAllPDBEntries().elementAt(0).getFile());
+ Console.debug("Using structure file (from sequence) '"
+ + structureFile.getAbsolutePath() + "'");
+ }
+
+ if (structureFile == null)
+ {
+ Console.warn("Not provided structure file with '" + val + "'");
+ continue STRUCTURE;
+ }
+
+ if (!structureFile.exists())
+ {
+ Console.warn("Structure file '"
+ + structureFile.getAbsoluteFile() + "' not found.");
+ continue STRUCTURE;
+ }
+
+ Console.debug("Using structure file "
+ + structureFile.getAbsolutePath());
+
+ // open structure view
+ AlignmentPanel ap = af.alignPanel;
+ StructureChooser.openStructureFileForSequence(ap, seq,
+ structureFile);
+ }
+ }
+ }
+ }
+
+ private SequenceI getSpecifiedSequence(AlignFrame af, SubId subId)
+ {
+ SequenceI seq = null;
+ SequenceI[] sequences = af.getCurrentView().getAlignment()
+ .getSequencesArray();
+ if (-1 < subId.index && subId.index < sequences.length)
+ {
+ seq = sequences[subId.index];
+ }
+ else if ("id".equals(subId.keyName))
+ {
+ for (SequenceI s : sequences)
+ {
+ if (s.getDisplayId(false).equals(subId.keyValue))
+ {
+ seq = s;
+ break;
+ }
+ }
+ }
+ return seq;