Permalink
Browse files

initial

  • Loading branch information...
0 parents commit 65768028c6d963289b53a0f20ed3da4989ba43af @vadimzalunin committed Oct 28, 2012
Showing 387 changed files with 8,197 additions and 0 deletions.
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/crammer"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/picard"/>
+ <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-math-2.2.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>cram1</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
@@ -0,0 +1,3 @@
+#Build Number for ANT. Do not edit!
+#Wed Aug 29 11:46:55 BST 2012
+build.number=8
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project basedir="../" default="help" name="cramtools">
+
+ <property environment="env" />
+
+ <property name="src" value="${basedir}/src" />
+ <property name="build.home" value="${basedir}/build" />
+ <property name="lib.home" value="${basedir}/lib" />
+ <property name="target.dir" value="${basedir}/target" />
+ <property name="classes" value="${target.dir}/classes" />
+ <property name="crammerClasses" value="../crammer/target/classes" />
+ <property name="jar.file.name" value="cramone.jar" />
+
+ <path id="classpath">
+ <fileset dir="${lib.home}" includes="*.jar" />
+ <fileset dir="../crammer/lib" includes="*.jar" />
+ </path>
+
+ <path id="build.classpath">
+ <fileset dir="${basedir}/">
+ <include name="${lib.home}/*.jar" />
+ </fileset>
+ </path>
+
+ <pathconvert property="mf.classpath" pathsep=" ">
+ <path refid="build.classpath" />
+ <mapper>
+ <chainedmapper>
+ <flattenmapper />
+ <globmapper from="*.jar" to="lib/*.jar" />
+ </chainedmapper>
+ </mapper>
+ </pathconvert>
+
+ <target name="runnable" depends="clean,compile">
+
+ <property file="version.property" />
+ <buildnumber />
+
+ <tstamp>
+ <format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" />
+ </tstamp>
+
+ <jar destfile="${basedir}/cramone.jar" filesetmanifest="skip" duplicate="preserve">
+ <fileset dir="${classes}" />
+ <zipgroupfileset dir="lib" includes="*.jar" >
+ <exclude name="**/SAMFileReader.class" />
+ </zipgroupfileset>
+
+ <manifest>
+ <attribute name="Main-Class" value="net.sf.cram.Coder" />
+ <attribute name="Class-Path" value="" />
+ <attribute name="Built-By" value="${user.name}" />
+ <attribute name="Implementation-Version" value="${version.num}-b${build.number}" />
+ <attribute name="Built-Date" value="${TODAY}" />
+ </manifest>
+ </jar>
+ </target>
+
+
+
+ <target name="setup">
+ <mkdir dir="${classes}" />
+ <mkdir dir="${target.dir}" />
+ </target>
+
+ <target name="run">
+ <java classname="net.sf.cram.Coder">
+ <classpath refid="classpath" />
+ <classpath path="${target.dir}/${jar.file.name}" />
+ </java>
+ </target>
+
+ <target name="test">
+ <junit printsummary="yes" fork="false" haltonfailure="false" haltonerror="false" includeantruntime="false" showoutput="true">
+ <classpath refid="classpath" />
+ <classpath path="${classes}" />
+
+ <formatter type="plain" />
+
+ <test name="uk.ac.ebi.ena.sra.cram.TestAll" />
+
+ </junit>
+ </target>
+
+ <target name="clean">
+ <delete dir="${target.dir}" includeEmptyDirs="true" />
+ <delete file="cramtools.jar" />
+ </target>
+
+ <target name="compile" depends="setup">
+ <javac debug="true" fork="true" destdir="${classes}" srcdir="${src}/main/java:${src}/test/java:../crammer/src/main/java">
+ <include name="**/*.java" />
+ <classpath refid="classpath" />
+ </javac>
+ <copy todir="${classes}">
+ <fileset dir="${basedir}/src/main/resources" includes="**/*">
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="help">
+ <property file="version.property" />
+
+ <echo message="cramtools build xml, version ${version.num}" />
+ <echo message="Available targets: " />
+ <echo message=" clean" />
+ <echo message=" compile" />
+ <echo message=" test" />
+ <echo message=" runnable" />
+ </target>
+
+</project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
+package net.sf.block;
+
+
+public class Block {
+ public byte method ;
+ public byte contentType;
+ public int contentId ;
+ public int bytes ;
+ public int dataBytes ;
+ public byte[] data ;
+
+}
@@ -0,0 +1,112 @@
+package net.sf.block;
+
+import java.nio.ByteBuffer;
+
+public class ByteBufferUtils {
+
+ public static final int readUnsignedITF8 (byte[] data) {
+ ByteBuffer buf = ByteBuffer.wrap(data) ;
+ int value = ByteBufferUtils.readUnsignedITF8(buf) ;
+ buf.clear() ;
+
+ return value ;
+ }
+
+ public static final byte[] writeUnsignedITF8 (int value) {
+ ByteBuffer buf = ByteBuffer.allocate(10);
+ ByteBufferUtils.writeUnsignedITF8(value, buf);
+
+ buf.flip();
+ byte[] array = new byte[buf.limit()];
+ buf.get(array);
+
+ buf.clear() ;
+ return array;
+ }
+
+ public static final int readUnsignedITF8(ByteBuffer buf) {
+ int b1 = 0xFF & buf.get();
+
+ if ((b1 & 0b10000000) == 0)
+ return b1;
+
+ if ((b1 & 0b01000000) == 0)
+ return ((b1 & 0b01111111) << 8) | (0xFF & buf.get());
+
+ if ((b1 & 0b00100000) == 0) {
+ int b2 = 0xFF & buf.get() ;
+ int b3 = 0xFF & buf.get() ;
+ return ((b1 & 0b00111111) << 16) | b2 << 8
+ | b3;
+ }
+
+ if ((b1 & 0b00010000) == 0)
+ return ((b1 & 0b00011111) << 24) | (0xFF & buf.get()) << 16
+ | (0xFF & buf.get()) << 8 | (0xFF & buf.get());
+
+ return ((b1 & 0b00001111) << 28) | (0xFF & buf.get()) << 20
+ | (0xFF & buf.get()) << 12 | (0xFF & buf.get()) << 4
+ | (0b00001111 & buf.get());
+ }
+
+ public static final void writeUnsignedITF8(int value, ByteBuffer buf) {
+ if ((value >>> 7) == 0) {
+ buf.put((byte) value);
+ return;
+ }
+
+ if ((value >>> 14) == 0) {
+ buf.put((byte) ((value >> 8) | 0b10000000));
+ buf.put((byte) (value & 0xFF));
+ return;
+ }
+
+ if ((value >>> 21) == 0) {
+ buf.put((byte) ((value >> 16) | 0b11000000));
+ buf.put((byte) ((value >> 8) & 0xFF));
+ buf.put((byte) (value & 0xFF));
+ return;
+ }
+
+ if ((value >>> 28) == 0) {
+ buf.put((byte) ((value >> 24) | 0b11100000));
+ buf.put((byte) ((value >> 16) & 0xFF));
+ buf.put((byte) ((value >> 8) & 0xFF));
+ buf.put((byte) (value & 0xFF));
+ return;
+ }
+
+ buf.put((byte) ((value >> 28) | 0b11110000));
+ buf.put((byte) ((value >> 20) & 0xFF));
+ buf.put((byte) ((value >> 12) & 0xFF));
+ buf.put((byte) ((value >> 4) & 0xFF));
+ buf.put((byte) (value & 0xFF));
+ }
+
+ public static void main(String[] args) {
+ ByteBuffer buf = ByteBuffer.allocate(5);
+
+ //Read 192 but expecting 16384
+ writeUnsignedITF8(16384, buf) ;
+ buf.flip() ;
+ int v = readUnsignedITF8(buf) ;
+ System.out.println(v);
+
+ long time=System.nanoTime() ;
+ for (int i=0; i<Integer.MAX_VALUE; i++) {
+ buf.clear() ;
+ writeUnsignedITF8(i, buf);
+ buf.flip() ;
+ int value = readUnsignedITF8(buf) ;
+ if (i != value)
+ throw new RuntimeException("Read " + value + " but expecting " + i);
+
+ if (System.nanoTime()-time > 1000*1000*1000) {
+ time = System.nanoTime() ;
+ System.out.println("i=" + i);
+ }
+ }
+
+ System.out.println("Done.");
+ }
+}
@@ -0,0 +1,13 @@
+package net.sf.block;
+
+public enum CompressionMethod {
+ RAW, GZIP;
+
+ public byte byteValue() {
+ return (byte) ordinal();
+ }
+
+ public static CompressionMethod fromByte(byte value) {
+ return CompressionMethod.values()[0xFF & value];
+ }
+}
@@ -0,0 +1,9 @@
+ package net.sf.block;
+
+public class Container {
+ public int length;
+ public long contentId;
+
+ public Block[] blocks;
+ public Container[] containers;
+}
@@ -0,0 +1,24 @@
+package net.sf.block;
+
+import java.nio.ByteBuffer;
+
+public class DefaultBlock {
+
+ public CompressionMethod compressionMethod;
+ public byte contentType;
+ public int contentId;
+ public int bytes;
+ public int dataBytes;
+ protected byte[] data;
+
+ public DefaultBlock() {
+ }
+
+ public void write(ByteBuffer buf) {
+
+ }
+
+ public void read(ByteBuffer buf) {
+
+ }
+}
@@ -0,0 +1,8 @@
+package net.sf.block;
+
+public class Definition {
+ public byte[] magick;
+ public byte formatMajor ;
+ public byte formatMinor ;
+ public byte[] contentId;
+}
@@ -0,0 +1,18 @@
+package net.sf.block;
+
+import java.io.ByteArrayOutputStream;
+
+public class ExposedByteArrayOutputStream extends ByteArrayOutputStream {
+
+ public ExposedByteArrayOutputStream() {
+ super();
+ }
+
+ public ExposedByteArrayOutputStream(int size) {
+ super(size);
+ }
+
+ public byte[] getBuffer() {
+ return buf;
+ }
+}
Oops, something went wrong.

0 comments on commit 6576802

Please sign in to comment.