本文整理汇总了Java中htsjdk.tribble.TribbleException.MalformedFeatureFile方法的典型用法代码示例。如果您正苦于以下问题:Java TribbleException.MalformedFeatureFile方法的具体用法?Java TribbleException.MalformedFeatureFile怎么用?Java TribbleException.MalformedFeatureFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.tribble.TribbleException
的用法示例。
在下文中一共展示了TribbleException.MalformedFeatureFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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());
}
}
示例4: 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);
}
}
示例5: 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);
}
}
}
示例6: 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);
}
}
示例7: checkSorted
import htsjdk.tribble.TribbleException; //导入方法依赖的package包/类
/**
* Checks if two features of a FeatureFile are sorted
* @param feature a current feature of a file to check
* @param lastFeature a previous feature of a file to check
* @param featureFile a file, thai is being checked
*/
public static void checkSorted(Feature feature, Feature lastFeature, FeatureFile featureFile) {
if (feature.getStart() < lastFeature.getStart() && // Check if file is sorted
lastFeature.getContig().equals(feature.getContig())) {
throw new TribbleException.MalformedFeatureFile(
"Input file is not sorted by start position. \n" +
"We saw a record with a start of " + feature.getContig() + ":" +
feature.getStart() + " after a record with a start of " +
lastFeature.getContig() + ":" + lastFeature.getStart(), featureFile.getName());
}
}
示例8: testRegisterGffFail
import htsjdk.tribble.TribbleException; //导入方法依赖的package包/类
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testRegisterGffFail() throws IOException, FeatureIndexException, InterruptedException,
NoSuchAlgorithmException {
Resource resource = context.getResource("classpath:templates/Felis_catus.Felis_catus_6.2.81.gtf");
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setPath(resource.getFile().getAbsolutePath());
boolean failed = true;
try {
gffManager.registerGeneFile(request);
} catch (TribbleException.MalformedFeatureFile e) {
failed = false;
}
Assert.assertFalse("Not failed on unsorted file", failed);
/*Resource fakeIndex = context.getResource("classpath:templates/fake_gtf_index.tbi");
request.setIndexPath(fakeIndex.getFile().getAbsolutePath());
failed = true;
try {
gffManager.registerGeneFile(request);
} catch (Exception e) {
failed = false;
}
Assert.assertFalse("Not failed on unsorted file", failed);*/
}