Examples of CyEdge


Examples of cytoscape.CyEdge

  private void createSpeciesEdgesInNetworkForReaction(CyNetwork net, CyNode reaction){
    int[] inEdgeInds = network.getAdjacentEdgeIndicesArray(reaction.getRootGraphIndex(), false, true, false);
    int[] outEdgeInds = network.getAdjacentEdgeIndicesArray(reaction.getRootGraphIndex(), false, false, true);
    for (int in: inEdgeInds){
      // Get the two edges and end nodes;  n1 --inEdge-> reaction --outEdge-> n2
      CyEdge inEdge  = (CyEdge) network.getEdge(in);
      String inEdgeType = (String) eAtts.getAttribute(inEdge.getIdentifier(), Semantics.INTERACTION);
      CyNode n1 = (CyNode) inEdge.getSource();
     
      for (int out: outEdgeInds){
        CyEdge outEdge = (CyEdge) network.getEdge(out);
        String outEdgeType = (String) eAtts.getAttribute(outEdge.getIdentifier(), Semantics.INTERACTION)
        // only certain combination will be converted to edges in the compound network
        // TODO: better a strict positive list what to take
        if (   inEdgeType.equals(CySBMLConstants.EDGETYPE_REACTION_ACTIVATOR)
          || inEdgeType.equals(CySBMLConstants.EDGETYPE_REACTION_INHIBITOR)
          || inEdgeType.equals(CySBMLConstants.EDGETYPE_REACTION_MODIFIER)){
          // ignore the modifier edges
          continue;
        }
        CyNode n2 = (CyNode) outEdge.getTarget();
       
        // source and target node are in the network, add the respective edge between these nodes
        if (net.containsNode(n1) && net.containsNode(n2)){
          String type = inEdgeType + "2" + outEdgeType;
          CyEdge edge = Cytoscape.getCyEdge(n1, n2, Semantics.INTERACTION, type, true);
         
          // Set reversibility from reaction
          eAtts.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_REVERSIBLE,
              (String) nAtts.getAttribute(reaction.getIdentifier(), CySBMLConstants.ATT_REVERSIBLE));
         
          net.addEdge(edge);
       
      }
View Full Code Here

Examples of cytoscape.CyEdge

  private void createReactionEdgesInNetworkForSpecies(CyNetwork net, CyNode reaction){
    int[] inEdgeInds = network.getAdjacentEdgeIndicesArray(reaction.getRootGraphIndex(), false, true, false);
    int[] outEdgeInds = network.getAdjacentEdgeIndicesArray(reaction.getRootGraphIndex(), false, false, true);
    for (int in: inEdgeInds){
      // Get the two edges and end nodes;  n1 --inEdge-> reaction --outEdge-> n2
      CyEdge inEdge  = (CyEdge) network.getEdge(in);
      String inEdgeType = (String) eAtts.getAttribute(inEdge.getIdentifier(), Semantics.INTERACTION);
      CyNode n1 = (CyNode) inEdge.getSource();
     
      for (int out: outEdgeInds){
        CyEdge outEdge = (CyEdge) network.getEdge(out);
        String outEdgeType = (String) eAtts.getAttribute(outEdge.getIdentifier(), Semantics.INTERACTION);
        // only certain combination will be converted to edges in the compound network
        if (   outEdgeType.equals(CySBMLConstants.EDGETYPE_REACTION_ACTIVATOR)
          || outEdgeType.equals(CySBMLConstants.EDGETYPE_REACTION_INHIBITOR)
          || outEdgeType.equals(CySBMLConstants.EDGETYPE_REACTION_MODIFIER)){
         
          // ignore the modifier edges
          continue;
        }
        CyNode n2 = (CyNode) outEdge.getTarget();
       
        // source and target node are in the network, add the respective edge between these nodes
        if (net.containsNode(n1) && net.containsNode(n2)){
          String type = inEdgeType + "2" + outEdgeType;
          CyEdge edge = Cytoscape.getCyEdge(n1, n2, Semantics.INTERACTION, type, true);
          net.addEdge(edge);
       
      }
    } 
  }
View Full Code Here

Examples of cytoscape.CyEdge

        // if the reaction is not set
        if (!rGlyph.isSetReaction()) {
          for (SpeciesReferenceGlyph sRefGlyph : rGlyph.getListOfSpeciesReferenceGlyphs()) {
            String sGlyphId = sRefGlyph.getSpeciesGlyph();
            CyNode sNode = Cytoscape.getCyNode(sGlyphId, false);
            CyEdge edge = Cytoscape.getCyEdge(rNode, sNode, Semantics.INTERACTION,
                              CySBMLConstants.EDGETYPE_UNDEFINED, true);
            readEdgeAttributesFromSpeciesReferenceGlyph(edge, sRefGlyph);
            edgeIds.add(edge.getRootGraphIndex());
          }
        }

        // if the reaction is set
        if (rGlyph.isSetReaction()) {
          String reactionId = rGlyph.getReaction();
          Reaction reaction = model.getReaction(reactionId);
          if (reaction == null) {
            System.err.println("reactionId in in ReactionGlyph is not in SBML model: " + reactionId);
            continue;
          }
          for (SpeciesReferenceGlyph sRefGlyph : rGlyph.getListOfSpeciesReferenceGlyphs()) {
            String sGlyphId = sRefGlyph.getSpeciesGlyph();
            SpeciesGlyph sGlyph = layout.getSpeciesGlyph(sGlyphId);
           
            String edgeType = getEdgeTypeFromSpeciesReferenceGlyphRole(sRefGlyph);
            // if not found try via SBML model
            if (edgeType.equals(CySBMLConstants.EDGETYPE_UNDEFINED)){
              edgeType = getEdgeTypeFromSBMLModel(reaction, sGlyph);
            }
           
            CyNode sNode = Cytoscape.getCyNode(sGlyphId, false);
            CyEdge edge = Cytoscape.getCyEdge(rNode, sNode, Semantics.INTERACTION, edgeType, true);
           
            // Read additional edge information
            readEdgeAttributesFromSpeciesReferenceGlyph(edge, sRefGlyph);
            edgeIds.add(edge.getRootGraphIndex());
          }
        }
      }
    }
  }
View Full Code Here

Examples of cytoscape.CyEdge

              // if not found try via SBML model
              if (edgeType.equals(CySBMLConstants.EDGETYPE_UNDEFINED)){
                edgeType = getEdgeTypeFromQualModel(transition, sGlyph);
              }
              CyNode sNode = Cytoscape.getCyNode(sGlyphId, false);
              CyEdge edge = Cytoscape.getCyEdge(rNode, sNode, Semantics.INTERACTION, edgeType, true);
       
              // Read additional edge information
              readEdgeAttributesFromSpeciesReferenceGlyph(edge, sRefGlyph);
             
              edgeIds.add(edge.getRootGraphIndex());
            }
          }
        }
      }
    }
View Full Code Here

Examples of cytoscape.CyEdge

  private void addEdgesToGRNForReaction(CyNode reaction){
    int[] inEdgeInds = sbmlNetwork.getAdjacentEdgeIndicesArray(reaction.getRootGraphIndex(), false, true, false);
    int[] outEdgeInds = sbmlNetwork.getAdjacentEdgeIndicesArray(reaction.getRootGraphIndex(), false, false, true);
   
    for (int in: inEdgeInds){
      CyEdge inEdge  = (CyEdge) sbmlNetwork.getEdge(in);
      String inEdgeSBO = (String) eAtts.getAttribute(inEdge.getIdentifier(), CySBMLConstants.ATT_SBOTERM);
      CyNode n1 = (CyNode) inEdge.getSource();
      if (inEdgeSBO == null){
        continue;
      }
      for (int out: outEdgeInds){
        // Get the two edges and end nodes;  n1 --inEdge-> reaction --outEdge-> n2
        CyEdge outEdge = (CyEdge) sbmlNetwork.getEdge(out);
        String outEdgeSBO = (String) eAtts.getAttribute(outEdge.getIdentifier(), CySBMLConstants.ATT_SBOTERM);
        System.out.println("OUT edge: " + outEdge.getIdentifier());
       
        CyNode n2 = (CyNode) outEdge.getTarget();       
        if (outEdgeSBO == null){
          continue;
        }
        // Edges to add
        if (GeneRegulatoryNetwork.productSBOforGRN.contains(outEdgeSBO) &&
          GeneRegulatoryNetwork.modifierSBOforGRN.contains(inEdgeSBO)){
            CyEdge edge = Cytoscape.getCyEdge(n1, n2, Semantics.INTERACTION, inEdgeSBO, true);
            edgeIds.add(edge.getRootGraphIndex());
         
            // Set reversibility from reaction
            eAtts.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, inEdgeSBO);
       
      } 
    }
  } 
View Full Code Here

Examples of cytoscape.CyEdge

      //products
      Double stoichiometry;
      for (SpeciesReference speciesRef : reaction.getListOfProducts()) {
        CyNode product = Cytoscape.getCyNode(speciesRef.getSpecies(), false);
        CyEdge edge = Cytoscape.getCyEdge(node, product, Semantics.INTERACTION,
            CySBMLConstants.EDGETYPE_REACTION_PRODUCT, true);
        if (speciesRef.isSetStoichiometry()){
          stoichiometry = speciesRef.getStoichiometry();
        } else {
          stoichiometry = 1.0;
        }
        edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_STOICHIOMETRY, stoichiometry);
        if (speciesRef.isSetSBOTerm()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, speciesRef.getSBOTermID());
        }
        if (speciesRef.isSetMetaId()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_METAID, speciesRef.getMetaId());
        }
        edgeIds.add(edge.getRootGraphIndex());
      }

      //reactants
      for (SpeciesReference speciesRef : reaction.getListOfReactants()) {
        CyNode reactant = Cytoscape.getCyNode(speciesRef.getSpecies(), false);
        CyEdge edge = Cytoscape.getCyEdge(node, reactant, Semantics.INTERACTION,
            CySBMLConstants.EDGETYPE_REACTION_REACTANT, true);
        if (speciesRef.isSetStoichiometry()){
          stoichiometry = speciesRef.getStoichiometry();
        } else {
          stoichiometry = 1.0;
        }
        edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_STOICHIOMETRY, stoichiometry);
        if (speciesRef.isSetSBOTerm()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, speciesRef.getSBOTermID());
        }
        if (speciesRef.isSetMetaId()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_METAID, speciesRef.getMetaId());
        }
        edgeIds.add(edge.getRootGraphIndex());
      }
     
      //modifier
      for (ModifierSpeciesReference msref : reaction.getListOfModifiers()) {
        CyNode modifier = Cytoscape.getCyNode(msref.getSpecies(), false);
        CyEdge edge = Cytoscape.getCyEdge(modifier, node, Semantics.INTERACTION,
            CySBMLConstants.EDGETYPE_REACTION_MODIFIER, true);
        stoichiometry = 1.0;
        edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_STOICHIOMETRY, stoichiometry);
        if (msref.isSetSBOTerm()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, msref.getSBOTermID());
        }
        if (msref.isSetMetaId()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_METAID, msref.getMetaId());
        }
        edgeIds.add(edge.getRootGraphIndex());
      }
     
      //parse the parameters from the kinetic laws
      //TODO: better handling of the kinetic information
      if (reaction.isSetKineticLaw()){
        KineticLaw law = reaction.getKineticLaw();
        if (law.isSetListOfLocalParameters()){
          for (LocalParameter parameter: law.getListOfLocalParameters()){
            String attName = "kineticLaw-" + parameter.getId();
            String attUnitsName = "kineticLaw-" + parameter.getId() + "-units";
            if (parameter.isSetValue()){
              nodeAttributes.setAttribute(rid, attName, parameter.getValue());
            }
            if (parameter.isSetUnits()){
              nodeAttributes.setAttribute(rid, attUnitsName, parameter.getValue());
            }
          }
        }
      }
    }
   
    ////////////// QUALITATIVE SBML MODEL ////////////////////////////////////////////
    //Must the network be generated again for the qual model ??
     QualitativeModel qModel = (QualitativeModel) model.getExtension(QualConstant.namespaceURI);
     if (qModel != null){
      
     //QualSpecies
     String qsid;
     for (QualitativeSpecies qSpecies : qModel.getListOfQualitativeSpecies()){ 
       qsid = qSpecies.getId();
         CyNode node = Cytoscape.getCyNode(qsid, true);
       nodeAttributes.setAttribute(qsid, CySBMLConstants.ATT_ID, qsid);
       nodeAttributes.setAttribute(qsid, CySBMLConstants.ATT_TYPE, CySBMLConstants.NODETYPE_QUAL_SPECIES);
      
       if (qSpecies.isSetName()){
         nodeAttributes.setAttribute(qsid, CySBMLConstants.ATT_NAME, qSpecies.getName());
       } else {
         nodeAttributes.setAttribute(qsid, CySBMLConstants.ATT_NAME, qsid);
       }
     
       if (qSpecies.isSetInitialLevel()){
         nodeAttributes.setAttribute(qsid,
             CySBMLConstants.ATT_INITIAL_LEVEL, new Integer(qSpecies.getInitialLevel()))
       }
       if (qSpecies.isSetMaxLevel()){
         nodeAttributes.setAttribute(qsid,
             CySBMLConstants.ATT_MAX_LEVEL, new Double(qSpecies.getMaxLevel()))
       }
       if (qSpecies.isSetSBOTerm()){
         nodeAttributes.setAttribute(qsid,
             CySBMLConstants.ATT_SBOTERM, qSpecies.getSBOTermID());
       }
       if (qSpecies.isSetCompartment()){
         nodeAttributes.setAttribute(qsid,
             CySBMLConstants.ATT_COMPARTMENT, qSpecies.getCompartment());
       }
       if (qSpecies.isSetConstant()){
         nodeAttributes.setAttribute(qsid,
             CySBMLConstants.ATT_CONSTANT, new Boolean(qSpecies.getConstant()));
       }
       if (qSpecies.isSetMetaId()){
         nodeAttributes.setAttribute(qsid, CySBMLConstants.ATT_METAID, qSpecies.getMetaId());
       }
       nodeIds.add(node.getRootGraphIndex());
    }
     
    // QualTransitions
    String qtid;
    for (Transition qTransition : qModel.getListOfTransitions()){
      qtid = qTransition.getId();
      CyNode tNode = Cytoscape.getCyNode(qtid, true);
   
      nodeAttributes.setAttribute(qtid, CySBMLConstants.ATT_TYPE, CySBMLConstants.NODETYPE_QUAL_TRANSITION);
      nodeAttributes.setAttribute(qtid, CySBMLConstants.ATT_ID, qtid);
      nodeAttributes.setAttribute(qtid,  CySBMLConstants.ATT_COMPARTMENT, "-");
      if (qTransition.isSetSBOTerm()){
        nodeAttributes.setAttribute(qtid, CySBMLConstants.ATT_SBOTERM, qTransition.getSBOTermID());
      }
      if (qTransition.isSetName()){
        nodeAttributes.setAttribute(qtid, CySBMLConstants.ATT_NAME, qTransition.getName());
      } else {
        nodeAttributes.setAttribute(qtid, CySBMLConstants.ATT_NAME, qtid);
     
      if (qTransition.isSetMetaId()){
        nodeAttributes.setAttribute(qtid,  CySBMLConstants.ATT_METAID, qTransition.getMetaId());
      }
      nodeIds.add(tNode.getRootGraphIndex());
     
      //outputs
      for (Output output : qTransition.getListOfOutputs()) {
        CyNode outNode = Cytoscape.getCyNode(output.getQualitativeSpecies(), false);
        CyEdge edge = Cytoscape.getCyEdge(tNode, outNode, Semantics.INTERACTION,
            CySBMLConstants.EDGETYPE_TRANSITION_OUTPUT, true);
        edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_STOICHIOMETRY, new Double(1.0));
        if (output.isSetSBOTerm()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, output.getSBOTermID());
        }
        if (output.isSetMetaId()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_METAID, output.getMetaId());
        }
        edgeIds.add(edge.getRootGraphIndex());
      }
      //inputs
      for (Input input : qTransition.getListOfInputs()) {
        CyNode inNode = Cytoscape.getCyNode(input.getQualitativeSpecies(), false);
        CyEdge edge = Cytoscape.getCyEdge(tNode, inNode, Semantics.INTERACTION,
            CySBMLConstants.EDGETYPE_TRANSITION_INPUT, true);
        edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_STOICHIOMETRY, new Double(1.0));
        if (input.isSetSBOTerm()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, input.getSBOTermID());
        }
        if (input.isSetMetaId()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_METAID, input.getMetaId());
        }
        edgeIds.add(edge.getRootGraphIndex());
      }
    }
     }
  }
View Full Code Here

Examples of org.cytoscape.model.CyEdge

          });     
          Iterator edges=inputNetwork.getEdgeList().iterator();
          while(edges.hasNext()&&!cancelled){  //for each edge, cal the weight
            weight=0.0;
            int common=0;
            CyEdge e=(CyEdge)edges.next();
            Long nFrom=e.getSource().getSUID();
            Long nTo=e.getTarget().getSUID();
           
            //cal the edge weght
           
            List<CyNode> listneighbors1 = inputNetwork.getNeighborList(inputNetwork.getNode(nFrom), CyEdge.Type.ANY);
            List<CyNode> listneighbors2 = inputNetwork.getNeighborList(inputNetwork.getNode(nTo), CyEdge.Type.ANY);

           
           
            // Get neighborhood of this node (including the node)
/*           
            if (listneighbors1.size() < 2) {
              // If there are no neighbors or just one neighbor, nodeInfo calculation is trivial
              NodeInfo nodeInfo = new NodeInfo();

              if (listneighbors1.size() == 1) {
                nodeInfo.coreLevel = 1;
                nodeInfo.coreDensity = 1.0;
                nodeInfo.density = 1.0;
              }

              return nodeInfo;
            }*/

            Long[] neighbors1 = new Long[listneighbors1.size()];
            int i = 0;

            for (CyNode n : listneighbors1) {
              neighbors1[i++] = n.getSUID();
            }

            // Add original node to extract complete neighborhood
            Arrays.sort(neighbors1);
           
           
//           Long[] neighbors1=getNeighborArray(inputNetwork,nFrom);
//          Long[] neighbors2=getNeighborArray(inputNetwork,nTo);
            Arrays.sort(neighbors1);
            for(int j=0;j<listneighbors2.size();j++){
              Long key=listneighbors2.get(j).getSUID();
              if(Arrays.binarySearch(neighbors1, key)>=0)//exist a common neighbor of both nodes
                common++;
            }
            common++;
            degree1 = inputNetwork.getAdjacentEdgeList(e.getSource(), CyEdge.Type.ANY).size();
            degree2 = inputNetwork.getAdjacentEdgeList(e.getTarget(), CyEdge.Type.ANY).size();

//            degree1=super.getNodeDegree(inputNetwork,e.getSource().getSUID());
//            degree2=getNodeDegree(inputNetwork,e.getTarget().getSUID());
           
           
/*            degree1=inputNetwork.getDegree(e.getSource());
            degree2=inputNetwork.getDegree(e.getTarget());*/
            min=degree1<degree2 ? degree1:degree2;
            weight=(double)(common)/(double)min;
           
            //add to the edge weights map
            if(edgeWeightsMap.containsKey(new Double(weight))) {
              al=(ArrayList)edgeWeightsMap.get(new Double(weight));
              al.add(e.getSUID());
            }else{
              al=new ArrayList();
              al.add(e.getSUID());
              edgeWeightsMap.put(new Double(weight), al);
            }
          }        
          curEdgeWeights=edgeWeightsMap;
          edgeWeightNetworkMap.put(networkID, edgeWeightsMap);
View Full Code Here

Examples of org.cytoscape.model.CyEdge

      Then, Operation UNION:  according to different situation, in which the two nodes consisting
        this arc may belong to different Complexes or an identical Complex and that the
        attributes of the Complexes varies, we take on different action
         ***********************************************************************************************/
        ArrayList alEdgeWithSameWeight; 
        CyEdge curEdge;                                                                                                                         
        for (Iterator iterator = values.iterator(); iterator.hasNext();) {
            //each weight may be associated with multiple edges, iterate over these lists
          alEdgeWithSameWeight = (ArrayList) iterator.next();
            for (int j = 0; j < alEdgeWithSameWeight.size(); j++) {//for each edge
                Long edgeIndex = ((Long) alEdgeWithSameWeight.get(j)).longValue();
                curEdge=inputNetwork.getEdge(edgeIndex);               
            Long inFrom = curEdge.getSource().getSUID();
            Long inTo   = curEdge.getTarget().getSUID();
            NodeInfo fromNI=(NodeInfo)curNodeInfos.get(inFrom)//source node info
            NodeInfo toNI=(NodeInfo)curNodeInfos.get(inTo)//target node info
           
            int icFrom=fromNI.iComplex;  //complex that the source node belongs to
            int icTo=toNI.iComplex;    //complex that the target node belongs to
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.