Examples of KamNode


Examples of org.openbel.framework.api.Kam.KamNode

                new LinkedHashMap<Integer, Set<Integer>>();
        Map<KamNode, KamNode> onodes = new HashMap<KamNode, KamNode>();
        for (final KamEdge e : edges) {
            // only evaluate orthologous edges
            if (ORTHOLOGOUS.equals(e.getRelationshipType())) {
                final KamNode edgeSource = e.getSourceNode();
                final KamNode edgeTarget = e.getTargetNode();

                // invalid; skip orthologous self edges
                if (edgeSource == edgeTarget) {
                    continue;
                }

                TermParameter speciesParam = findParameter(kam, kAMStore,
                        edgeSource, rlocs);
                if (speciesParam != null) {
                    // source node matches target species
                    Integer id = edgeSource.getId();
                    Set<Integer> adjacentEdges = oedges.get(id);
                    if (adjacentEdges == null) {
                        adjacentEdges = new LinkedHashSet<Integer>();
                        oedges.put(id, adjacentEdges);
                    }

                    // collect adjacent edges (except this edge) for the
                    // orthologous target node
                    final Set<KamEdge> orthoEdges = kam.getAdjacentEdges(edgeTarget);
                    for (final KamEdge orthoEdge : orthoEdges) {
                        if (orthoEdge != e) {
                            adjacentEdges.add(orthoEdge.getId());
                        }
                    }

                    onodes.put(edgeTarget, edgeSource);
                    continue;
                }

                speciesParam = findParameter(kam, kAMStore, edgeTarget, rlocs);
                if (speciesParam != null) {
                    // target node matches target species
                    Integer id = edgeTarget.getId();
                    Set<Integer> adjacentEdges = oedges.get(id);
                    if (adjacentEdges == null) {
                        adjacentEdges = new LinkedHashSet<Integer>();
                        oedges.put(id, adjacentEdges);
                    }
View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

            if (ORTHOLOGOUS.equals(edge.getRelationshipType())) {
                // remove all orthologous edges
                kam.removeEdge(edge);
            } else {
                // redirect ortholog's relationships to species replacement
                final KamNode sn = edge.getSourceNode();
                final KamNode tn = edge.getTargetNode();

                // when edge's source node is the orthologous node
                // find the corresponding species
                KamNode species = ortho.get(sn);
                if (species != null) {
                    // replace the edge's source as the species node
                    KamNode speciesNode = kam.findNode(species.getId());
                    kam.removeEdge(edge);
                    kam.createEdge(edge.getId(), speciesNode,
                            edge.getRelationshipType(), tn);
                    continue;
                }

                // when edge's target node is the orthologous node
                // find the corresponding species
                species = ortho.get(tn);
                if (species != null) {
                    // replace the edge's target as the species node
                    KamNode speciesNode = kam.findNode(species.getId());
                    kam.removeEdge(edge);
                    kam.createEdge(edge.getId(), sn,
                            edge.getRelationshipType(), speciesNode);
                    continue;
                }
View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

                new HashMap<FunctionEnum, KamNode>();
        final Map<RelationshipType, KamNode> rels =
                new HashMap<RelationshipType, Kam.KamNode>();
        for (final KamEdge e : out) {
            // get correct edge opposite node based on search direction
            final KamNode opnode = (direction == FORWARD ? e.getTargetNode()
                    : e.getSourceNode());

            // handle ACTS_IN edge independently since we care about similar
            // activity functions
            if (e.getRelationshipType() == ACTS_IN) {
                final FunctionEnum actfun = opnode.getFunctionType();

                // lookup first seen node for activity function
                KamNode node = acts.get(actfun);

                // if not yet seen mark opposite node and edge as species collapse
                // target.  continue to next edge.
                if (node == null) {
                    acts.put(opnode.getFunctionType(), opnode);
                    ntp.put(opnode.getId(), param);
                    etp.put(e.getId(), param);
                    continue;
                }

                kam.collapseNode(opnode, node);

                // hang on to collapsed node
                ortho.put(opnode, node);
            } else {
                // handle all other edges by relationship type
                final RelationshipType rel = e.getRelationshipType();

                // lookup first seen relationship type
                KamNode node = rels.get(rel);

                // if not yet seen mark opposite node and edge as species collapse
                // target.  continue to next edge.
                if (node == null) {
                    rels.put(rel, opnode);
View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

        // Figure out which nodes we want to create. We only create ones which are attached to edges
        // and as edges might have been filtered, we need to weed out those nodes which are no longer
        // connected
        for (KamProtoEdge kamProtoEdge : kamProtoEdges) {
            KamNode sourceNode = findNode(kamProtoEdge.getSourceNode().getId());
            if (null == sourceNode) {
                throw new InvalidArgument("Can't find source node.");
                //sourceNode = createNode(kamProtoEdge.getSourceNode().getId(), kamProtoEdge.getSourceNode().getFunctionType(), kamProtoEdge.getSourceNode().getLabel());
            }
            KamNode targetNode = findNode(kamProtoEdge.getTargetNode().getId());
            if (null == targetNode) {
                throw new InvalidArgument("Can't find target node.");
                //targetNode = createNode(kamProtoEdge.getTargetNode().getId(), kamProtoEdge.getTargetNode().getFunctionType(), kamProtoEdge.getTargetNode().getLabel());
            }
            createEdge(kamProtoEdge.getId(), sourceNode,
View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

    /**
     * {@inheritDoc}
     */
    @Override
    public KamNode findNode(Integer kamNodeId, NodeFilter filter) {
        final KamNode kamNode = idNodeMap.get(kamNodeId);

        if (kamNode == null) {
            return null;
        }

View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

            EdgeDirectionType edgeDirection, EdgeFilter edgeFilter,
            NodeFilter nodeFilter) {

        Set<KamNode> adjacentNodes = new LinkedHashSet<KamNode>();

        KamNode node = null;
        if (EdgeDirectionType.FORWARD == edgeDirection
                || EdgeDirectionType.BOTH == edgeDirection) {
            final Set<KamEdge> sources = nodeSourceMap.get(kamNode);
            if (hasItems(sources)) {
                for (KamEdge kamEdge : sources) {
View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

            RelationshipType relationship, FunctionEnum targetFunction,
            String targetLabel) {

        // replace source node
        final int sourceNodeId = kamEdge.getSourceNode().getId();
        final KamNode sourceReplacement =
                new KamNodeImpl(this, sourceNodeId, sourceFunction, sourceLabel);

        // establish id to replacement node
        idNodeMap.put(sourceNodeId, sourceReplacement);
        nodeIdMap.put(sourceReplacement, sourceNodeId);

        //replace target node
        final int targetNodeId = kamEdge.getTargetNode().getId();
        final KamNode targetReplacement =
                new KamNodeImpl(this, targetNodeId, targetFunction, targetLabel);

        // establish id to replacement node
        idNodeMap.put(targetNodeId, targetReplacement);
        nodeIdMap.put(targetReplacement, targetNodeId);
View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

    @Override
    public KamNode createNode(Integer id, FunctionEnum functionType,
            String label) throws InvalidArgument {

        // See if the node already exists
        KamNode kamNode = findNode(id);

        if (null == kamNode) {
            kamNode = new KamNodeImpl(this, id, functionType, label);
            // add this node into the graph
            addNode(kamNode);
View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

     * {@inheritDoc}
     */
    @Override
    public KamNode replaceNode(KamNode kamNode, FunctionEnum function, String label) {
        final int nodeId = kamNode.getId();
        final KamNode replacement = new KamNodeImpl(this, nodeId, function, label);
        return replaceNode(kamNode, replacement);
    }
View Full Code Here

Examples of org.openbel.framework.api.Kam.KamNode

                return false;
            }
            if (!KamNode.class.isAssignableFrom(obj.getClass())) {
                return false;
            }
            KamNode other = (KamNode) obj;
            if (!getKam().equals(other.getKam())) {
                return false;
            }
            if (getId() == null) {
                if (other.getId() != null) {
                    return false;
                }
            } else if (!getId().equals(other.getId())) {
                return false;
            }
            return true;
        }
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.