Examples of KeyValueTuple


Examples of org.molgenis.util.tuple.KeyValueTuple

    { "fam", "ind", "fa", "mo", "sex", "phen" };
  }

  public static Tuple famToTuple(FamEntry fam)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("fam", fam.getFamily());
    tuple.set("ind", fam.getIndividual());
    tuple.set("fa", fam.getFather());
    tuple.set("mo", fam.getMother());
    tuple.set("sex", fam.getSex());
    tuple.set("phen", fam.getPhenotype());
    return tuple;
  }
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

    { "fam", "ind", "fa", "mo", "sex", "phen", "bial" };
  }

  public static Tuple pedToTuple(PedEntry ped)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("fam", ped.getFamily());
    tuple.set("ind", ped.getIndividual());
    tuple.set("fa", ped.getFather());
    tuple.set("mo", ped.getMother());
    tuple.set("sex", ped.getSex());
    tuple.set("phen", ped.getPhenotype());
    tuple.set("bial", ped.getBialleles());
    return tuple;
  }
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

    { "chr", "snp", "cm", "bp", "al1", "al2" };
  }

  public static Tuple bimToTuple(BimEntry bim)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("chr", bim.getChromosome());
    tuple.set("snp", bim.getSNP());
    tuple.set("cm", bim.getcM());
    tuple.set("bp", bim.getBpPos());
    tuple.set("al1", bim.getBiallele().getAllele1());
    tuple.set("al2", bim.getBiallele().getAllele2());
    return tuple;
  }
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

    { "chr", "snp", "cm", "bp" };
  }

  public static Tuple mapToTuple(MapEntry map)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("chr", map.getChromosome());
    tuple.set("snp", map.getSNP());
    tuple.set("cm", map.getcM());
    tuple.set("bp", map.getBpPos());
    return tuple;
  }
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

    { "chr", "snp", "cm", "bp", "bial" };
  }

  public static Tuple tpedToTuple(TpedEntry tped)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("chr", tped.getChromosome());
    tuple.set("snp", tped.getSNP());
    tuple.set("cm", tped.getcM());
    tuple.set("bp", tped.getBpPos());
    tuple.set("bial", tped.getBialleles());
    return tuple;
  }
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

  @Test
  public void addCellProcessor() throws IOException
  {
    CellProcessor processor = when(mock(CellProcessor.class).processHeader()).thenReturn(true).getMock();

    KeyValueTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1");
    row1.set("col2", "val2");

    excelSheetWriter.addCellProcessor(processor);
    excelSheetWriter.writeColNames(Arrays.asList("col1", "col2"));
    excelSheetWriter.write(row1);
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

  }

  @Test
  public void writeColNames() throws IOException
  {
    KeyValueTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1");
    row1.set("col2", "val2");
    KeyValueTuple row2 = new KeyValueTuple();
    row2.set("col1", "val3");
    row2.set("col2", "val4");

    excelSheetWriter.writeColNames(Arrays.asList("col1", "col2"));
    excelSheetWriter.write(row1);
    excelSheetWriter.write(row2);
    excelWriter.close();
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

    TupleTable tableModel = mock(TupleTable.class);
    Field field1 = when(mock(Field.class).getName()).thenReturn("col1").getMock();
    Field field2 = when(mock(Field.class).getName()).thenReturn("col2").getMock();
    Field field3 = when(mock(Field.class).getName()).thenReturn("col3").getMock();
    when(tableModel.getColumns()).thenReturn(Arrays.asList(field1, field2, field3));
    WritableTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1.1");
    row1.set("col2", "val1.2");
    row1.set("col3", "val1.3");
    WritableTuple row2 = new KeyValueTuple();
    row2.set("col1", "val2.1");
    row2.set("col2", "val2.2");
    row2.set("col3", "val2.3");
    when(tableModel.iterator()).thenReturn(Arrays.<Tuple> asList(row1, row2).iterator());

    ExcelExporter excelExporter = new ExcelExporter(tableModel);
    File xlsFile = File.createTempFile("table", ".xls");
    try
    {
      excelExporter.export(new FileOutputStream(xlsFile));

      // check output
      ExcelReader excelReader = new ExcelReader(xlsFile);
      ExcelSheetReader sheetReader = excelReader.getSheet("Sheet1");
      try
      {
        Iterator<Tuple> it = sheetReader.iterator();
        assertTrue(it.hasNext());
        Tuple tuple1 = it.next();
        assertEquals(tuple1.getString("col1"), row1.getString("col1"));
        assertEquals(tuple1.getString("col2"), row1.getString("col2"));
        assertEquals(tuple1.getString("col3"), row1.getString("col3"));
        assertTrue(it.hasNext());
        Tuple tuple2 = it.next();
        assertEquals(tuple2.getString("col1"), row2.getString("col1"));
        assertEquals(tuple2.getString("col2"), row2.getString("col2"));
        assertEquals(tuple2.getString("col3"), row2.getString("col3"));
        assertFalse(it.hasNext());
      }
      finally
      {
        IOUtils.closeQuietly(sheetReader);
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

    // verify that offsets and limits are ignored during export
    Field field1 = when(mock(Field.class).getName()).thenReturn("col1").getMock();
    Field field2 = when(mock(Field.class).getName()).thenReturn("col2").getMock();
    Field field3 = when(mock(Field.class).getName()).thenReturn("col3").getMock();
    when(tableModel.getColumns()).thenReturn(Arrays.asList(field1, field2, field3));
    WritableTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1.1");
    row1.set("col2", "val1.2");
    row1.set("col3", "val1.3");
    WritableTuple row2 = new KeyValueTuple();
    row2.set("col1", "val2.1");
    row2.set("col2", "val2.2");
    row2.set("col3", "val2.3");
    when(tableModel.iterator()).thenReturn(Arrays.<Tuple> asList(row1, row2).iterator());

    ExcelExporter excelExporter = new ExcelExporter(tableModel);
    File xlsFile = File.createTempFile("table", ".xls");
    try
    {
      excelExporter.export(new FileOutputStream(xlsFile));

      // check output
      ExcelReader excelReader = new ExcelReader(xlsFile);
      ExcelSheetReader sheetReader = excelReader.getSheet("Sheet1");
      try
      {
        Iterator<Tuple> it = sheetReader.iterator();
        assertTrue(it.hasNext());
        Tuple tuple1 = it.next();
        assertEquals(tuple1.getString("col1"), row1.getString("col1"));
        assertEquals(tuple1.getString("col2"), row1.getString("col2"));
        assertEquals(tuple1.getString("col3"), row1.getString("col3"));
        assertTrue(it.hasNext());
        Tuple tuple2 = it.next();
        assertEquals(tuple2.getString("col1"), row2.getString("col1"));
        assertEquals(tuple2.getString("col2"), row2.getString("col2"));
        assertEquals(tuple2.getString("col3"), row2.getString("col3"));
        assertFalse(it.hasNext());
      }
      finally
      {
        IOUtils.closeQuietly(sheetReader);
View Full Code Here

Examples of org.molgenis.util.tuple.KeyValueTuple

  @Test
  public void addCellProcessor_header() throws IOException
  {
    CellProcessor processor = when(mock(CellProcessor.class).processHeader()).thenReturn(true).getMock();

    KeyValueTuple tuple = new KeyValueTuple();
    tuple.set("col1", "val1");
    tuple.set("col2", "val2");

    CsvWriter csvWriter = new CsvWriter(new StringWriter());
    try
    {
      csvWriter.addCellProcessor(processor);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.