コード例 #1
0
 @Override
 public void addInstance(GKInstance instance) {
   SchemaClass cls = instance.getSchemClass();
   if (!cls.isa(ReactomeJavaConstants.PhysicalEntity) || cls.isa(ReactomeJavaConstants.Complex))
     return; // Only display non-complex PE in this class.
   DefaultMutableTreeNode clsNode = getClassNode(cls);
   DefaultMutableTreeNode instanceNode = new DefaultMutableTreeNode(instance);
   insertInstanceNodeAlphabetically(clsNode, instanceNode);
 }
コード例 #2
0
 /**
  * This method is used to dump all human pathway diagrams into a specified directory.
  *
  * @param dir
  * @throws Exception
  */
 public void dumpHumanPathwayDiagrams(File dir) throws Exception {
   Collection<?> diagrams = adaptor.fetchInstancesByClass(ReactomeJavaConstants.PathwayDiagram);
   SchemaClass cls = adaptor.fetchSchema().getClassByName(ReactomeJavaConstants.PathwayDiagram);
   SchemaAttribute att = cls.getAttribute(ReactomeJavaConstants.representedPathway);
   adaptor.loadInstanceAttributeValues(diagrams, att);
   // Group all human pathways
   for (Iterator<?> it = diagrams.iterator(); it.hasNext(); ) {
     GKInstance diagram = (GKInstance) it.next();
     GKInstance pathway =
         (GKInstance) diagram.getAttributeValue(ReactomeJavaConstants.representedPathway);
     GKInstance species = (GKInstance) pathway.getAttributeValue(ReactomeJavaConstants.species);
     if (species == null) continue;
     if (species.getDBID().equals(48887L)) {
       String fileName = getFileName(pathway);
       File file = new File(dir, fileName);
       convertReactomeToGPML(pathway, file.getAbsolutePath());
     }
   }
 }
コード例 #3
0
 /**
  * A helper method to create a TreeNode and insert it under the root for the specified SchemaClass
  * object.
  *
  * @param cls
  * @return
  */
 private DefaultMutableTreeNode createClassNode(SchemaClass cls) {
   SchemaClass displayedCls = getDisplayedPESubclass(cls);
   DefaultMutableTreeNode clsNode = new DefaultMutableTreeNode(displayedCls);
   // Need to insert to the root
   DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
   DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
   // Find where it should be inserted
   int index = 0;
   if (root.getChildCount() > 0) {
     for (int i = 0; i < root.getChildCount(); i++) {
       DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
       SchemaClass nodeCls = (SchemaClass) node.getUserObject();
       if (nodeCls.getName().compareTo(displayedCls.getName()) > 0) {
         index = i;
         break;
       }
     }
   }
   model.insertNodeInto(clsNode, root, index);
   return clsNode;
 }
コード例 #4
0
 private SchemaClass getDisplayedPESubclass(SchemaClass cls) {
   SchemaClass displayedCls = cls;
   // Only the first level of PE is displayed. Need to map it to one of
   // these subclasses
   XMLFileAdaptor fileAdaptor = PersistenceManager.getManager().getActiveFileAdaptor();
   GKSchemaClass pe =
       (GKSchemaClass)
           fileAdaptor.getSchema().getClassByName(ReactomeJavaConstants.PhysicalEntity);
   for (Iterator it = pe.getSubClasses().iterator(); it.hasNext(); ) {
     GKSchemaClass sub = (GKSchemaClass) it.next();
     if (cls.isa(sub)) {
       displayedCls = sub;
       break;
     }
   }
   return displayedCls;
 }