示例#1
0
  private void buildProfiles() {
    log.info("Filling repository with profiles");

    List<String> referenceProfile;
    List<String> referenceGeneNames;

    Set<GctReplicate> gctReplicatePairs = repositoryService.getGctReplicatesCombinations();

    int dummyClusteringOrder = gctReplicatePairs.size();
    for (GctReplicate gctReplicate : gctReplicatePairs) {

      GctFile gctFile = gctReplicate.getGctFile();
      ReplicateAnnotation replicateAnnotation = gctReplicate.getReplicateAnnotation();

      List<PeakArea> peakAreas =
          peakAreaRepository.findByGctFileAndReplicateAnnotation(gctFile, replicateAnnotation);

      AssayType assayType = gctFile.getAssayType();

      referenceProfile = getReferenceProfile(assayType);
      referenceGeneNames = getReferenceGeneNames(assayType);

      Double[] profileVector = new Double[referenceProfile.size()];
      boolean[] imputeVector = new boolean[referenceProfile.size()];

      for (PeakArea peakArea : peakAreas) {
        int index = referenceProfile.indexOf(peakArea.getPeptideAnnotation().getPeptideId());
        profileVector[index] = peakArea.getValue();
      }

      UtilsStatistics.imputeProfileVector(profileVector, imputeVector);

      Profile profile =
          new Profile(
              replicateAnnotation,
              gctFile,
              ArrayUtils.toPrimitive(profileVector),
              imputeVector,
              referenceProfile,
              referenceGeneNames,
              dummyClusteringOrder--);

      profileRepository.save(profile);
    }
  }
示例#2
0
  private void loadDataPoints() throws IOException, CommandException {
    log.info("Loading peak areas from panorama gct files");

    List<String> gctDownloadUrls = connectPanorama.gctDownloadUrls(true);

    for (String url : gctDownloadUrls) {

      HashMap<String, List<ParseGCT.AnnotationValue>> metaPeptides = new HashMap<>();
      HashMap<String, List<ParseGCT.AnnotationValue>> metaReplicas = new HashMap<>();
      ArrayList<ParseGCT.PeptideReplicatePeak> peakValues = new ArrayList<>();

      try {
        parser.parseToRepository(url, peakValues, metaPeptides, metaReplicas);
      } catch (Exception e) {

      }

      GctFile gctfile = new GctFile(url);

      int runId = UtilsParse.parseRunId(url);
      String runIdUrl = connectPanorama.getRunIdLink(gctfile);

      gctfile.setRunId(runId);
      gctfile.setRunIdUrl(runIdUrl);

      gctFileRepository.save(gctfile);

      List<String> probeNameIds = new ArrayList<>(metaPeptides.keySet());

      AssayType assayType = UtilsParse.parseArrayTypeFromUrl(url);

      HashMap<String, Integer> peptideIdsForChromatogramsUrl =
          connectPanorama.getPeptideIdsFromJSON(probeNameIds, assayType, runId);

      for (ParseGCT.PeptideReplicatePeak peakFromGct : peakValues) {

        String peptideId = peakFromGct.getPeptideId();
        String replicateId = peakFromGct.getReplicateId();

        PeptideAnnotation peptideAnnotation =
            peptideAnnotationRepository.findFirstByPeptideId(peptideId);
        ReplicateAnnotation replicateAnnotation =
            replicateAnnotationRepository.findFirstByReplicateId(replicateId);

        if (peptideAnnotation == null) {
          log.warn("Peptide annotation is null");
        }

        if (replicateAnnotation == null) {
          log.warn("Replicate annotation is null");
        }

        Double peakAreaValue = peakFromGct.getPeakArea();

        for (ParseGCT.AnnotationValue annotationObject : metaPeptides.get(peptideId)) {
          String annotationName = annotationObject.getAnnotationName();
          String annotationValue = annotationObject.getAnnotationValue();

          if (annotationName.equals("pr_probe_suitability_manual")
              && annotationValue.equals("FALSE")) {
            peakAreaValue = null;
          }
        }

        String chromatogramUrl =
            connectPanorama.getChromatogramUrl(
                assayType, peptideIdsForChromatogramsUrl.get(peptideId), replicateId);

        PeakArea peakArea =
            new PeakArea(
                gctfile, peptideAnnotation, replicateAnnotation, peakAreaValue, chromatogramUrl);

        peakAreaRepository.save(peakArea);
      }
    }
  }