本文整理汇总了Java中htsjdk.tribble.util.LittleEndianOutputStream.writeInt方法的典型用法代码示例。如果您正苦于以下问题:Java LittleEndianOutputStream.writeInt方法的具体用法?Java LittleEndianOutputStream.writeInt怎么用?Java LittleEndianOutputStream.writeInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.tribble.util.LittleEndianOutputStream
的用法示例。
在下文中一共展示了LittleEndianOutputStream.writeInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFeature
import htsjdk.tribble.util.LittleEndianOutputStream; //导入方法依赖的package包/类
public void addFeature(int tid, Node feature, long filepointer, LittleEndianOutputStream los) throws IOException {
if(tid > BinIndexWriter.SHORT_MAX) throw new IllegalArgumentException("Currently we don't support to index file which has chr numbers larger than 32767.");
los.writeShort(tid);
//edit for case: start == end
if(feature.beg > feature.end) {
throw new IllegalArgumentException(String.format("Feature start position %d > feature end position %d", feature.beg, feature.end));
}
los.writeInt(feature.beg);
if((feature.end - feature.beg) > BinIndexWriter.SHORT_MAX) {
// System.out.println("range:" + (feature.end - feature.beg));
los.writeShort(BinIndexWriter.INT_START);
los.writeInt(feature.end - feature.beg);
} else {
los.writeShort(feature.end - feature.beg);
}
los.writeLong(filepointer);
}
示例2: makeIndex
import htsjdk.tribble.util.LittleEndianOutputStream; //导入方法依赖的package包/类
public void makeIndex() {
try {
final String outputPath = path + IntervalIndex.PLUS_EXTENSION;
final File outputFile = new File(outputPath + IntervalIndex.TEMP);
BlockCompressedInputStream reader = checkStream(new File(path));
LittleEndianOutputStream los = new LittleEndianOutputStream(new BlockCompressedOutputStream(outputFile));
readBGZInputstream(reader, los);
los.writeInt(IntervalIndex.PLUS_FILE_END);
writeOthers(los);
los.close();
boolean success = outputFile.renameTo(new File(outputPath));
if (!success) {
System.err.println("Make index has completed. But rename from '" + outputFile.getAbsolutePath() + "' to '" + outputPath + "' with error. ");
} else {
throw new IllegalArgumentException("We currently support bgz file format. please use bgzip to compress your file!");
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: addFeature
import htsjdk.tribble.util.LittleEndianOutputStream; //导入方法依赖的package包/类
public void addFeature(int tid, Node feature, long filepointer, LittleEndianOutputStream los) throws IOException {
los.writeInt(tid);
if(feature.beg >= feature.end) {
throw new IllegalArgumentException(String.format("Feature start position %d >= feature end position %d", feature.beg, feature.end));
}
los.writeInt(feature.beg);
// System.out.println(feature.beg + "," + feature.end);
los.writeInt(feature.end-feature.beg);
los.writeLong(filepointer);
}
示例4: writeChromosomeData
import htsjdk.tribble.util.LittleEndianOutputStream; //导入方法依赖的package包/类
private static void writeChromosomeData(LittleEndianOutputStream peakWriter,
LinkedHashMap<String, Long> chrIndex,
String currentChr,
List<PeakRecord> records) throws IOException {
chrIndex.put(currentChr, peakWriter.getWrittenCount());
// Compress data for chromosome, then write it out.
BufferedByteWriter buffer = new BufferedByteWriter(100000);
buffer.putNullTerminatedString(currentChr);
buffer.putInt(records.size());
for (PeakRecord record : records) {
buffer.putInt(record.start);
buffer.putInt(record.end);
buffer.putFloat(record.score);
for (int i = 0; i < record.timeScores.length; i++) {
buffer.putFloat(record.timeScores[i]);
}
}
byte[] bytes = buffer.getBytes();
bytes = compressionUtils.compress(bytes);
peakWriter.writeInt(bytes.length);
peakWriter.write(bytes);
records.clear();
}
示例5: convert
import htsjdk.tribble.util.LittleEndianOutputStream; //导入方法依赖的package包/类
/**
* @param inputPath
* @param outputFile
* @param chromosomeHandler
*/
public static void convert(String inputPath, String outputFile, ChromosomeHandler chromosomeHandler) throws IOException {
Map<String, Integer> chromosomeOrdinals = new HashMap<>();
for (Chromosome c : chromosomeHandler.getChromosomeArray()) {
chromosomeOrdinals.put(c.getName(), c.getIndex());
}
AsciiPairIterator iter = null;
BufferedOutputStream bos = null;
try {
bos = new BufferedOutputStream(new FileOutputStream(outputFile));
LittleEndianOutputStream les = new LittleEndianOutputStream(bos);
iter = new AsciiPairIterator(inputPath, chromosomeOrdinals
);
while (iter.hasNext()) {
AlignmentPair pair = iter.next();
les.writeBoolean(pair.getStrand1());
les.writeInt(pair.getChr1());
les.writeInt(pair.getPos1());
les.writeInt(pair.getFrag1());
les.writeBoolean(pair.getStrand2());
les.writeInt(pair.getChr2());
les.writeInt(pair.getPos2());
les.writeInt(pair.getFrag2());
}
les.flush();
bos.flush();
} finally {
if (iter != null) iter.close();
if (bos != null) bos.close();
}
}
示例6: writeHeader
import htsjdk.tribble.util.LittleEndianOutputStream; //导入方法依赖的package包/类
private void writeHeader(LittleEndianOutputStream les, int dim, float lower, float upper) throws IOException {
// Magic number - 4 bytes
les.writeByte('h');
les.writeByte('i');
les.writeByte('c');
les.writeByte(0);
// Version number
les.writeInt(1);
// Genome --
les.writeString(dataset.getGenomeId());
// Chromosomes
les.writeString(chromosome1.getName());
les.writeString(chromosome1.getName());
// Resolution (bin size)
les.writeInt(binSize);
// Statistics, other attributes
les.writeFloat(lower); // this is supposed to be lower quartile
les.writeFloat(upper); // this is supposed to be upper quartile
les.writeInt(dim); // # rows
les.writeInt(dim); // # cols
les.writeInt(BLOCK_TILE);
}