Example #1
0
  @Override
  protected DefaultMutableTreeNode doInBackground() {

    myNode = new DefaultMutableTreeNode(this.mouseID);
    message("startedLoadingTree", "Doh");
    setMessage("Creating Mouse Tree ...");
    if (0 == "FindAncestors".compareTo(this.function)) {
      ped.FindAncestors(0, this.mouseID, myNode);
      return (myNode);
    } else if (0 == "FindDescendants".compareTo(this.function)) {
      ped.FindDescendants(0, this.mouseID, myNode);
      return (myNode);
    } else return (null);
  }
  private void redirect(String pedigreeFileS, String biparentalStr) {
    Pedigree ped = new Pedigree(pedigreeFileS);
    String[] NAMfamily = ped.getFamilyStartWith(biparentalStr, 100);
    String[][] samples = ped.getSampleOfFamilies(NAMfamily, 100);

    for (int i = 0; i < samples.length; i++) {
      Arrays.sort(samples[i]);
    }
    tbt2anchorRedirect = new int[NAMfamily.length][theTBTs[0].getTaxaNames().length];
    IdGroup anchorIdGroup = theAnchorChrInBits[0].getIdGroup();
    String[] taxaNameAnchor = new String[anchorIdGroup.getIdCount()];
    int[] taxaNameIndexAnchor = new int[anchorIdGroup.getIdCount()];
    int[] familyMark = new int[taxaNameAnchor.length];
    for (int i = 0; i < taxaNameAnchor.length; i++) {
      taxaNameAnchor[i] = anchorIdGroup.getIdentifier(i).getFullName();
      taxaNameIndexAnchor[i] = i;
    }

    for (int i = 0; i < taxaNameAnchor.length - 1; i++) {
      for (int j = i + 1; j < taxaNameAnchor.length; j++) {
        if (taxaNameAnchor[i].compareTo(taxaNameAnchor[j]) > 0) {
          String temp;
          temp = taxaNameAnchor[i];
          taxaNameAnchor[i] = taxaNameAnchor[j];
          taxaNameAnchor[j] = temp;
          int tem;
          tem = taxaNameIndexAnchor[i];
          taxaNameIndexAnchor[i] = taxaNameIndexAnchor[j];
          taxaNameIndexAnchor[j] = tem;
        }
      }
    }

    for (int i = 0; i < taxaNameAnchor.length; i++) {
      familyMark[i] = -1;
      int hit = -1;
      for (int j = 0; j < samples.length; j++) {
        hit = Arrays.binarySearch(samples[j], taxaNameAnchor[i]);
        if (hit >= 0) {
          familyMark[i] = j;
          break;
        }
      }
      // System.out.println(taxaNameAnchor[i]+"\t"+hit);
    }

    for (int i = 0; i < theTBTs[0].getTaxaNames().length; i++) {
      String query = theTBTs[0].getTaxaName(i);

      int hit = Arrays.binarySearch(taxaNameAnchor, query);
      if (hit >= 0 && familyMark[hit] != -1) {
        tbt2anchorRedirect[familyMark[hit]][i] = taxaNameIndexAnchor[hit];
        for (int j = 0; j < tbt2anchorRedirect.length; j++) {
          if (j == familyMark[hit]) continue;
          tbt2anchorRedirect[j][i] = -1;
        }
      } else {
        for (int j = 0; j < tbt2anchorRedirect.length; j++) {
          tbt2anchorRedirect[j][i] = -1;
        }
      }
    }

    family2TBTIndex = new int[tbt2anchorRedirect.length][];
    for (int i = 0; i < tbt2anchorRedirect.length; i++) {
      ArrayList<Integer> temp = new ArrayList();
      for (int j = 0; j < tbt2anchorRedirect[i].length; j++) {
        if (tbt2anchorRedirect[i][j] > -1) temp.add(j);
      }
      family2TBTIndex[i] = new int[temp.size()];
      for (int j = 0; j < family2TBTIndex[i].length; j++) {
        family2TBTIndex[i][j] = temp.get(j);
      }
    }
  }