当前位置: 首页>>代码示例>>Java>>正文


Java TribbleException类代码示例

本文整理汇总了Java中htsjdk.tribble.TribbleException的典型用法代码示例。如果您正苦于以下问题:Java TribbleException类的具体用法?Java TribbleException怎么用?Java TribbleException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TribbleException类属于htsjdk.tribble包,在下文中一共展示了TribbleException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: determineReferenceAllele

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
/**
 * Determines the common reference allele
 *
 * @param VCs    the list of VariantContexts
 * @param loc    if not null, ignore records that do not begin at this start location
 * @return possibly null Allele
 */
public static Allele determineReferenceAllele(final List<VariantContext> VCs, final GenomeLoc loc) {
    Allele ref = null;

    for ( final VariantContext vc : VCs ) {
        if ( contextMatchesLoc(vc, loc) ) {
            final Allele myRef = vc.getReference();
            if ( ref == null || ref.length() < myRef.length() )
                ref = myRef;
            else if ( ref.length() == myRef.length() && ! ref.equals(myRef) )
                throw new TribbleException(String.format("The provided variant file(s) have inconsistent references for the same position(s) at %s:%d, %s vs. %s", vc.getChr(), vc.getStart(), ref, myRef));
        }
    }

    return ref;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:23,代码来源:GATKVariantContextUtils.java

示例2: createStream

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
private InputStream createStream(final FileInputStream fileStream) throws IOException {
    // if this looks like a block compressed file and it in fact is, we will use it
    // otherwise we will use the file as is
    if (!AbstractFeatureReader.hasBlockCompressedExtension(inputFile)) {
        return fileStream;
    }

    // make a buffered stream to test that this is in fact a valid block compressed file
    final int bufferSize = Math.max(Defaults.BUFFER_SIZE,
            BlockCompressedStreamConstants.MAX_COMPRESSED_BLOCK_SIZE);
    final BufferedInputStream bufferedStream = new BufferedInputStream(fileStream, bufferSize);

    if (!BlockCompressedInputStream.isValidFile(bufferedStream)) {
        throw new TribbleException.MalformedFeatureFile(
                "Input file is not in valid block compressed format.", inputFile.getAbsolutePath());
    }

    final ISeekableStreamFactory ssf = SeekableStreamFactory.getInstance();
    // if we got here, the file is valid, make a SeekableStream for the BlockCompressedInputStream
    // to read from
    final SeekableStream seekableStream =
            ssf.getBufferedStream(ssf.getStreamFor(inputFile.getAbsolutePath()));
    return new BlockCompressedInputStream(seekableStream);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:25,代码来源:FeatureIterator.java

示例3: determineReferenceAllele

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
/**
 * Determines the common reference allele
 *
 * @param VCs
 *            the list of VariantContexts
 * @param loc
 *            if not null, ignore records that do not begin at this start
 *            location
 * @return possibly null Allele
 */
public static Allele determineReferenceAllele(final List<VariantContext> VCs, final GenomeLocation loc) {
	Allele ref = null;

	for (final VariantContext vc : VCs) {
		if (contextMatchesLocation(vc, loc)) {
			final Allele myRef = vc.getReference();
			if (ref == null || ref.length() < myRef.length())
				ref = myRef;
			else if (ref.length() == myRef.length() && !ref.equals(myRef))
				throw new TribbleException(String.format(
						"The provided variant file(s) have inconsistent references for the same position(s) at %s:%d, %s vs. %s",
						vc.getContig(), vc.getStart(), ref, myRef));
		}
	}

	return ref;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:28,代码来源:GaeaVariantContextUtils.java

示例4: processVCF

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
private static Collection<EligibilityReport> processVCF(final String patient, final boolean isGermline, final File vcf,
        final BachelorEligibility eligibility) {

    final EligibilityReport.ReportType type =
            isGermline ? EligibilityReport.ReportType.GERMLINE_MUTATION : EligibilityReport.ReportType.SOMATIC_MUTATION;
    LOGGER.info("process {} vcf: {}", type, vcf.getPath());

    try (final VCFFileReader reader = new VCFFileReader(vcf, true)) {
        // TODO: always correct? germline has R,T somatic has just T
        final String sample = reader.getFileHeader().getGenotypeSamples().get(0);
        return eligibility.processVCF(patient, sample, type, reader);
    } catch (final TribbleException e) {
        LOGGER.error("error with VCF file {}: {}", vcf.getPath(), e.getMessage());
        return Collections.emptyList();
    }
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:17,代码来源:BachelorApplication.java

示例5: decodeLine

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
private VariantContext decodeLine(final String line, final boolean includeGenotypes) {
    // the same line reader is not used for parsing the header and parsing lines, if we see a #, we've seen a header line
    if (line.startsWith(VCFHeader.HEADER_INDICATOR)) return null;

    // our header cannot be null, we need the genotype sample names and counts
    if (header == null) throw new TribbleException("VCF Header cannot be null when decoding a record");

    if (parts == null)
        parts = new String[Math.min(header.getColumnCount(), NUM_STANDARD_FIELDS+1)];

    final int nParts = ParsingUtils.split(line, parts, VCFConstants.FIELD_SEPARATOR_CHAR, true);

    // if we have don't have a header, or we have a header with no genotyping data check that we
    // have eight columns.  Otherwise check that we have nine (normal columns + genotyping data)
    if (( (header == null || !header.hasGenotypingData()) && nParts != NUM_STANDARD_FIELDS) ||
            (header != null && header.hasGenotypingData() && nParts != (NUM_STANDARD_FIELDS + 1)) )
        throw new TribbleException("Line " + lineNo + ": there aren't enough columns for line " + line + " (we expected " + (header == null ? NUM_STANDARD_FIELDS : NUM_STANDARD_FIELDS + 1) +
                " tokens, and saw " + nParts + " )");

    return parseVCFLine(parts, includeGenotypes);
}
 
开发者ID:rkataine,项目名称:BasePlayer,代码行数:22,代码来源:OwnVCFCodec.java

示例6: validVersion

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
private static boolean validVersion(File filepath) throws IOException {
  BufferedReader reader = Files.newBufferedReader(filepath.toPath(), UTF_8);

  // The first line must be the header
  String firstLine = reader.readLine();
  reader.close();

  try {
    VCFHeaderVersion version = VCFHeaderVersion.getHeaderVersion(firstLine);

    // If the version is greater than or equal to 4.2, we cannot handle it
    if (version.isAtLeastAsRecentAs(VCFHeaderVersion.VCF4_2)) {
      return false;
    }
  } catch (TribbleException.InvalidHeader msg) {
    throw new IOException(msg);
  }

  return true;
}
 
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:21,代码来源:VcfToVariant.java

示例7: doInBackground

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
@Override
protected Index doInBackground() throws Exception {
    int binSize = IgvTools.LINEAR_BIN_SIZE;
    FeatureCodec codec = CodecFactory.getCodec(file.getAbsolutePath(), GenomeManager.getInstance().getCurrentGenome());
    if (codec != null) {
        try {
            Index index = IndexFactory.createLinearIndex(file, codec, binSize);
            if (index != null) {
                IgvTools.writeTribbleIndex(index, idxFile.getAbsolutePath());
            }
            return index;
        } catch (TribbleException.MalformedFeatureFile e) {
            StringBuffer buf = new StringBuffer();
            buf.append("<html>Files must be sorted by start position prior to indexing.<br>");
            buf.append(e.getMessage());
            buf.append("<br><br>Note: igvtools can be used to sort the file, select \"File > Run igvtools...\".");
            MessageUtils.showMessage(buf.toString());
        }
    } else {
        throw new DataLoadException("Unknown File Type", file.getAbsolutePath());
    }
    return null;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:IndexCreatorDialog.java

示例8: doWork

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
@Override
protected Object doWork() {
    final FeatureCodec<? extends Feature, ?> codec = FeatureManager.getCodecForFile(inputBedFile);
    final Class<? extends Feature> featureType = codec.getFeatureType();
    if (BEDFeature.class.isAssignableFrom(featureType)) {
        final FeatureDataSource<? extends BEDFeature> source = new FeatureDataSource<>(inputBedFile);
        try {
            final List<Target> targets = StreamSupport.stream(source.spliterator(), false).map(ConvertBedToTargetFile::createTargetFromBEDFeature)
                    .collect(Collectors.toList());
            TargetWriter.writeTargetsToFile(outFile, targets);
        } catch (final TribbleException e) {
            throw new UserException.BadInput(String.format("'%s' has a .bed extension but does not seem to be a valid BED file.", inputBedFile.getAbsolutePath()));
        }
    } else {
        throw new UserException.BadInput(String.format("'%s' does not seem to be a BED file.", inputBedFile.getAbsolutePath()));
    }
    return "SUCCESS";
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:19,代码来源:ConvertBedToTargetFile.java

示例9: determineReferenceAllele

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
/**
 * Determines the common reference allele
 *
 * @param VCs    the list of VariantContexts
 * @param loc    if not null, ignore records that do not begin at this start location
 * @return possibly null Allele
 */
public static Allele determineReferenceAllele(final List<VariantContext> VCs, final Locatable loc) {
    Allele ref = null;

    for ( final VariantContext vc : VCs ) {
        if ( contextMatchesLoc(vc, loc) ) {
            final Allele myRef = vc.getReference();
            if ( ref == null || ref.length() < myRef.length() )
                ref = myRef;
            else if ( ref.length() == myRef.length() && ! ref.equals(myRef) )
                throw new TribbleException(String.format("The provided variant file(s) have inconsistent references for the same position(s) at %s:%d, %s vs. %s", vc.getContig(), vc.getStart(), ref, myRef));
        }
    }

    return ref;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:23,代码来源:GATKVariantContextUtils.java

示例10: testVcf

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
private void testVcf(File f,InputStream in) throws IOException,TribbleException
 	{
 	long n=0;
 	VcfIterator iter=new VcfIteratorImpl(in);
 	iter.getHeader();
 	while(iter.hasNext() &&  (NUM<0 || n<NUM))
 		{
 		iter.next();
 		++n;
 		}
 	if(n==0)
{
 		emptyFile(f);
}
 	iter.close();
 	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:17,代码来源:FindCorruptedFiles.java

示例11: checkSorted

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
private void checkSorted(VcfFile vcfFile, VariantContext variantContext, VariantContext lastFeature) {
    if (lastFeature != null && variantContext.getStart() < lastFeature.getStart() &&
            lastFeature.getContig().equals(variantContext.getContig())) {
        throw new TribbleException.MalformedFeatureFile("Input file is not sorted by start position. \n" +
                "We saw a record with a start of " + variantContext.getContig()
                + ":" + variantContext.getStart()
                + " after a record with a start of "
                + lastFeature.getContig() + ":" + lastFeature
                .getStart(), vcfFile.getName());
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:12,代码来源:VcfManager.java

示例12: readHeader

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
/**
 * Some codecs,  e.g. VCF files,  need the header to decode features.  This is a rather poor design,
 * the internal header is set as a side-affect of reading it, but we have to live with it for now.
 */
private FeatureCodecHeader readHeader() {
    try {
        final S sourceFromStream = this.codec.makeSourceFromStream(initStream(inputFile, 0));
        final FeatureCodecHeader header = this.codec.readHeader(sourceFromStream);
        codec.close(sourceFromStream);
        return header;
    } catch (IOException e) {
        LOGGER.error(MessageHelper.getMessage(MessagesConstants.ERROR_FILE_HEADER_READING), e);
        throw new TribbleException.InvalidHeader(e.getMessage());
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:16,代码来源:FeatureIterator.java

示例13: readNextFeature

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
/**
 * Read the next feature from the stream
 *
 * @throws TribbleException.MalformedFeatureFile
 */
private void readNextFeature() {
    cachedPosition = ((LocationAware) source).getPosition();
    try {
        nextFeature = null;
        while (nextFeature == null && !codec.isDone(source)) {
            nextFeature = codec.decodeLoc(source);
        }
    } catch (final IOException e) {
        throw new TribbleException.MalformedFeatureFile("Unable to read a line from the file",
                inputFile.getAbsolutePath(), e);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:18,代码来源:FeatureIterator.java

示例14: checkSorted

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
public static void checkSorted(final File inputFile, final Feature lastFeature,
        final Feature currentFeature, Map<String, Feature> visitedChromos) {
    // if the last currentFeature is after the current currentFeature, exception out
    if (lastFeature != null && currentFeature.getStart() < lastFeature.getStart() && lastFeature
            .getContig().equals(currentFeature.getContig())) {
        throw new TribbleException.MalformedFeatureFile(
                "Input file is not sorted by start position. \n"
                        + "We saw a record with a start of " + currentFeature.getContig() + ":"
                        + currentFeature.getStart() + " after a record with a start of "
                        + lastFeature.getContig() + ":" + lastFeature.getStart(),
                inputFile.getAbsolutePath());
    }

    //should only visit chromosomes once
    final String curChr = currentFeature.getContig();
    final String lastChr = lastFeature != null ? lastFeature.getContig() : null;
    if (!curChr.equals(lastChr)) {
        if (visitedChromos.containsKey(curChr)) {
            String msg = "Input file must have contiguous chromosomes.";
            throw new TribbleException.MalformedFeatureFile(msg,
                    inputFile.getAbsolutePath());
        } else {
            visitedChromos.put(curChr, currentFeature);
        }
    }

}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:28,代码来源:IndexUtils.java

示例15: readHeader

import htsjdk.tribble.TribbleException; //导入依赖的package包/类
private FeatureCodecHeader readHeader(PositionalBufferedStream stream) {
    try {
        final S sourceFromStream = this.codec.makeSourceFromStream(stream);
        return this.codec.readHeader(sourceFromStream);
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
        throw new TribbleException.InvalidHeader(e.getMessage());
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:10,代码来源:IndexUtils.java


注:本文中的htsjdk.tribble.TribbleException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。