Package mesquite.cont.lib

Examples of mesquite.cont.lib.ContinuousData


  @Override
  public void prepElementBatchInsert(Connection pCon) {

    super.prepElementBatchInsert(pCon);

    ContinuousData continuousData = (ContinuousData) getMesquiteCharacterData();
    // int numCols = continuousData.getNumChars();
    // int numItems = continuousData.getNumItems();

    // Set<String> itemDefNameSet = new HashSet<String>();
    //
View Full Code Here


   * @see org.cipres.treebase.domain.nexus.mesquite.MesquiteMatrixConverter#createMatrix(mesquite.lib.characters.CharacterData)
   */
  @Override
  protected MatrixJDBC createMatrix(CharacterData pMesqMatrix) {

    ContinuousData continuousData = (ContinuousData) pMesqMatrix;
    ContinuousMatrix m = new ContinuousMatrix();
   
    ContinuousMatrixJDBC matrixJDBC = new ContinuousMatrixJDBC(m, continuousData, this);

    int numChars = continuousData.getNumChars();
    int numItems = continuousData.getNumItems();

    mItemDefinitions = new Double2DArray[numItems];
    mItemDefinitionNames = new String[numItems];
   
    Set<ItemDefinition> itemDefs = new HashSet<ItemDefinition>();

    List<MatrixColumnJDBC> columnJDBCs = new ArrayList<MatrixColumnJDBC>();
    List<ItemDefinitionJDBC> itemDefJDBCs = new ArrayList<ItemDefinitionJDBC>();
   
    // add Item definitions if there are any:
    for (int j = 0; j < numItems; j++) {
      Double2DArray anItem = continuousData.getItem(j);

      String itemName = continuousData.getItemName(j);
      mItemDefinitionNames[j] = itemName;
      mItemDefinitions[j] = anItem;
       
      // This can be null, means the default definition 'AVG' is used.
      ItemDefinition definition = getItemDefinition(itemName);
      //ItemDefinitionJDBC itemDefJDBC = new ItemDefinitionJDBC();
      //itemDefJDBC.setColumnIndex(pNewColumnIndex);
      //itemDefJDBC.setItemDefinitionDesc(itemName);
     
      if (definition != null) {
        itemDefs.add(definition);
        getItemDefMap().put(anItem, definition);
      }
    }
   
    if (!itemDefs.isEmpty()) {
      m.setItemDefinitions(itemDefs);
    }

    // add character/column:
    for (int i = 0; i < numChars; i++) {

      //MatrixColumn aColumn = new MatrixColumn();
      MatrixColumnJDBC aColumnJDBC = new MatrixColumnJDBC();
     
      ContinuousChar tbChar = new ContinuousChar();

      String charName = continuousData.getCharacterName(i);
      tbChar.setDescription(charName);

      //aColumn.setCharacter(tbChar);
      aColumnJDBC.setPhyloChar(tbChar);
     
View Full Code Here

   *      int, mesquite.lib.characters.CharacterData)
   */
  @Override
  @Deprecated
  protected void addRowElements(MatrixRow pRow, int pRowIndex, CharacterData pMesqMatrix) {
    ContinuousData continuousData = (ContinuousData) pMesqMatrix;
    int numChars = continuousData.getNumChars();
    int numItems = continuousData.getNumItems();

    List<MatrixColumn> columns = pRow.getMatrix().getColumnsReadOnly();

    // add matrix row elements
    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;
View Full Code Here

    long pColId,
    int pColIndex,
    ContinuousMatrixJDBC pMatrixJDBC,
    List<ContinuousMatrixElementJDBC> pElements) {
   
    ContinuousData continuousData = (ContinuousData) pMatrixJDBC.getMesquiteCharacterData();
    //int numChars = continuousData.getNumChars();
    int numItems = continuousData.getNumItems();

    long[] rowIds = pMatrixJDBC.getRowIDs();
    //String gapSymbol = pMatrixJDBC.getCharacterMatrix().getGapSymbol();
    //String missingSymbol = pMatrixJDBC.getCharacterMatrix().getMissingSymbol();

    //FIXME: worry about symbols string for continuous matrix??

    if (numItems > 1) {
      // multiple item definitions, use single element as a place holder, add an entry
      // to the matrix compoundElement list:
   
      // add elements for the column
      for (int rowIndex = 0; rowIndex < rowIds.length; rowIndex++) {
       
        // place holder:
        ContinuousMatrixElementJDBC element = new ContinuousMatrixElementJDBC();
       
        // the compound element to be added later:
        CompoundElementJDBC compoundElement = new CompoundElementJDBC();
       
        //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 = getItemDefinitions()[j];
          double elementValue = anItem.getValue(pColIndex, rowIndex);

          compoundElement.getValues().add(elementValue);
         
          String itemName = getItemDefinitionNames()[j];

          // This can be null, means the default definition 'AVG' is used.
          Long itemDefId = pMatrixJDBC.getItemDefNameToIDMap().get(itemName);
          if (itemDefId == null) {
            itemDefId = -1L;
          }
          compoundElement.getItemDefinitionIDs().add(itemDefId);
         
   
          compoundValues.append(elementValue);
          if (j < numItems - 1) {
            compoundValues.append(' ');
          }
        }

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

        compoundElement.setColIndex(pColIndex);
        compoundElement.setRowIndex(rowIndex);
        pMatrixJDBC.getCompoundElements().add(compoundElement);
       
        element.setElementOrder(pColIndex);
        element.setMatrixRowID(rowIds[rowIndex]);
        element.setMatrixColID(pColId);
       
        pElements.add(element);
      }
    } else {
      // single item definition, use single element:
     
      // add elements for the column
      for (int rowIndex = 0; rowIndex < rowIds.length; rowIndex++) {
       
        ContinuousMatrixElementJDBC element = new ContinuousMatrixElementJDBC();
       
        if (continuousData.isInapplicable(pColIndex, rowIndex)) {
          // gap:
          element.setGap((short)1);
        } else if (!continuousData.isUnassigned(pColIndex, rowIndex)) {

          double elementValue = continuousData.getState(pColIndex, rowIndex, 0);
          element.setValue(elementValue);         
        }
       
        element.setElementOrder(pColIndex);
        element.setMatrixRowID(rowIds[rowIndex]);
View Full Code Here

TOP

Related Classes of mesquite.cont.lib.ContinuousData

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.