Package net.sf.block

Examples of net.sf.block.Container


    Format format = new FormatFactory().createFormat(definition);

    SAMRecord samRecord = null;
    CramHeader cramHeader = createCramHeader(reader.getFileHeader());
    ByteArrayOutputStream hBaos= new ByteArrayOutputStream() ;
    Container hC = new Container() ;
    Block hBlock = new Block() ;
    hBlock.contentId=0;
    hBlock.contentType=0;
    hBlock.method = CompressionMethod.GZIP.byteValue() ;
    hC.blocks = new Block[]{hBlock} ;
    hC.containers= new Container[0] ;
    CramHeaderIO.write(cramHeader, hBaos) ;
    hBlock.data = hBaos.toByteArray() ;
    format.writeContainer(hC, hBaos) ;
    System.out.println("Header size: " + hBaos.size());
   
    for (int b = 0; b < maxRecords; b+=recordsPerBlock) {
      bases = 0 ;
      size = 0 ;
      for (int i = 0; i < recordsPerBlock; i++) {
        samRecord = iterator.next();
        a.addSAMRecord(samRecord);
        bases += samRecord.getReadLength();
      }

      for (int i = 0; i < recordsPerBlock; i++) {
        while ((samRecord = a.nextSAMRecord()) != null) {
          CramRecord cramRecord = scFactory.createCramRecord(samRecord);
          records.add(cramRecord);

          setPairingInformation(cramRecord, samRecord, a.distanceToNextFragment());
        }
        while ((samRecord = a.fetchNextSAMRecord()) != null) {
          CramRecord cramRecord = scFactory.createCramRecord(samRecord);
          records.add(cramRecord);

          setPairingInformation(cramRecord, samRecord, a.distanceToNextFragment());
        }

      }

      Container container = new Coder(recordsPerSlice).writeRecords(cramHeader, records, provider);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      long time1 = System.nanoTime();
      format.writeContainer(container, baos);
      long time2 = System.nanoTime();
      System.out.printf("Container written: bytes=%d in %.2f ms.\n", baos.size(), (time2 - time1) / 1000000f);
      size += baos.size();

      records.clear();

      System.out.printf("Total records: %d, bases=%d, bytes=%d, b/b=%.2f\n", counter, bases, size, 8f * size
          / bases);

      time1 = System.nanoTime();
      Container c = format.readContainer(new ByteArrayInputStream(baos.toByteArray()));
      time2 = System.nanoTime();
      System.out.printf("Container read in %.2f ms.\n", (time2 - time1) / 1000000f);

      time1 = System.nanoTime();
      List<CramRecord> readRecords = new Coder(recordsPerSlice).readRecords(c, cramHeader, provider);
View Full Code Here


      }
    }
    long time2 = System.nanoTime();
    System.out.printf("Written %d records in %.2f ms.\n", counter, (time2 - time1) / 1000000f);

    Container c = new Container();
    c.blocks = blocks.toArray(new Block[blocks.size()]);
    c.containers = new Container[0];
    c.contentId = 2;

    return c;
View Full Code Here

TOP

Related Classes of net.sf.block.Container

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.