本文整理汇总了Java中htsjdk.samtools.util.BufferedLineReader类的典型用法代码示例。如果您正苦于以下问题:Java BufferedLineReader类的具体用法?Java BufferedLineReader怎么用?Java BufferedLineReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BufferedLineReader类属于htsjdk.samtools.util包,在下文中一共展示了BufferedLineReader类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readSAMFileHeader
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
private static SAMFileHeader readSAMFileHeader(InputStream inputStream,
final String id) throws IOException {
final SecramBlock block = SecramBlock.readFromInputStream(inputStream);
inputStream = new ByteArrayInputStream(block.getRawContent());
final ByteBuffer buffer = ByteBuffer.allocate(4);
buffer.order(ByteOrder.LITTLE_ENDIAN);
for (int i = 0; i < 4; i++)
buffer.put((byte) inputStream.read());
buffer.flip();
final int size = buffer.asIntBuffer().get();
final DataInputStream dataInputStream = new DataInputStream(inputStream);
final byte[] bytes = new byte[size];
dataInputStream.readFully(bytes);
final BufferedLineReader bufferedLineReader = new BufferedLineReader(
new ByteArrayInputStream(bytes));
final SAMTextHeaderCodec codec = new SAMTextHeaderCodec();
return codec.decode(bufferedLineReader, id);
}
开发者ID:acs6610987,项目名称:secram,代码行数:23,代码来源:SecramIO.java
示例2: convertParamsFile
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
private void convertParamsFile(String libraryParamsFile, int concatNColumnFields, File testDataDir, File outputDir, File libraryParams, List<File> outputPrefixes) throws FileNotFoundException {
try (LineReader reader = new BufferedLineReader(new FileInputStream(new File(testDataDir, libraryParamsFile)))) {
final PrintWriter writer = new PrintWriter(libraryParams);
final String header = reader.readLine();
writer.println(header + "\tOUTPUT_PREFIX");
while (true) {
final String line = reader.readLine();
if (line == null) {
break;
}
final String[] fields = line.split("\t");
final File outputPrefix = new File(outputDir, StringUtil.join("", Arrays.copyOfRange(fields, 0, concatNColumnFields)));
outputPrefixes.add(outputPrefix);
writer.println(line + "\t" + outputPrefix);
}
writer.close();
}
}
开发者ID:broadinstitute,项目名称:picard,代码行数:19,代码来源:IlluminaBasecallsToFastqTest.java
示例3: testHeaderVersion
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
/**
* Confirm that ViewSam retains whatever version number was in the input header.
*/
@Test
public void testHeaderVersion() throws Exception {
final String oldVersionHeader = "@HD\tVN:1.3\tSO:unsorted";
final File inputSam = File.createTempFile("ViewSamTest.input.", ".sam");
inputSam.deleteOnExit();
final AsciiWriter writer = new AsciiWriter(new FileOutputStream(inputSam));
writer.write(oldVersionHeader);
writer.write("\n");
writer.close();
final File viewSamOutputFile = File.createTempFile("ViewSamTest.output.", ".sam");
viewSamOutputFile.deleteOnExit();
final ViewSam viewSam = new ViewSam();
viewSam.INPUT = inputSam.getAbsolutePath();
// create a print stream to this file
final PrintStream viewSamPrintStream = new PrintStream(viewSamOutputFile);
// make sure the command line call exited successfully
Assert.assertEquals(viewSam.writeSamText(viewSamPrintStream), 0);
viewSamPrintStream.close();
final LineReader viewSamInputReader = new BufferedLineReader(new FileInputStream(viewSamOutputFile));
Assert.assertEquals(viewSamInputReader.readLine(), oldVersionHeader);
}
开发者ID:broadinstitute,项目名称:picard,代码行数:28,代码来源:ViewSamTest.java
示例4: loadFastaDictionary
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
/**
* Given an InputStream connected to a fasta dictionary, returns its sequence dictionary
*
* Note: does not close the InputStream it's passed
*
* @param fastaDictionaryStream InputStream connected to a fasta dictionary
* @return the SAMSequenceDictionary from the fastaDictionaryStream
*/
public static SAMSequenceDictionary loadFastaDictionary( final InputStream fastaDictionaryStream ) {
// Don't close the reader when we're done, since we don't want to close the client's InputStream for them
final BufferedLineReader reader = new BufferedLineReader(fastaDictionaryStream);
final SAMTextHeaderCodec codec = new SAMTextHeaderCodec();
final SAMFileHeader header = codec.decode(reader, fastaDictionaryStream.toString());
// Make sure we have a valid sequence dictionary before continuing:
if (header.getSequenceDictionary() == null || header.getSequenceDictionary().isEmpty()) {
throw new UserException.MalformedFile (
"Could not read sequence dictionary from given fasta stream " +
fastaDictionaryStream
);
}
return header.getSequenceDictionary();
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:26,代码来源:ReferenceUtils.java
示例5: SAMStreamHandler
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
public SAMStreamHandler(AlignerInstance instance, Context context, boolean useCompact) {
this.is = instance.getSTDOUTStream();
this.mFileHeader = instance.getFileHeader();
this.instance = instance;
this.useCompact = useCompact;
mCurrentLine = null;
mFile = null;
validationStringency = ValidationStringency.LENIENT;
mReader = new BufferedLineReader(this.is);
samRecordFactory = new DefaultSAMRecordFactory();
this.context = context;
isPaired = HalvadeConf.getIsPaired(context.getConfiguration());
}
开发者ID:biointec,项目名称:halvade,代码行数:14,代码来源:SAMStreamHandler.java
示例6: BasicInputParser
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
/**
* Constructor. Opens up a buffered reader and reads the first line.
*
* @param inputStreams the file(s) to parse, in order
*/
public BasicInputParser(final boolean treatGroupedDelimitersAsOne, final InputStream... inputStreams) {
if (inputStreams.length == 0) {
throw new IllegalArgumentException("At least one input must be specified.");
}
this.inputs.addAll(Arrays.asList(inputStreams));
reader = new BufferedLineReader(this.inputs.remove(0));
this.setTreatGroupedDelimitersAsOne(treatGroupedDelimitersAsOne);
}
开发者ID:broadinstitute,项目名称:picard,代码行数:14,代码来源:BasicInputParser.java
示例7: HDF5SimpleCountCollection
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
/**
* DEV NOTE: If you are adding attributes that are neither RealMatrix nor a primitive,
* you must follow the pattern in the constructor (i.e. the Lazy loading pattern).
* Otherwise, some operations will hang.
*/
HDF5SimpleCountCollection(final HDF5File file) {
Utils.nonNull(file, "The input file cannot be null.");
this.file = file;
sampleName = new Lazy<>(() -> file.readStringArray(SAMPLE_NAME_PATH)[0]);
sequenceDictionary = new Lazy<>(() -> {
final String sequenceDictionaryString = file.readStringArray(SEQUENCE_DICTIONARY_PATH)[0];
return new SAMTextHeaderCodec()
.decode(BufferedLineReader.fromString(sequenceDictionaryString), file.getFile().getAbsolutePath())
.getSequenceDictionary();
});
intervals = new Lazy<>(() -> HDF5Utils.readIntervals(file, INTERVALS_GROUP_NAME));
counts = new Lazy<>(() -> new Array2DRowRealMatrix(file.readDoubleMatrix(COUNTS_PATH)));
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:19,代码来源:HDF5SimpleCountCollection.java
示例8: HDF5SVDReadCountPanelOfNormals
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
/**
* DEV NOTE: If you are adding attributes that are neither RealMatrix nor a primitive,
* you must follow the pattern in the constructor (i.e. the Lazy loading pattern).
* Otherwise, some operations will hang.
*/
private HDF5SVDReadCountPanelOfNormals(final HDF5File file) {
Utils.nonNull(file);
IOUtils.canReadFile(file.getFile());
this.file = file;
sequenceDictionary = new Lazy<>(() -> {
final String sequenceDictionaryString = file.readStringArray(SEQUENCE_DICTIONARY_PATH)[0];
return new SAMTextHeaderCodec()
.decode(BufferedLineReader.fromString(sequenceDictionaryString), file.getFile().getAbsolutePath())
.getSequenceDictionary();
});
originalIntervals = new Lazy<>(() -> HDF5Utils.readIntervals(file, ORIGINAL_INTERVALS_PATH));
panelIntervals = new Lazy<>(() -> HDF5Utils.readIntervals(file, PANEL_INTERVALS_PATH));
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:19,代码来源:HDF5SVDReadCountPanelOfNormals.java
示例9: testExecuteCommand
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
@Test(groups = "python", dataProvider="supportedPythonVersions", dependsOnMethods = "testPythonExists", timeOut=10000)
public void testExecuteCommand(final PythonScriptExecutor.PythonExecutableName executableName) throws IOException {
// create a temporary output file
final File tempFile = createTempFile("pythonExecuteCommandTest", "txt");
final String WRITE_FILE_SCRIPT =
String.format(
"with open('%s', 'w') as tempFile:\n tempFile.write('Hello world')" + NL + NL,
tempFile.getAbsolutePath());
final String CLOSE_FILE_SCRIPT = "tempFile.close()" + NL;
final StreamingPythonScriptExecutor streamingPythonExecutor =
new StreamingPythonScriptExecutor(executableName,true);
Assert.assertNotNull(streamingPythonExecutor);
Assert.assertTrue(streamingPythonExecutor.start(Collections.emptyList()));
try {
streamingPythonExecutor.sendSynchronousCommand(WRITE_FILE_SCRIPT);
streamingPythonExecutor.sendSynchronousCommand(CLOSE_FILE_SCRIPT);
}
finally {
streamingPythonExecutor.terminate();
Assert.assertFalse(streamingPythonExecutor.getProcess().isAlive());
}
// read the temp file in and validate
try (final FileInputStream fis= new FileInputStream(tempFile);
final BufferedLineReader br = new BufferedLineReader(fis)) {
Assert.assertEquals(br.readLine(), "Hello world");
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:33,代码来源:StreamingPythonScriptExecutorUnitTest.java
示例10: advanceFile
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
protected void advanceFile() {
currentFileName = !fileNames.isEmpty() ? fileNames.remove(0) : null;
nextLineNumber = 0;
nextLine = null;
reader = new BufferedLineReader(inputs.remove(0));
}
开发者ID:broadinstitute,项目名称:picard,代码行数:7,代码来源:BasicInputParser.java
示例11: testGenotypeConcordance
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
@Test(dataProvider = "genotypeConcordanceTestFileData")
public void testGenotypeConcordance(final File vcf1, final String sample1, final File vcf2, final String sample2,
final Integer minGq, final Integer minDp, final boolean outputAllRows, final boolean missingSitesFlag,
final String expectedOutputFileBaseName) throws Exception {
final List<Boolean> withVcfs = Arrays.asList(true, false);
for (final boolean withVcf : withVcfs) {
final File outputBaseFileName = new File(OUTPUT_DATA_PATH, "actualGtConc");
final File outputSummaryFile = new File(outputBaseFileName.getAbsolutePath() + GenotypeConcordance.SUMMARY_METRICS_FILE_EXTENSION);
final File outputDetailsFile = new File(outputBaseFileName.getAbsolutePath() + GenotypeConcordance.DETAILED_METRICS_FILE_EXTENSION);
final File outputContingencyFile = new File(outputBaseFileName.getAbsolutePath() + GenotypeConcordance.CONTINGENCY_METRICS_FILE_EXTENSION);
final Path outputVcfFile = Paths.get(outputBaseFileName.getAbsolutePath() + GenotypeConcordance.OUTPUT_VCF_FILE_EXTENSION);
outputSummaryFile.deleteOnExit();
outputDetailsFile.deleteOnExit();
outputContingencyFile.deleteOnExit();
outputVcfFile.toFile().deleteOnExit();
final GenotypeConcordance genotypeConcordance = new GenotypeConcordance();
genotypeConcordance.TRUTH_VCF = vcf1;
genotypeConcordance.TRUTH_SAMPLE = sample1;
genotypeConcordance.CALL_VCF = vcf2;
genotypeConcordance.CALL_SAMPLE = sample2;
if (minGq != null) genotypeConcordance.MIN_GQ = minGq;
if (minDp != null) genotypeConcordance.MIN_DP = minDp;
genotypeConcordance.OUTPUT_ALL_ROWS = outputAllRows;
genotypeConcordance.OUTPUT = outputBaseFileName;
genotypeConcordance.MISSING_SITES_HOM_REF = missingSitesFlag;
if (missingSitesFlag) {
genotypeConcordance.INTERVALS = Collections.singletonList(new File(TEST_DATA_PATH, "IntervalList1PerChrom.interval_list"));
}
genotypeConcordance.OUTPUT_VCF = withVcf;
Assert.assertEquals(genotypeConcordance.instanceMain(new String[0]), 0);
assertMetricsFileEqual(outputSummaryFile, new File(TEST_DATA_PATH, expectedOutputFileBaseName + GenotypeConcordance.SUMMARY_METRICS_FILE_EXTENSION));
assertMetricsFileEqual(outputDetailsFile, new File(TEST_DATA_PATH, expectedOutputFileBaseName + GenotypeConcordance.DETAILED_METRICS_FILE_EXTENSION));
assertMetricsFileEqual(outputContingencyFile, new File(TEST_DATA_PATH, expectedOutputFileBaseName + GenotypeConcordance.CONTINGENCY_METRICS_FILE_EXTENSION));
if (withVcf) {
// An ugly way to compare VCFs
final Path expectedVcf = Paths.get(TEST_DATA_PATH.getAbsolutePath(), expectedOutputFileBaseName + ".vcf");
final BufferedLineReader reader = new BufferedLineReader(new GZIPInputStream(new FileInputStream(outputVcfFile.toFile())));
final Iterator<String> actualLines;
{
final List<String> lines = new ArrayList<>();
while (-1 != reader.peek()) {
lines.add(reader.readLine());
}
reader.close();
actualLines = lines.iterator();
}
final Iterator<String> expectedLines = Files.lines(expectedVcf).iterator();
while (actualLines.hasNext() && expectedLines.hasNext()) {
final String actualLine = actualLines.next();
final String expectedLine = expectedLines.next();
Assert.assertEquals(actualLine, expectedLine);
}
Assert.assertFalse(actualLines.hasNext());
Assert.assertFalse(expectedLines.hasNext());
}
}
}
开发者ID:broadinstitute,项目名称:picard,代码行数:62,代码来源:GenotypeConcordanceTest.java
示例12: getHeader
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
private SAMFileHeader getHeader() throws FileNotFoundException {
final LineReader lineReader = new BufferedLineReader(new FileInputStream(file));
return new SAMTextHeaderCodec().decode(lineReader, getSource());
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:5,代码来源:AbstractRecordCollection.java
示例13: testAsyncWriteInBatches
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
@Test
public void testAsyncWriteInBatches() throws IOException, InterruptedException, ExecutionException {
final int ITEM_COUNT = 100;
final int BATCH_SIZE = 12;
final List<String> readCommandStrings = new ArrayList<>();
final List<String> expectedReadCommandStrings = new ArrayList<>();
final List<String> expectedItems = new ArrayList<>();
List<String> batchItems;
int batchCount = 0;
AsynchronousStreamWriterService<String> asyncWriteService = null;
// create an executor service, and write ITEM_COUNT lines in batches of BATCH_SIZE (where ITEM_COUNT is not
// an integral multiple of BATCH_SIZE) and leave one final odd-sized batch at the end
final ExecutorService executorService = Executors.newSingleThreadExecutor();
try (final ByteArrayOutputStream streamWriter = new ByteArrayOutputStream()) {
asyncWriteService = new AsynchronousStreamWriterService<>(executorService, streamWriter, AsynchronousStreamWriterService.stringSerializer);
batchItems = new ArrayList<>(BATCH_SIZE);
for (int i = 0; i < ITEM_COUNT; i++) {
if (batchCount == BATCH_SIZE) {
dispatchABatch(asyncWriteService, batchItems, batchCount, readCommandStrings, expectedReadCommandStrings);
batchItems = new ArrayList<>(BATCH_SIZE);
batchCount = 0;
}
final String itemToWrite = Integer.toString(i) + "\n";
batchItems.add(itemToWrite);
expectedItems.add(itemToWrite);
batchCount++;
}
// write the last, odd-sized batch
if (batchCount != 0) {
dispatchABatch(asyncWriteService, batchItems, batchCount, readCommandStrings, expectedReadCommandStrings);
}
final Future<Integer> batchResult = asyncWriteService.waitForPreviousBatchCompletion(TIMEOUT_TIME, TIMEOUT_TIMEUNIT);
Assert.assertTrue(batchResult.get().equals(batchCount));
Assert.assertTrue(asyncWriteService.terminate());
// read the output stream file in and make sure everything was written to the stream by the async writer,
// and all command strings were executed on the background thread
try (final ByteArrayInputStream is= new ByteArrayInputStream(streamWriter.toByteArray());
final BufferedLineReader br = new BufferedLineReader(is)) {
expectedItems.forEach(expectedLine -> Assert.assertEquals(br.readLine() + '\n', expectedLine));
}
Assert.assertEquals(readCommandStrings, expectedReadCommandStrings);
} finally {
if (asyncWriteService != null) {
asyncWriteService.terminate();
}
executorService.shutdown();
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:54,代码来源:AsynchronousStreamWriterServiceUnitTest.java
示例14: doWork
import htsjdk.samtools.util.BufferedLineReader; //导入依赖的package包/类
@Override
public int doWork(List<String> args) {
LOG.info("reading from stdin ... ");
try
{
int c=stdin().read();
if(c==-1 || c!='#')
{
LOG.info("VCF header missing (Sample are "+this.SAMPLES+") . Fixing.");
stdout().println("##fileformat=VCFv4.1");
stdout().println("##source=VarScan2");
stdout().println("##varscan2header=missing");
stdout().println("##INFO=<ID=ADP,Number=1,Type=Integer,Description=\"Average per-sample depth of bases with Phred score >= 15\">");
stdout().println("##INFO=<ID=WT,Number=1,Type=Integer,Description=\"Number of samples called reference (wild-type)\">");
stdout().println("##INFO=<ID=HET,Number=1,Type=Integer,Description=\"Number of samples called heterozygous-variant\">");
stdout().println("##INFO=<ID=HOM,Number=1,Type=Integer,Description=\"Number of samples called homozygous-variant\">");
stdout().println("##INFO=<ID=NC,Number=1,Type=Integer,Description=\"Number of samples not called\">");
stdout().println("##FILTER=<ID=str10,Description=\"Less than 10% or more than 90% of variant supporting reads on one strand\">");
stdout().println("##FILTER=<ID=indelError,Description=\"Likely artifact due to indel reads at this position\">");
stdout().println("##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">");
stdout().println("##FORMAT=<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Quality\">");
stdout().println("##FORMAT=<ID=SDP,Number=1,Type=Integer,Description=\"Raw Read Depth as reported by SAMtools\">");
stdout().println("##FORMAT=<ID=DP,Number=1,Type=Integer,Description=\"Quality Read Depth of bases with Phred score >= 15\">");
stdout().println("##FORMAT=<ID=RD,Number=1,Type=Integer,Description=\"Depth of reference-supporting bases (reads1)\">");
stdout().println("##FORMAT=<ID=AD,Number=1,Type=Integer,Description=\"Depth of variant-supporting bases (reads2)\">");
stdout().println("##FORMAT=<ID=FREQ,Number=1,Type=String,Description=\"Variant allele frequency\">");
stdout().println("##FORMAT=<ID=PVAL,Number=1,Type=String,Description=\"P-value from Fisher's Exact Test\">");
stdout().println("##FORMAT=<ID=RBQ,Number=1,Type=Integer,Description=\"Average quality of reference-supporting bases (qual1)\">");
stdout().println("##FORMAT=<ID=ABQ,Number=1,Type=Integer,Description=\"Average quality of variant-supporting bases (qual2)\">");
stdout().println("##FORMAT=<ID=RDF,Number=1,Type=Integer,Description=\"Depth of reference-supporting bases on forward strand (reads1plus)\">");
stdout().println("##FORMAT=<ID=RDR,Number=1,Type=Integer,Description=\"Depth of reference-supporting bases on reverse strand (reads1minus)\">");
stdout().println("##FORMAT=<ID=ADF,Number=1,Type=Integer,Description=\"Depth of variant-supporting bases on forward strand (reads2plus)\">");
stdout().println("##FORMAT=<ID=ADR,Number=1,Type=Integer,Description=\"Depth of variant-supporting bases on reverse strand (reads2minus)\">");
header();
IOUtils.copyTo(System.in, stdout());
}
else if(c=='#')
{
String line;
BufferedLineReader r=new BufferedLineReader(System.in);
while((line=r.readLine())!=null)
{
if(c!=-1)
{
line="#"+line;
c=-1;
}
if(line.startsWith("#CHROM\t"))
{
stdout().println("##varscan2samples=replace");
header();//problem with varscan:it doesn't know the sample names :-) !!
}
else
{
stdout().println(line);
}
}
r.close();
}
else
{
throw new IOException("BAD varscan input: first letter is ascii("+c+")");
}
}
catch(IOException err)
{
LOG.error(err,"Boum");
return -1;
}
return 0;
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:75,代码来源:FixVarScanMissingVCFHeader.java
注:本文中的htsjdk.samtools.util.BufferedLineReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论