}
/*
- * the following call should not be needed but is temporarily included,
- * to avoid a stack trace error in Chimera after "stop really" is sent
+ * the following call is added to avoid a stack trace error in Chimera
+ * after "stop really" is sent; Chimera > 1.14 will not need it; see also
+ * http://plato.cgl.ucsf.edu/trac/chimera/ticket/17597
*/
- if (closeChimera)
+ if (closeChimera && (getViewerType() == ViewerType.CHIMERA))
{
chimeraManager.getChimeraProcess().destroy();
}
}
/**
- * Get Chimera residues which have the named attribute, find the mapped
- * positions in the Jalview sequence(s), and set as sequence features
- *
- * @param attName
- * @param alignmentPanel
- */
- public void copyStructureAttributesToFeatures(String attName,
- AlignmentViewPanel alignmentPanel)
- {
- // todo pull up to AAStructureBindingModel (and interface?)
-
- /*
- * ask Chimera to list residues with the attribute, reporting its value
- */
- // this alternative command
- // list residues spec ':*/attName' attr attName
- // doesn't report 'None' values (which is good), but
- // fails for 'average.bfactor' (which is bad):
-
- String cmd = "list residues attr '" + attName + "'";
- List<String> residues = executeCommand(new StructureCommand(cmd), true);
-
- boolean featureAdded = createFeaturesForAttributes(attName, residues);
- if (featureAdded)
- {
- alignmentPanel.getFeatureRenderer().featuresAdded();
- }
- }
-
- /**
* Create features in Jalview for the given attribute name and structure
* residues.
*
*
* @param attName
* @param residues
- * @return
+ * @return the number of features added
*/
- protected boolean createFeaturesForAttributes(String attName,
+ protected int createFeaturesForAttributes(String attName,
List<String> residues)
{
- boolean featureAdded = false;
+ int featuresAdded = 0;
String featureGroup = getViewerFeatureGroup();
for (String residue : residues)
spec = parseAtomSpec(atomSpec);
} catch (IllegalArgumentException e)
{
- System.err.println("Problem parsing atomspec " + atomSpec);
+ Cache.log.error("Problem parsing atomspec " + atomSpec);
continue;
}
start, end, score, featureGroup);
// todo: should SequenceFeature have an explicit property for chain?
// note: repeating the action shouldn't duplicate features
- featureAdded |= seq.addSequenceFeature(sf);
+ if (seq.addSequenceFeature(sf))
+ {
+ featuresAdded++;
+ }
}
}
- return featureAdded;
+ return featuresAdded;
}
/**
*/
public List<String> getChimeraAttributes()
{
- List<String> atts = chimeraManager.getAttrList();
- Iterator<String> it = atts.iterator();
- while (it.hasNext())
+ List<String> attributes = new ArrayList<>();
+ StructureCommandI command = getCommandGenerator().listResidueAttributes();
+ final List<String> reply = executeCommand(command, true);
+ if (reply != null)
{
- if (it.next().startsWith(ChimeraCommands.NAMESPACE_PREFIX))
+ for (String inputLine : reply)
{
- /*
- * attribute added from Jalview - exclude it
- */
- it.remove();
+ String[] lineParts = inputLine.split("\\s");
+ if (lineParts.length == 2 && lineParts[0].equals("resattr"))
+ {
+ String attName = lineParts[1];
+ /*
+ * exclude attributes added from Jalview
+ */
+ if (!attName.startsWith(ChimeraCommands.NAMESPACE_PREFIX))
+ {
+ attributes.add(attName);
+ }
+ }
}
}
- return atts;
+ return attributes;
}
/**