コード例 #1
0
  private void initialize() {
    try {
      dataSetManager = new DataSetManager();
      dataSetManager.addDataSetFactory(
          new LuceneDataSetFactory<Object, Object, Object>(
              dataSetManager,
              null,
              new FileUtils(),
              new NullCytoscapeUtils<Object, Object, Object>(),
              null),
          Collections.emptyMap());
      data = dataSetManager.open(DirectorySettings.getGeneManiaDirectory());

      human = getHumanOrganism(data);
      networkUtils = new NetworkUtils();

      cache =
          new DataCache(
              new SynchronizedObjectCache(
                  new MemObjectCache(data.getObjectCache(NullProgressReporter.instance(), false))));
      mania = new Mania2(cache);
      setGeneLimit(DEFAULT_GENE_LIMIT);
      setCombiningMethod(DEFAULT_COMBINING_METHOD);
      setNetworks(new HashSet<String>(Arrays.asList(DEFAULT_NETWORKS)));
    } catch (Exception e) {
      LOG.error(e);
    }
  }
コード例 #2
0
 private RelatedGenesEngineResponseDto runQuery(RelatedGenesEngineRequestDto request)
     throws DataStoreException {
   try {
     request.setProgressReporter(NullProgressReporter.instance());
     RelatedGenesEngineResponseDto result;
     result = mania.findRelated(request);
     request.setCombiningMethod(result.getCombiningMethodApplied());
     networkUtils.normalizeNetworkWeights(result);
     return result;
   } catch (ApplicationException e) {
     Logger logger = Logger.getLogger(getClass());
     logger.error("Unexpected error", e); // $NON-NLS-1$
     return null;
   }
 }
コード例 #3
0
  private EnrichmentEngineRequestDto createEnrichmentRequest(
      RelatedGenesEngineResponseDto response) {
    if (human.getOntology() == null) {
      return null;
    }
    EnrichmentEngineRequestDto request = new EnrichmentEngineRequestDto();
    request.setProgressReporter(NullProgressReporter.instance());
    request.setMinCategories(MIN_CATEGORIES);
    request.setqValueThreshold(Q_VALUE_THRESHOLD);

    request.setOrganismId(human.getId());
    request.setOntologyId(human.getOntology().getId());

    Set<Long> nodes = new HashSet<Long>();
    for (NetworkDto network : response.getNetworks()) {
      for (InteractionDto interaction : network.getInteractions()) {
        nodes.add(interaction.getNodeVO1().getId());
        nodes.add(interaction.getNodeVO2().getId());
      }
    }
    request.setNodes(nodes);
    return request;
  }
コード例 #4
0
  /**
   * add a user-network to data set, then compute a result using BP combining from the core networks
   * *not* including the user network that was just uploaded
   */
  @Test
  public void testBPCombiningWithoutUserNetwork() throws Exception {
    System.out.println("averageCombiningWithUserNetworkChaChaCha");
    int orgId = 1;
    int userNetworkId = -1;
    String userName = "******";

    // add a user network

    //        INetworkSymMatrixProvider provider = new CacheNetworkSymMatrixProvider(userName,
    // orgId, randomCacheBuilder.getCache());
    UserNetworkProcessor instance =
        new UserNetworkProcessor(randomCacheBuilder.getCache(), randomCacheBuilder.getCacheDir());

    UploadNetworkEngineRequestDto uploadRequest = new UploadNetworkEngineRequestDto();
    uploadRequest.setLayout(DataLayout.PROFILE);
    uploadRequest.setMethod(NetworkProcessingMethod.PEARSON);
    uploadRequest.setNamespace(userName);
    uploadRequest.setProgressReporter(NullProgressReporter.instance());
    uploadRequest.setOrganismId(orgId);
    uploadRequest.setNetworkId(userNetworkId);
    uploadRequest.setSparsification(50);

    String data = "id\tf1\tf2\tf3\n10000\t1.5\t3.0\t4.0\n10001\t2.0\t2.2\t2.1\n";
    uploadRequest.setData(new StringReader(data));

    UploadNetworkEngineResponseDto uploadResponse = instance.process(uploadRequest);
    assertNotNull(uploadResponse);

    // now send in a request for related genes, involving all the old networks plus
    // the new one

    IMania mania = new Mania2(randomCacheBuilder.getCache());

    // create request for organism 1
    RelatedGenesEngineRequestDto relatedRequest = new RelatedGenesEngineRequestDto();
    relatedRequest.setNamespace(userName);
    relatedRequest.setOrganismId(orgId);
    relatedRequest.setCombiningMethod(CombiningMethod.BP);
    relatedRequest.setScoringMethod(ScoringMethod.DISCRIMINANT);

    long[] nodeIds = randomCacheBuilder.getCache().getNodeIds(orgId).getNodeIds();

    // first 10 nodes as +ve
    ArrayList<Long> posNodes = new ArrayList<Long>();
    for (int i = 0; i < 10; i++) {
      posNodes.add((long) nodeIds[i]);
    }
    relatedRequest.setPositiveNodes(posNodes);

    // all networks less one
    Collection<Collection<Long>> requestNetworks = new ArrayList<Collection<Long>>();

    ArrayList<Long> group = new ArrayList<Long>();
    for (int i = 0; i < networkIds.length; i++) {
      group.add(networkIds[i]);
    }

    // group.add((long) userNetworkId);

    requestNetworks.add(group);
    relatedRequest.setInteractionNetworks(requestNetworks);
    relatedRequest.setLimitResults(10);
    relatedRequest.setProgressReporter(NullProgressReporter.instance());

    // compute result
    RelatedGenesEngineResponseDto relatedResponse = mania.findRelated(relatedRequest);
    assertNotNull(relatedResponse);
    assertNotNull(relatedResponse.getNetworks());
    assertFalse(relatedResponse.getNetworks().size() == 0);

    System.out.println("num networks in result: " + relatedResponse.getNetworks().size());
    for (NetworkDto n : relatedResponse.getNetworks()) {
      System.out.println(
          "  network id: "
              + n.getId()
              + " weight: "
              + n.getWeight()
              + " num interactions: "
              + n.getInteractions().size());
      for (InteractionDto interaction : n.getInteractions()) {
        /*
        System.out.println(String.format("   inter: node %s %s, node %s %s, %s",
        interaction.getNodeVO1().getId(),
        interaction.getNodeVO1().getScore(),
        interaction.getNodeVO2().getId(),
        interaction.getNodeVO2().getScore(),
        interaction.getWeight()
        ));
         */
      }
    }

    // TODO: send the same request through again, but this time using the old mania api

  }
コード例 #5
0
  /*
   * helper to add a small user network to the test data set, then
   * call a related genes request with given combining method, and
   * other params set to std values
   */
  public RelatedGenesEngineResponseDto regressionHelper(CombiningMethod method) throws Exception {
    int orgId = 1;
    int userNetworkId = -1;
    String userName = "******";

    // add a user network

    //        INetworkSymMatrixProvider provider = new CacheNetworkSymMatrixProvider(userName,
    // orgId, randomCacheBuilder.getCache());
    UserNetworkProcessor instance =
        new UserNetworkProcessor(randomCacheBuilder.getCache(), randomCacheBuilder.getCacheDir());

    UploadNetworkEngineRequestDto uploadRequest = new UploadNetworkEngineRequestDto();
    uploadRequest.setLayout(DataLayout.PROFILE);
    uploadRequest.setMethod(NetworkProcessingMethod.PEARSON);
    uploadRequest.setNamespace(userName);
    uploadRequest.setProgressReporter(NullProgressReporter.instance());
    uploadRequest.setOrganismId(orgId);
    uploadRequest.setNetworkId(userNetworkId);
    uploadRequest.setSparsification(50);

    String data = "id\tf1\tf2\tf3\n10000\t1.5\t3.0\t4.0\n10001\t2.0\t2.2\t2.1\n";
    uploadRequest.setData(new StringReader(data));

    UploadNetworkEngineResponseDto uploadResponse = instance.process(uploadRequest);
    assertNotNull(uploadResponse);

    // now send in a request for related genes, involving all the old networks plus
    // the new one

    IMania mania = new Mania2(randomCacheBuilder.getCache());

    // create request for organism 1
    RelatedGenesEngineRequestDto relatedRequest = new RelatedGenesEngineRequestDto();
    relatedRequest.setNamespace(userName);
    relatedRequest.setOrganismId(orgId);
    relatedRequest.setCombiningMethod(method);
    relatedRequest.setScoringMethod(ScoringMethod.DISCRIMINANT);

    long[] nodeIds = randomCacheBuilder.getCache().getNodeIds(orgId).getNodeIds();

    // first 10 nodes as +ve
    ArrayList<Long> posNodes = new ArrayList<Long>();
    for (int i = 0; i < 10; i++) {
      posNodes.add(nodeIds[i]);
    }
    relatedRequest.setPositiveNodes(posNodes);

    // all networks
    Collection<Collection<Long>> requestNetworks = new ArrayList<Collection<Long>>();

    ArrayList<Long> group = new ArrayList<Long>();
    for (int i = 0; i < networkIds.length; i++) {
      group.add((long) networkIds[i]);
    }

    group.add((long) userNetworkId);

    requestNetworks.add(group);
    relatedRequest.setInteractionNetworks(requestNetworks);
    relatedRequest.setLimitResults(10);
    relatedRequest.setProgressReporter(NullProgressReporter.instance());

    // compute result
    RelatedGenesEngineResponseDto relatedResponse = mania.findRelated(relatedRequest);
    return relatedResponse;
  }