Skip to content
Browse files

minor fixes;

added crai;
brai in progress (beyond alignment query returns all records instead of
none).
  • Loading branch information...
1 parent 9b30bbf commit 39215485d495e6a0f158a98ade5650f43bf1d730 @vadimzalunin committed Dec 11, 2012
View
4 build.number
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Wed Dec 05 15:39:11 GMT 2012
-build.number=244
+#Tue Dec 11 16:00:04 GMT 2012
+build.number=245
View
BIN cramtools-1.0.jar
Binary file not shown.
View
4 src/main/java/net/sf/cram/Bam2Cram.java
@@ -241,6 +241,7 @@ public static void main(String[] args) throws IOException,
ReferenceSequenceFile referenceSequenceFile = ReferenceSequenceFileFactory
.getReferenceSequenceFile(params.referenceFasta);
+ BLOCK_PROTO.recordsPerSlice = params.maxSliceSize ;
ReferenceSequence sequence = null;
List<SAMRecord> samRecords = new ArrayList<SAMRecord>(
params.maxContainerSize);
@@ -259,6 +260,7 @@ public static void main(String[] args) throws IOException,
log.info("Adding default read group.");
SAMReadGroupRecord readGroup = new SAMReadGroupRecord(
Sam2CramRecordFactory.UNKNOWN_READ_GROUP_ID);
+
readGroup
.setSample(Sam2CramRecordFactory.UNKNOWN_READ_GROUP_SAMPLE);
samFileReader.getFileHeader().addReadGroup(readGroup);
@@ -428,7 +430,7 @@ public static void main(String[] args) throws IOException,
int maxSliceSize = 10000;
@Parameter(names = { "--max-container-size" }, hidden = true)
- int maxContainerSize = 100000;
+ int maxContainerSize = 10000;
@Parameter(names = { "--illumina-quality-score-binning" }, description = "Use NCBI binning scheme for quality scores.")
boolean illuminaQualityScoreBinning = false;
View
52 src/main/java/net/sf/cram/IndexCRAM.java
@@ -1,7 +1,9 @@
package net.sf.cram;
+import java.io.BufferedInputStream;
import java.io.EOFException;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
@@ -75,29 +77,41 @@ public static void main(String[] args) throws IOException {
Log.setGlobalLogLevel(LogLevel.INFO);
File file = new File(args[0]);
- File indexFile = new File(file.getAbsolutePath() + ".bai");
+ File cramIndexFile = new File(file.getAbsolutePath() + ".brai");
+ File bamIndexFile = new File(file.getAbsolutePath().replaceAll(
+ ".cram$", "")
+ + ".bai");
+
// InputStream is = new BufferedInputStream(new FileInputStream(file));
- // IndexCRAM ic = new IndexCRAM(is, indexFile);
+ // IndexCRAM ic = new IndexCRAM(is, cramIndexFile);
//
// ic.run();
-
-// CRAMFileReader reader = new CRAMFileReader(file, indexFile,
-// ReferenceSequenceFileFactory.getReferenceSequenceFile(new File(
-// args[1])));
- SAMFileReader reader = new SAMFileReader(file, indexFile) ;
-
- int position = 63693735;
- query(reader, position);
-
- int minPos = 1;
- int maxPos = 100000000;
- Random random = new Random();
- for (int i = 0; i < 10; i++)
- query(reader, random.nextInt(maxPos - minPos) + minPos);
+ //
+ // CRAMIndexer.createAndWriteIndex(cramIndexFile, new
+ // File("c:/temp/brai.txt"), true) ;
+ // CRAMIndexer.createAndWriteIndex(bamIndexFile, new
+ // File("c:/temp/bai.txt"), true) ;
+
+ CRAMFileReader reader = new CRAMFileReader(file, cramIndexFile,
+ ReferenceSequenceFileFactory.getReferenceSequenceFile(new File(
+ args[1])));
+// SAMFileReader reader = new SAMFileReader(file, bamIndexFile);
+
+ int position = 63693735;
+// int position = 62965418;
+ for (int i = position; i < position + 10; i++)
+ query(reader, i);
+
+// int minPos = 1;
+// int maxPos = 100000000;
+// Random random = new Random();
+// for (int i = 0; i < 10; i++)
+// query(reader, random.nextInt(maxPos - minPos) + minPos);
}
- private static void query(SAMFileReader reader, int position) {
- CloseableIterator<SAMRecord> iterator = reader.queryAlignmentStart("20", position);
+ private static void query(CRAMFileReader reader, int position) {
+ CloseableIterator<SAMRecord> iterator = reader.queryAlignmentStart(
+ "20", position);
System.out.println("Query: " + position);
SAMRecord record = null;
@@ -106,6 +120,8 @@ private static void query(SAMFileReader reader, int position) {
record = iterator.next();
if (record.getAlignmentStart() >= position)
break;
+ else
+ record = null;
overhead++;
}
if (record == null)
View
5 src/main/java/net/sf/samtools/CRAMIndexer.java
@@ -197,6 +197,8 @@ private int computeIndexingBin(Slice slice) {
* @param rec The BAM record. Requires rec.getFileSource() is non-null.
*/
public void processAlignment(Slice slice) {
+
+ System.out.printf("%d\t%d\t%d\t%d\n", slice.alignmentStart, slice.alignmentSpan, slice.offset, slice.containerOffset);
// metadata
indexStats.recordMetaData(slice);
@@ -240,7 +242,8 @@ public void processAlignment(Slice slice) {
// process chunks
final long chunkStart = (slice.containerOffset << 16) | slice.index;
- final long chunkEnd = (slice.containerOffset << 16) | slice.index;
+ final long chunkEnd = ((slice.containerOffset << 16) | slice.index) + 1;
+
Chunk newChunk = new Chunk(chunkStart, chunkEnd) ;
final List<Chunk> oldChunks = bin.getChunkList();

0 comments on commit 3921548

Please sign in to comment.
Something went wrong with that request. Please try again.