Package org.gvt.model.basicsif

Examples of org.gvt.model.basicsif.BasicSIFGraph


      genesfile = dialog.getGenefile();
      limit = dialog.getLimit();
      directed = dialog.getDirected();

      SIFReader sifReader = new SIFReader(selectedRuleTypes);
      BasicSIFGraph graph = (BasicSIFGraph) sifReader.readXMLFile(new File(siffile));

      if (graph.getNodes().isEmpty())
      {
        MessageDialog.openInformation(main.getShell(), "Graph empty!",
          "Loaded SIF file does not have any interaction of specified type.");
        return;
      }

      Set<XRef> refs = new HashSet<XRef>();

      // Read in xrefs
      try
      {
        BufferedReader reader = new BufferedReader(new FileReader(genesfile));

        String line;
        while ((line = reader.readLine()) != null)
        {
          if (line.startsWith("#"))
          {
            continue;
          }
          for (String ref : line.split(" "))
          {
            refs.add(new XRef(ref));
          }
        }

        reader.close();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }

      if (refs.isEmpty())
      {
        MessageDialog.openInformation(main.getShell(), "No reference for genes-of-interest!",
          "Genes-of-interest file does not contain any references.");
        return;
      }

      Set<Node> seed = new HashSet<Node>();

      for (Object o : graph.getNodes())
      {
        Node node = (Node) o;

        for (XRef ref : node.getReferences())
        {
          if (refs.contains(ref))
          {
            seed.add(node);
            break;
          }
        }
      }

      if (seed.isEmpty())
      {
        MessageDialog.openInformation(main.getShell(), "No genes-of-interest!",
          "Loaded references do not match any genes in the loaded SIF file.");
        return;
      }
      else
      {
        System.out.println("Nmber of genes of interest = " + seed.size());
      }

      Collection<GraphObject> graphObjects =
        AlgoRunner.searchGraphOfInterest(graph, seed, limit, directed);

      Set<String> rdfseed = new HashSet<String>();
      for (Node node : seed)
      {
        rdfseed.add(((BasicSIFNode)node).getRdfid());
      }

      BasicSIFGraph goi = (BasicSIFGraph) graph.excise(graphObjects, true);
      goi.setName("GOI");

      System.out.println("GOI has " + goi.getNodes().size() + " nodes and " +
        goi.getEdges().size() + " edges.");

      boolean cont = MessageDialog.openConfirm(main.getShell(), "Confirm",
        "GOI has " + goi.getNodes().size() + " nodes and " +
          goi.getEdges().size() + " edges. Layout?");

      if (cont)
      {
        main.createNewTab(goi);

        for (Object o : goi.getNodes())
        {
          BasicSIFNode node = (BasicSIFNode) o;
          if (rdfseed.contains(node.getRdfid()))
          {
            node.setHighlightColor(ChisioMain.higlightColor);
View Full Code Here


      }
    }
    try
    {
      duplicatesExist = false;
      root = new BasicSIFGraph();

      String filename = sifFile.getName();
      root.setName(filename.substring(0, filename.indexOf(".sif")));
     
      root.setAsRoot();
View Full Code Here

  {
    String fileName = null;
    boolean done = false;

    SIFGraph sifGraph = null;
    BasicSIFGraph basicSifGraph = null;

    if (main.getPathwayGraph().getGraphType().equals(BioPAXGraph.SIF))
    {
      sifGraph = (SIFGraph) main.getPathwayGraph();
    }
    else if (main.getPathwayGraph().getGraphType().equals(BioPAXGraph.BASIC_SIF))
    {
      basicSifGraph = (BasicSIFGraph) main.getPathwayGraph();
    }

    if (sifGraph == null && basicSifGraph == null)
    {
      MessageDialog.openError(main.getShell(), "Not A Valid View!",
        "Only Simple Interaction Views can be written in SIF format.");
      return;
    }

    while (!done)
    {
      // Get the user to choose a file name and type to save.
      FileDialog fileChooser = new FileDialog(main.getShell(), SWT.SAVE);

      // Do not let user to overwrite a non-graphml file by default

      String currentFilename = main.getOwlFileName();
      if (!currentFilename.endsWith(".sif"))
      {
        if (currentFilename.indexOf(".") > 0)
        {
          currentFilename = currentFilename.substring(
            0, currentFilename.lastIndexOf("."));
        }
        currentFilename += ".sif";
      }

      fileChooser.setFileName(currentFilename);

      String[] filterExtensions = new String[]{"*.sif"};
      String[] filterNames = new String[]{"Simple Interaction Format (*.sif)"};

      fileChooser.setFilterExtensions(filterExtensions);
      fileChooser.setFilterNames(filterNames);
      fileName = fileChooser.open();

      if (fileName == null)
      {
        // User has cancelled, so quit and return
        done = true;
      }
      else
      {
        // User has selected a file; see if it already exists
        File file = new File(fileName);

        if (file.exists())
        {
          // The file already exists; asks for confirmation
          MessageBox mb = new MessageBox(
            fileChooser.getParent(),
            SWT.ICON_WARNING | SWT.YES | SWT.NO);

          // We really should read this string from a
          // resource bundle
          mb.setMessage(fileName + " already exists. Do you want to replace it?");
          mb.setText("Confirm Replace File");
          // If they click Yes, we're done and we drop out. If
          // they click No, we redisplay the File Dialog
          done = mb.open() == SWT.YES;
        }
        else
        {
          // File does not exist, so drop out
          done = true;
        }
      }
    }

    if (fileName == null)
    {
      isSaved = false;
      return;
    }

    try
    {
      OutputStream os = new FileOutputStream(fileName);

      if (sifGraph != null)
      {
        sifGraph.write(os);
      }
      else if (basicSifGraph != null)
      {
        basicSifGraph.write(os);
      }
    }
    catch (Exception e)
    {
      // e.printStackTrace();
View Full Code Here

      genesfile = dialog.getGenefile();
      limit = dialog.getLimit();
      directed = dialog.getDirected();

      SIFReader sifReader = new SIFReader(selectedRuleTypes);
      BasicSIFGraph graph = (BasicSIFGraph) sifReader.readXMLFile(new File(siffile));

      if (graph.getNodes().isEmpty())
      {
        MessageDialog.openInformation(main.getShell(), "Graph empty!",
          "Loaded SIF file does not have any interaction of specified type.");
        return;
      }

      Set<XRef> refs = new HashSet<XRef>();

      // Read in xrefs
      try
      {
        BufferedReader reader = new BufferedReader(new FileReader(genesfile));

        String line;
        while ((line = reader.readLine()) != null)
        {
          if (line.startsWith("#"))
          {
            continue;
          }
          for (String ref : line.split(" "))
          {
            refs.add(new XRef(ref));
          }
        }

        reader.close();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }

      if (refs.isEmpty())
      {
        MessageDialog.openInformation(main.getShell(), "No reference for genes-of-interest!",
          "Genes-of-interest file does not contain any references.");
        return;
      }

      Set<Node> seed = new HashSet<Node>();

      for (Object o : graph.getNodes())
      {
        Node node = (Node) o;

        for (XRef ref : node.getReferences())
        {
          if (refs.contains(ref))
          {
            seed.add(node);
            break;
          }
        }
      }

      if (seed.isEmpty())
      {
        MessageDialog.openInformation(main.getShell(), "No genes-of-interest!",
          "Loaded references do not match any genes in the loaded SIF file.");
        return;
      }
      else
      {
        System.out.println("Nmber of genes of interest = " + seed.size());
      }

      Collection<GraphObject> graphObjects =
        AlgoRunner.searchGraphOfInterest(graph, seed, limit, directed);

      Set<String> rdfseed = new HashSet<String>();
      for (Node node : seed)
      {
        rdfseed.add(((BasicSIFNode)node).getRdfid());
      }

      BasicSIFGraph goi = (BasicSIFGraph) graph.excise(graphObjects, true);
      goi.setName("GOI");

      System.out.println("GOI has " + goi.getNodes().size() + " nodes and " +
        goi.getEdges().size() + " edges.");

      boolean cont = MessageDialog.openConfirm(main.getShell(), "Confirm",
        "GOI has " + goi.getNodes().size() + " nodes and " +
          goi.getEdges().size() + " edges. Layout?");

      if (cont)
      {
        main.createNewTab(goi);

        for (Object o : goi.getNodes())
        {
          BasicSIFNode node = (BasicSIFNode) o;
          if (rdfseed.contains(node.getRdfid()))
          {
            node.setHighlightColor(ChisioMain.higlightColor);
View Full Code Here

  {
    String fileName = null;
    boolean done = false;

    SIFGraph sifGraph = null;
    BasicSIFGraph basicSifGraph = null;

    if (main.getPathwayGraph().getGraphType().equals(BioPAXGraph.SIF))
    {
      sifGraph = (SIFGraph) main.getPathwayGraph();
    }
    else if (main.getPathwayGraph().getGraphType().equals(BioPAXGraph.BASIC_SIF))
    {
      basicSifGraph = (BasicSIFGraph) main.getPathwayGraph();
    }

    if (sifGraph == null && basicSifGraph == null)
    {
      MessageDialog.openError(main.getShell(), "Not A Valid View!",
        "Only Simple Interaction Views can be written in SIF format.");
      return;
    }

    while (!done)
    {
      // Get the user to choose a file name and type to save.
      FileDialog fileChooser = new FileDialog(main.getShell(), SWT.SAVE);

      // Do not let user to overwrite a non-graphml file by default

      String currentFilename = main.getOwlFileName();
      if (!currentFilename.endsWith(".sif"))
      {
        if (currentFilename.indexOf(".") > 0)
        {
          currentFilename = currentFilename.substring(
            0, currentFilename.lastIndexOf("."));
        }
        currentFilename += ".sif";
      }

      fileChooser.setFileName(currentFilename);

      String[] filterExtensions = new String[]{"*.sif"};
      String[] filterNames = new String[]{"Simple Interaction Format (*.sif)"};

      fileChooser.setFilterExtensions(filterExtensions);
      fileChooser.setFilterNames(filterNames);
      fileName = fileChooser.open();

      if (fileName == null)
      {
        // User has cancelled, so quit and return
        done = true;
      }
      else
      {
        // User has selected a file; see if it already exists
        File file = new File(fileName);

        if (file.exists())
        {
          // The file already exists; asks for confirmation
          MessageBox mb = new MessageBox(
            fileChooser.getParent(),
            SWT.ICON_WARNING | SWT.YES | SWT.NO);

          // We really should read this string from a
          // resource bundle
          mb.setMessage(fileName + " already exists. Do you want to replace it?");
          mb.setText("Confirm Replace File");
          // If they click Yes, we're done and we drop out. If
          // they click No, we redisplay the File Dialog
          done = mb.open() == SWT.YES;
        }
        else
        {
          // File does not exist, so drop out
          done = true;
        }
      }
    }

    if (fileName == null)
    {
      isSaved = false;
      return;
    }

    try
    {
      OutputStream os = new FileOutputStream(fileName);

      if (sifGraph != null)
      {
        sifGraph.write(os);
      }
      else if (basicSifGraph != null)
      {
        basicSifGraph.write(os);
      }
    }
    catch (Exception e)
    {
      // e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.gvt.model.basicsif.BasicSIFGraph

Copyright © 2018 www.massapicom. 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.