private static final String ALPHACARBON = "CA";
- private List<String> chainNames = new ArrayList<>();
-
private Hashtable<String, String> chainFile = new Hashtable<>();
/*
}
/**
- * Returns a list of chains mapped in this viewer. Note this list is not
- * currently scoped per structure.
- *
- * @return
- */
- @Override
- public List<String> getChainNames()
- {
- return chainNames;
- }
-
- /**
* Send a 'focus' command to Chimera to recentre the visible display
*/
public void focusView()
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Vector;
{
return;
}
+
+ /*
+ * add the 'All' menu item
+ */
JMenuItem menuItem = new JMenuItem(
MessageManager.getString("label.all"));
menuItem.addActionListener(new ActionListener()
allChainsSelected = false;
}
});
-
chainMenu.add(menuItem);
+ /*
+ * add a menu item for each structure and chain
+ */
+ Collections.sort(chainNames);
+ String lastSeqName = "";
for (String chain : chainNames)
{
- menuItem = new JCheckBoxMenuItem(chain, true);
+ String seqName = getSequenceNameForChain(chain);
+ int nameLength = seqName.length();
+ if (nameLength > 16)
+ {
+ seqName = seqName.substring(0, 8) + "..."
+ + seqName.substring(nameLength - 8, nameLength);
+ }
+ String text = chain;
+ if (!lastSeqName.equals(seqName))
+ {
+ text = text + " " + seqName;
+ }
+ lastSeqName = seqName;
+ menuItem = new JCheckBoxMenuItem(text, true);
menuItem.addItemListener(new ItemListener()
{
@Override
}
/**
+ * Answers the name of the sequence mapped to the given chain (formatted as
+ * pdbId:chainId, e.g. 1A70:A). Answers null if no mapped sequence is found. If
+ * more than one sequence is matched, just answers the name of the first one
+ * found.
+ *
+ * @param chain
+ * @return
+ */
+ private String getSequenceNameForChain(String chain)
+ {
+ String[] tokens = chain.split(":");
+ String pdbId = tokens[0];
+ String chainId = tokens[1];
+ List<StructureMapping> mappings = getBinding().getSsm()
+ .getMappingForChain(pdbId, chainId);
+ return mappings.isEmpty() ? null
+ : mappings.get(0).getSequence().getName();
+ }
+
+ /**
* Action on selecting one of Jalview's registered colour schemes
*/
@Override
}
/**
+ * Answers a (possibly empty) list of structure to sequence mappings matching
+ * the given pdb and chain ids
+ *
+ * @param pdbId
+ * @param chain
+ * @return
+ */
+ public List<StructureMapping> getMappingForChain(String pdbId,
+ String chain)
+ {
+ List<StructureMapping> result = new ArrayList<>();
+ for (StructureMapping sm : mappings)
+ {
+ if (sm.pdbid.equals(pdbId) && sm.pdbchain.equals(chain))
+ {
+ result.add(sm);
+ }
+ }
+ return result;
+ }
+
+ /**
* Returns a readable description of all mappings for the given pdbfile to any
* of the given sequences
*
private boolean hideHiddenRegions;
+ protected List<String> chainNames = new ArrayList<>();
+
/**
* Data bean class to simplify parameterisation in superposeStructures
*/
}
/**
- * Returns a list of chains mapped in this viewer.
- *
- * @return
- */
- public abstract List<String> getChainNames();
-
- /**
* Returns the Jalview panel hosting the structure viewer (if any)
*
* @return
}
return colourMap;
}
+
+ /**
+ * Returns a list of chains mapped in this viewer. Note this list is not
+ * currently scoped per structure.
+ *
+ * @return
+ */
+ public List<String> getChainNames()
+ {
+ return chainNames;
+ }
}