Package org.cipres.treebase.domain.matrix

Examples of org.cipres.treebase.domain.matrix.MatrixElement


      DiscreteChar columnChar = (DiscreteChar) matrixColumn.getCharacter();

      // convert the mesquite character state to treebase state:
      long statesLong = categoricalData.getState(colIndex, pRowIndex);

      MatrixElement element = null;
      if (categoricalData.isInapplicable(colIndex, pRowIndex)) {
        // gap:
        element = createElement(columnChar, gapSymbolStr, 0, matrix);

      } else if (categoricalData.isUnassigned(colIndex, pRowIndex)) {
        // missing
        element = createElement(columnChar, missingSymbolStr, 0, matrix);

      } else {

        int[] states = CategoricalState.expand(statesLong);

        if (states.length > 1) {
          // multiple states, use compound element:
          CompoundMatrixElement compoundElement = new CompoundMatrixElement();
          Set<DiscreteMatrixElement> elements = new HashSet<DiscreteMatrixElement>();

          // pre calculate the compound values and cache it in compoundElement.
          StringBuilder compoundValues = new StringBuilder();
          compoundValues.append('{');

          for (int i = 0; i < states.length; i++) {
            int aState = states[i];
            String stateName = categoricalData.getStateName(colIndex, aState);

            DiscreteMatrixElement anElement = createElement(
              columnChar,
              stateName,
              i,
              matrix);
            anElement.setColumn(matrixColumn);
            elements.add(anElement);

            anElement.appendValue(compoundValues);

            if (i < states.length - 1) {
              compoundValues.append(' ');
            }
          }

          compoundValues.append('}');
          compoundElement.setCompoundValue(compoundValues.toString());

          compoundElement.setElements(elements);
          element = compoundElement;

        } else {
          // single state, use single element:
          String stateName = categoricalData.getStateName(colIndex, states[0]);
          element = createElement(columnChar, stateName, 0, matrix);
        }
      }

      element.setColumn(matrixColumn);
      pRow.addElement(element);
    }
  }
View Full Code Here


      DiscreteChar columnChar = (DiscreteChar) matrixColumn.getCharacter();

      // convert the mesquite character state to treebase state:
      long statesLong = categoricalData.getState(colIndex, pRowIndex);

      MatrixElement element = null;
      if (categoricalData.isInapplicable(colIndex, pRowIndex)) {
        // gap:
        element = createElement(columnChar, gapSymbolStr, 0, matrix);

      } else if (categoricalData.isUnassigned(colIndex, pRowIndex)) {
        // missing
        element = createElement(columnChar, missingSymbolStr, 0, matrix);

      } else {

        int[] states = CategoricalState.expand(statesLong);

        if (states.length > 1) {
          // multiple states, use compound element:
          CompoundMatrixElement compoundElement = new CompoundMatrixElement();
          Set<DiscreteMatrixElement> elements = new HashSet<DiscreteMatrixElement>();

          // pre calculate the compound values and cache it in compoundElement.
          StringBuilder compoundValues = new StringBuilder();
          compoundValues.append('{');

          for (int i = 0; i < states.length; i++) {
            int aState = states[i];
            String stateName = categoricalData.getStateName(colIndex, aState);

            DiscreteMatrixElement anElement = createElement(
              columnChar,
              stateName,
              i,
              matrix);
            anElement.setColumn(matrixColumn);
            elements.add(anElement);

            anElement.appendValue(compoundValues);

            if (i < states.length - 1) {
              compoundValues.append(' ');
            }
          }

          compoundValues.append('}');
          compoundElement.setCompoundValue(compoundValues.toString());

          compoundElement.setElements(elements);
          element = compoundElement;

        } else {
          // single state, use single element:
          String stateName = categoricalData.getStateName(colIndex, states[0]);
          element = createElement(columnChar, stateName, 0, matrix);
        }
      }

      element.setColumn(matrixColumn);
      pRow.addElement(element);
    }
  }
View Full Code Here

    for (int colIndex = 0; colIndex < numChars; colIndex++) {
      // first find mesquite char and treebase char:
      MatrixColumn matrixColumn = columns.get(colIndex);
      //ContinuousChar columnChar = (ContinuousChar) matrixColumn.getCharacter();

      MatrixElement element = null;

      if (numItems > 1) {

        CompoundMatrixElement compoundElement = new CompoundMatrixElement();
        Set<ContinuousMatrixElement> elements = new HashSet<ContinuousMatrixElement>();

        // pre calculate the compound values and cache it in compoundElement.
        StringBuilder compoundValues = new StringBuilder();
        compoundValues.append('(');

        for (int j = 0; j < numItems; j++) {
          Double2DArray anItem = continuousData.getItem(j);
          double elementValue = anItem.getValue(colIndex, pRowIndex);

          ContinuousMatrixElement anElement = new ContinuousMatrixElement();
          anElement.setValue(elementValue);
          anElement.setColumn(matrixColumn);

          // This can be null, means the default definition 'AVG' is used.
          ItemDefinition definition = getItemDefMap().get(anItem);

          if (definition != null) {
            anElement.setDefinition(definition);
          }

          anElement.appendValue(compoundValues);

          if (j < numItems - 1) {
            compoundValues.append(' ');
          }
        }

        compoundValues.append(')');
        compoundElement.setCompoundValue(compoundValues.toString());

        compoundElement.setElements(elements);
        element = compoundElement;

      } else {
        // single item definition, use single element:
        double elementValue = continuousData.getState(colIndex, pRowIndex, 0);
        ContinuousMatrixElement anElement = new ContinuousMatrixElement();
        anElement.setValue(elementValue);
        anElement.setColumn(matrixColumn);

        element = anElement;
      }
      element.setColumn(matrixColumn);
      pRow.addElement(element);
    }
  }
View Full Code Here

    Iterator<MatrixRow> rows = pCharacterMatrix.getRowsReadOnly().iterator();
    while (rows.hasNext()) {
      Iterator<MatrixElement> elementIter = rows.next().getElementIterator();
      while (elementIter.hasNext()) {
        MatrixElement elem = (MatrixElement) elementIter.next();
        getHibernateTemplate().persist(elem);
      }
    }

  }
View Full Code Here

    List<MatrixElement> aRowElements = new ArrayList<MatrixElement>();

    for (Object result : results) {
      Object[] resultArray = (Object[]) result;

      MatrixElement e = (MatrixElement) resultArray[0];
      Long rowID = (Long) resultArray[1];
      int elementIndex = (Integer) resultArray[2];

      if (isInitial) {
        tmpRowId = rowID;
View Full Code Here

TOP

Related Classes of org.cipres.treebase.domain.matrix.MatrixElement

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.