本文整理汇总了Java中htsjdk.samtools.SAMSequenceDictionary.assertSameDictionary方法的典型用法代码示例。如果您正苦于以下问题:Java SAMSequenceDictionary.assertSameDictionary方法的具体用法?Java SAMSequenceDictionary.assertSameDictionary怎么用?Java SAMSequenceDictionary.assertSameDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SAMSequenceDictionary
的用法示例。
在下文中一共展示了SAMSequenceDictionary.assertSameDictionary方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBestSequenceDictionary_FromVariantReference
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testBestSequenceDictionary_FromVariantReference() throws Exception {
final GATKTool tool = new TestGATKToolWithFeatures();
final CommandLineParser clp = new CommandLineArgumentParser(tool);
final File vcfFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/example_variants_noSequenceDict.vcf");
final String[] args = {"-V", vcfFile.getCanonicalPath(), "-R", hg19MiniReference};
clp.parseArguments(System.out, args);
tool.onStartup();
// make sure we DON'T get the seq dictionary from the VCF index, and instead get the one from
// the reference when its better
final SAMSequenceDictionary toolDict = tool.getBestAvailableSequenceDictionary();
Assert.assertFalse(toolDict.getSequences().stream().allMatch(seqRec -> seqRec.getSequenceLength() == 0));
SAMSequenceDictionary refDict = new ReferenceFileSource(IOUtils.getPath(hg19MiniReference)).getSequenceDictionary();
toolDict.assertSameDictionary(refDict);
refDict.assertSameDictionary(toolDict);
Assert.assertEquals(toolDict, refDict);
}
示例2: testBestSequenceDictionary_fromReads
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testBestSequenceDictionary_fromReads() throws Exception {
final GATKTool tool = new TestGATKToolWithReads();
final CommandLineParser clp = new CommandLineArgumentParser(tool);
final File bamFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/reads_data_source_test1.bam");
final String[] args = {"-I", bamFile.getCanonicalPath()};
clp.parseArguments(System.out, args);
tool.onStartup();
//read the dict back in and compare to bam dict
final SAMSequenceDictionary toolDict = tool.getBestAvailableSequenceDictionary();
try(final SamReader open = SamReaderFactory.makeDefault().open(bamFile)) {
final SAMSequenceDictionary bamDict = open.getFileHeader().getSequenceDictionary();
toolDict.assertSameDictionary(bamDict);
bamDict.assertSameDictionary(toolDict);
Assert.assertEquals(toolDict, bamDict);
}
}
示例3: testBestSequenceDictionary_fromReadsAndReference
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testBestSequenceDictionary_fromReadsAndReference() throws Exception {
final GATKTool tool = new TestGATKToolWithReads();
final CommandLineParser clp = new CommandLineArgumentParser(tool);
final File bamFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/reads_data_source_test1.bam");
final String fastaFile = hg19MiniReference;
final String[] args = {"-I", bamFile.getCanonicalPath(),
"-R", fastaFile};
clp.parseArguments(System.out, args);
tool.onStartup();
//read the dict back in and compare to reference dict
final SAMSequenceDictionary toolDict = tool.getBestAvailableSequenceDictionary();
final SAMSequenceDictionary fastaDict = new IndexedFastaSequenceFile(new File(fastaFile)).getSequenceDictionary();
toolDict.assertSameDictionary(fastaDict);
fastaDict.assertSameDictionary(toolDict);
Assert.assertEquals(toolDict, fastaDict);
}
示例4: testBestSequenceDictionary_fromVariants
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testBestSequenceDictionary_fromVariants() throws Exception {
final GATKTool tool = new TestGATKToolWithFeatures();
final CommandLineParser clp = new CommandLineArgumentParser(tool);
final File vcfFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/feature_data_source_test_withSequenceDict.vcf");
final String[] args = {"--mask", vcfFile.getCanonicalPath()};
clp.parseArguments(System.out, args);
tool.onStartup();
//read the dict back in and compare to vcf dict
final SAMSequenceDictionary toolDict = tool.getBestAvailableSequenceDictionary();
try(final VCFFileReader reader = new VCFFileReader(vcfFile)) {
final SAMSequenceDictionary vcfDict = reader.getFileHeader().getSequenceDictionary();
toolDict.assertSameDictionary(vcfDict);
vcfDict.assertSameDictionary(toolDict);
Assert.assertEquals(toolDict, vcfDict);
}
}
示例5: collectFileReadersAndHeaders
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
private void collectFileReadersAndHeaders(final List<String> sampleList, SAMSequenceDictionary samSequenceDictionary) {
for (final File input : INPUT) {
final VCFFileReader in = new VCFFileReader(input, false);
final VCFHeader header = in.getFileHeader();
final SAMSequenceDictionary dict = in.getFileHeader().getSequenceDictionary();
if (dict == null || dict.isEmpty()) {
if (null == samSequenceDictionary) {
throw new IllegalArgumentException("Sequence dictionary was missing or empty for the VCF: " + input.getAbsolutePath() + " Please add a sequence dictionary to this VCF or specify SEQUENCE_DICTIONARY.");
}
header.setSequenceDictionary(samSequenceDictionary);
} else {
if (null == samSequenceDictionary) {
samSequenceDictionary = dict;
} else {
try {
samSequenceDictionary.assertSameDictionary(dict);
} catch (final AssertionError e) {
throw new IllegalArgumentException(e);
}
}
}
if (sampleList.isEmpty()) {
sampleList.addAll(header.getSampleNamesInOrder());
} else {
if (!sampleList.equals(header.getSampleNamesInOrder())) {
throw new IllegalArgumentException("Input file " + input.getAbsolutePath() + " has sample names that don't match the other files.");
}
}
inputReaders.add(in);
inputHeaders.add(header);
}
}
示例6: assertFastaDictionaryContent
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
private void assertFastaDictionaryContent(final Path dictPath, final SAMSequenceDictionary dictionary)
throws IOException, GeneralSecurityException, URISyntaxException {
final ReadsDataSource readsDataSource = new ReadsDataSource(dictPath);
final SAMFileHeader actualHeader = readsDataSource.getHeader();
final SAMSequenceDictionary actualDictionary = actualHeader.getSequenceDictionary();
dictionary.assertSameDictionary(actualDictionary);
}
示例7: assertSameSamplesAndValidOrdering
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/** Validates that all headers contain the same set of genotyped samples and that files are in order by position of first record. */
private static void assertSameSamplesAndValidOrdering(final List<File> inputFiles) {
final VCFHeader header = new VCFFileReader(inputFiles.get(0), false).getFileHeader();
final SAMSequenceDictionary dict = header.getSequenceDictionary();
final VariantContextComparator comparator = new VariantContextComparator(header.getSequenceDictionary());
final List<String> samples = header.getGenotypeSamples();
File lastFile = null;
VariantContext lastContext = null;
for (final File f : inputFiles) {
final VCFFileReader in = new VCFFileReader(f, false);
try {
dict.assertSameDictionary(in.getFileHeader().getSequenceDictionary());
} catch (final AssertionError e) {
log.error("File #1: " + inputFiles.get(0));
log.error("File #2: " + f);
throw e;
}
final List<String> theseSamples = in.getFileHeader().getGenotypeSamples();
if (!samples.equals(theseSamples)) {
final SortedSet<String> s1 = new TreeSet<String>(samples);
final SortedSet<String> s2 = new TreeSet<String>(theseSamples);
s1.removeAll(theseSamples);
s2.removeAll(samples);
throw new IllegalArgumentException("VCFs do not have identical sample lists." +
" Samples unique to first file: " + s1 + ". Samples unique to " + f.getAbsolutePath() + ": " + s2 + ".");
}
final CloseableIterator<VariantContext> variantIterator = in.iterator();
if (variantIterator.hasNext()) {
final VariantContext currentContext = variantIterator.next();
if (lastContext != null && comparator.compare(lastContext, currentContext) >= 0) {
throw new IllegalArgumentException("First record in file " + f.getAbsolutePath() + " is not after first record in " +
"previous file " + lastFile.getAbsolutePath());
}
lastContext = currentContext;
lastFile = f;
}
CloserUtil.close(in);
}
}
示例8: assertSameSamplesAndValidOrdering
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/** Validates that all headers contain the same set of genotyped samples and that files are in order by position of first record. */
private static void assertSameSamplesAndValidOrdering(final List<Path> inputFiles, final boolean disableContigOrderingCheck) {
final VCFHeader firstHeader = getHeader(inputFiles.get(0));
final SAMSequenceDictionary dict = firstHeader.getSequenceDictionary();
if ( dict == null) {
throw new UserException.BadInput("The first VCF specified is missing the required sequence dictionary. " +
"This is required to perform validation. You can skip this validation " +
"using --"+IGNORE_SAFETY_CHECKS_LONG_NAME +" but ignoring safety checks " +
"can result in invalid output.");
}
final VariantContextComparator comparator = new VariantContextComparator(dict);
final List<String> samples = firstHeader.getGenotypeSamples();
Path lastFile = null;
VariantContext lastContext = null;
for (final Path f : inputFiles) {
final FeatureReader<VariantContext> in = getReaderFromVCFUri(f, 0);
final VCFHeader header = (VCFHeader)in.getHeader();
dict.assertSameDictionary(header.getSequenceDictionary());
final List<String> theseSamples = header.getGenotypeSamples();
if (!samples.equals(theseSamples)) {
final SortedSet<String> s1 = new TreeSet<>(samples);
final SortedSet<String> s2 = new TreeSet<>(theseSamples);
s1.removeAll(theseSamples);
s2.removeAll(samples);
throw new IllegalArgumentException("VCFs do not have identical sample lists." +
" Samples unique to first file: " + s1 + ". Samples unique to " + f.toUri().toString() + ": " + s2 + ".");
}
try(final CloseableIterator<VariantContext> variantIterator = in.iterator()) {
if (variantIterator.hasNext()) {
final VariantContext currentContext = variantIterator.next();
if (lastContext != null) {
if ( disableContigOrderingCheck ) {
if ( lastContext.getContig().equals(currentContext.getContig()) && lastContext.getStart() >= currentContext.getStart() ) {
throw new IllegalArgumentException(
"First record in file " + f.toUri().toString() + " is not after first record in " +
"previous file " + lastFile.toUri().toString());
}
}
else {
if ( comparator.compare(lastContext, currentContext) >= 0 ) {
throw new IllegalArgumentException(
"First record in file " + f.toUri().toString() + " is not after first record in " +
"previous file " + lastFile.toUri().toString());
}
}
}
lastContext = currentContext;
lastFile = f;
}
} catch (final IOException e) {
throw new UserException.CouldNotReadInputFile(f, e.getMessage(), e);
}
CloserUtil.close(in);
}
}