Package org.nexml.model

Examples of org.nexml.model.Subset


           
          // increment from beginning to end. This number is probably either null, for a
          // contiguous range, or perhaps 3 for codon positions
          int tbInc = 1;
          // create the equivalent nexml character set
          Subset nexSubset = xmlMatrix.createSubset(tbCharSet.getLabel());
       
          // assign character objects to the subset. Here we get the full list
          List<org.nexml.model.Character> nexCharacters = xmlMatrix.getCharacters();
     
          // now we iterate over the coordinates and assign the nexml characters to the set
          for ( int i = tbStart; i <= tbStop; i += tbInc ) {
            nexSubset.addThing(nexCharacters.get(i));
          }
        }
      }     
    }
   
View Full Code Here


        if ( null != tbRepeatInterval ) {           
          tbInc = tbRepeatInterval;
        }       
       
        // create the equivalent nexml character set
        Subset xmlSubset = xmlMatrix.createSubset(tbCharSet.getLabel());
     
        // assign character objects to the subset. Here we get the full list
        List<org.nexml.model.Character> xmlCharacters = xmlMatrix.getCharacters();
   
        // now we iterate over the coordinates and assign the nexml characters to the set
        for ( int i = tbStart; i <= tbStop; i += tbInc ) {
          xmlSubset.addThing(xmlCharacters.get(i));
        }
      }
    }
  } 
View Full Code Here

              }
             
              // this is how we create the equivalent nexml character set
              // you will need to update CharSet to get the new implementation of getLabel(), which
              // returns the same value as getTitle()
              Subset nexSubset = nexMatrix.createSubset(tbCharSet.getLabel());
             
              // we have to assign character objects to the subset. Here we get the full list
              List<org.nexml.model.Character> nexCharacters = nexMatrix.getCharacters();
             
              // now we iterate over the coordinates and assign the nexml characters to the set
              for ( int i = start; i <= stop; i += inc ) {
                nexSubset.addThing(nexCharacters.get(i));
              }
            }
          }
        }
      }
View Full Code Here

          if (tbCharSets.isEmpty() != true) {
            // a treebase matrix has zero or more character sets, we must iterate over them
            for ( CharSet tbCharSet : tbCharSets ) {
             
              // this is how we fetch the equivalent nexml character set
              Subset nexSubset = nexMatrix.getSubset(tbCharSet.getLabel());
              Assert.assertNotNull("If NexmlMatrixConverter works correctly, a Subset is returned", nexSubset);             
           
              //get names of TreeBASE and NeXML character set
              String tbCharSetName = tbCharSet.getLabel();
              String nexCharSetName = nexSubset.getLabel();
             
              //verify that the names are the same
              Assert.assertEquals("The NeXML character set must have copied the label of the TreeBASE character set",tbCharSetName,nexCharSetName);             
             
              // the coordinates of the character set are defined by a collection of column ranges that we iterate over
              Collection<ColumnRange> tbColumnRanges = tbCharSet.getColumns(tbCharacterMatrix);
           
              for ( ColumnRange tbColumnRange : tbColumnRanges ) {
             
                // these are the beginning and end of the range
                int tbStart = tbColumnRange.getStartColIndex();
                int tbStop = tbColumnRange.getEndColIndex();
               
                // this is how we increment from beginning to end. This number is probably either null, for a
                // contiguous range, or perhaps 3 for codon positions
                int tbInc = 1;
                 
                // need to do this to prevent nullpointerexceptions
                if ( null != tbColumnRange.getRepeatInterval()) {
                   
                  tbInc = tbColumnRange.getRepeatInterval();
                }
               
                // The NexmlMatrixConverter should have created a Subset for each tbCharSet
                if ( null != nexSubset ) {                                   
               
                  // now we iterate over the coordinates in this column range
                  //and verify whether correct character objects are returned
                  for ( int i = tbStart; i <= tbStop; i += tbInc ) {
                   
                    // get the nexml character that should have been created
                    org.nexml.model.Character nexCharacter = nexCharacters.get(i);
                    Assert.assertNotNull("The NeXML Character should not be null if there as an index into it in this set", nexCharacter);
                    Assert.assertTrue("The Subset should contain the character at index i", nexSubset.containsThing(nexCharacter));
                   
                    //get the treebase character for the index in this column range
                    PhyloChar tbCharacter = tbCharacterMatrix.getCharacter(i);
                    Assert.assertNotNull("The TreeBASE PhyloChar should not be null if there as an index into it in this set", tbCharacter);                   
                    Assert.assertEquals("If the TreeBASE character has a label, then the NeXML character's label should match it", tbCharacter.getLabel(), nexCharacter.getLabel());
View Full Code Here

TOP

Related Classes of org.nexml.model.Subset

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.