本文整理汇总了Java中htsjdk.tribble.AsciiFeatureCodec类的典型用法代码示例。如果您正苦于以下问题:Java AsciiFeatureCodec类的具体用法?Java AsciiFeatureCodec怎么用?Java AsciiFeatureCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsciiFeatureCodec类属于htsjdk.tribble包,在下文中一共展示了AsciiFeatureCodec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: makeTabixCompressedIndex
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
private void makeTabixCompressedIndex(final File sourceFile, final File indexFile, final AsciiFeatureCodec codec,
final TabixFormat format) throws IOException {
TabixIndexCreator indexCreator = new TabixIndexCreator(format);
try (
BlockCompressedInputStream inputStream = new BlockCompressedInputStream(
new FileInputStream(sourceFile));
LittleEndianOutputStream outputStream = new LittleEndianOutputStream(
new BlockCompressedOutputStream(indexFile))
) {
long p = 0;
String line = inputStream.readLine();
while (line != null) {
//add the feature to the index
Feature decode = codec.decode(line);
if (decode != null) {
indexCreator.addFeature(decode, p);
}
// read the next line if available
p = inputStream.getFilePointer();
line = inputStream.readLine();
}
// write the index to a file
Index index = indexCreator.finalizeIndex(p);
// VERY important! either use write based on input file or pass the little endian a BGZF stream
index.write(outputStream);
}
}
开发者ID:epam,项目名称:NGB,代码行数:31,代码来源:FileManager.java
示例2: createGeneCompressedIndex
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
private void createGeneCompressedIndex(File indexFile, File file, GffCodec.GffType gffType) throws IOException {
AsciiFeatureCodec<GeneFeature> codec = new GffCodec(gffType);
TabixIndexCreator indexCreator = new TabixIndexCreator(TabixFormat.GFF);
try (
BlockCompressedInputStream inputStream = new BlockCompressedInputStream(new FileInputStream(file));
LittleEndianOutputStream outputStream = new LittleEndianOutputStream(
new BlockCompressedOutputStream(indexFile))
) {
long p = 0;
String line = inputStream.readLine();
while (line != null) {
//add the feature to the index
GeneFeature decode = codec.decode(line);
if (decode != null) {
indexCreator.addFeature(decode, p);
}
// read the next line if available
p = inputStream.getFilePointer();
line = inputStream.readLine();
}
// write the index to a file
Index index = indexCreator.finalizeIndex(p);
// VERY important! either use write based on input file or pass the little endian a BGZF stream
index.write(outputStream);
}
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:30,代码来源:FileManager.java
示例3: registerGeneFileFromUrl
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
private GeneFile registerGeneFileFromUrl(final FeatureIndexedFileRegistrationRequest request) {
Reference reference = referenceGenomeManager.loadReferenceGenome(request.getReferenceId());
Map<String, Chromosome> chromosomeMap = Utils.makeChromosomeMap(reference);
GeneFile geneFile = null;
final String extension = Utils.getFileExtension(request.getPath());
GffCodec.GffType gffType = GffCodec.GffType.forExt(extension);
AsciiFeatureCodec<GeneFeature> codec = new GffCodec(gffType);
try (FeatureReader<GeneFeature> reader = AbstractFeatureReader.getFeatureReader(request.getPath(),
request.getIndexPath(), codec, true)) {
geneFile = createGeneFile(request);
boolean hasGenes = false;
for (Map.Entry<String, Chromosome> chrEntry : chromosomeMap.entrySet()) {
CloseableIterator<GeneFeature> iterator = Utils.query(reader, chrEntry.getKey(), 1,
chrEntry.getValue().getSize());
if (iterator.hasNext()) {
hasGenes = true;
break;
}
}
Assert.isTrue(hasGenes, getMessage(MessagesConstants.ERROR_FILE_CORRUPTED_OR_EMPTY, request.getPath(),
reference.getName()));
biologicalDataItemManager.createBiologicalDataItem(geneFile.getIndex());
geneFileManager.createGeneFile(geneFile);
} catch (IOException e) {
throw new RegistrationException(getMessage(ERROR_REGISTER_FILE, request.getName()), e);
} finally {
if (geneFile != null && geneFile.getId() != null &&
!geneFileManager.geneFileExists(geneFile.getId())) {
biologicalDataItemManager.deleteBiologicalDataItem(geneFile.getBioDataItemId());
}
}
return geneFile;
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:40,代码来源:GffManager.java
示例4: openStreams
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
private void openStreams(GeneFile geneFile, IndexedFileRegistrationRequest request)
throws
IOException {
File file = new File(request.getPath());
final String extension = Utils.getFileExtension(request.getPath());
GffCodec.GffType gffType = GffCodec.GffType.forExt(extension);
AsciiFeatureCodec<GeneFeature> codec = new GffCodec(gffType);
compressedInputStream = new BlockCompressedInputStream(new FileInputStream(file));
inputStream = new PositionalBufferedStream(new FileInputStream(file));
if (geneFile.getCompressed()) {
largeScaleOS = null;
largeScaleBCOS = fileManager.makeGeneBlockCompressedOutputStream(gffType, geneFile,
GeneFileType.LARGE_SCALE);
transcriptOS = null;
transcriptBCOS = fileManager.makeGeneBlockCompressedOutputStream(gffType, geneFile,
GeneFileType.TRANSCRIPT);
writerTranscript = new BufferedWriter(new OutputStreamWriter(transcriptBCOS,
Charset.forName(CHARSET_NAME)));
writerLargeScale = new BufferedWriter(new OutputStreamWriter(largeScaleBCOS,
Charset.forName(CHARSET_NAME)));
iterator = new IndexUtils.FeatureIterator<>(file, codec);
} else {
largeScaleOS = fileManager.makePositionalOutputStream(gffType, geneFile, GeneFileType.LARGE_SCALE);
largeScaleBCOS = null;
transcriptOS = fileManager.makePositionalOutputStream(gffType, geneFile, GeneFileType.TRANSCRIPT);
transcriptBCOS = null;
writerTranscript = new BufferedWriter(new OutputStreamWriter(transcriptOS, Charset.forName(CHARSET_NAME)));
writerLargeScale = new BufferedWriter(new OutputStreamWriter(largeScaleOS, Charset.forName(CHARSET_NAME)));
iterator = new IndexUtils.FeatureIterator<>(inputStream, codec);
}
}
开发者ID:epam,项目名称:NGB,代码行数:36,代码来源:GeneRegisterer.java
示例5: SQLCodecSource
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
SQLCodecSource(DBProfile.DBTable table, AsciiFeatureCodec codec) {
super(table);
this.codec = codec;
this.binColName = table.getBinColName();
this.chromoColName = table.getChromoColName();
this.posStartColName = table.getPosStartColName();
this.posEndColName = table.getPosEndColName();
this.startColIndex = table.getStartColIndex();
this.endColIndex = table.getEndColIndex();
readHeader();
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:13,代码来源:SQLCodecSource.java
示例6: getFromTable
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
/**
* @param table
* @return a SQLCodecSource, or null if no appropriate codec found
*/
public static SQLCodecSource getFromTable(DBProfile.DBTable table) {
FeatureCodec codec = CodecFactory.getCodec("." + table.getFormat(), GenomeManager.getInstance().getCurrentGenome());
if (codec != null && codec instanceof AsciiFeatureCodec) {
return new SQLCodecSource(table, (AsciiFeatureCodec) codec);
}
return null;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:12,代码来源:SQLCodecSource.java
示例7: getInstanceFor
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
/**
* Return an parser instance appropriate the the file type. Currently the filename
* is used to determine file type, this is fragile obviously but what is the alternative?
*/
public static FeatureParser getInstanceFor(ResourceLocator locator, Genome genome) {
FeatureCodec codec = CodecFactory.getCodec(locator, genome);
if (codec != null && codec instanceof AsciiFeatureCodec) {
return new FeatureCodecParser((AsciiFeatureCodec) codec, genome);
} else {
return null;
}
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:13,代码来源:AbstractFeatureParser.java
示例8: parse
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
public static <T extends Range> List<T> parse(AsciiFeatureCodec<T> codec, String path) throws IOException {
List<T> values = new ArrayList<T>();
AbstractFeatureReader reader = AbstractFeatureReader.getFeatureReader(path, codec, false);
Iterator<T> iter = reader.iterator();
while(iter.hasNext()){
values.add(iter.next());
}
return values;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:10,代码来源:CufflinksParser.java
示例9: makeTabixIndex
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
private void makeTabixIndex(final File sourceFile, final File indexFile,
final AsciiFeatureCodec codec, final TabixFormat format) throws IOException {
TabixIndex index = IndexFactory.createTabixIndex(sourceFile, codec, format, null);
index.write(indexFile);
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:6,代码来源:FileManager.java
示例10: makeGeneIndex
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
/**
* Creates an index for gene file, determined by a {@code GeneFile} object
*
* @param geneFeatureClass {@code Class<? extends GeneFeature>} defines gene file type, that will be indexed
* @param geneFile {@code GeneFile} that represents a file in the system
*/
public void makeGeneIndex(Class<? extends GeneFeature> geneFeatureClass, final GeneFile geneFile, final GeneFileType
type) throws IOException {
GffCodec.GffType gffType = GffCodec.GffType.forGeneFile(geneFeatureClass, geneFile);
final Map<String, Object> params = new HashMap<>();
params.put(DIR_ID.name(), geneFile.getId());
params.put(USER_ID.name(), geneFile.getCreatedBy());
params.put(GENE_EXTENSION.name(), gffType.getExtensions()[0]);
File file;
File indexFile;
switch (type) {
case ORIGINAL:
file = new File(geneFile.getPath());
indexFile = new File(toRealPath(substitute(GENE_INDEX, params)));
break;
case LARGE_SCALE:
file = new File(toRealPath(substitute(GENE_LARGE_SCALE_FILE, params)));
indexFile = new File(toRealPath(substitute(GENE_LARGE_SCALE_INDEX, params)));
break;
case TRANSCRIPT:
file = new File(toRealPath(substitute(GENE_TRANSCRIPT_FILE, params)));
indexFile = new File(toRealPath(substitute(GENE_TRANSCRIPT_INDEX, params)));
break;
default:
throw new UnsupportedGeneFileTypeException(type);
}
LOGGER.info(getMessage(MessagesConstants.INFO_GENE_INDEX_WRITING, indexFile.getAbsolutePath()));
if (geneFile.getCompressed()) {
createGeneCompressedIndex(indexFile, file, gffType);
} else {
AsciiFeatureCodec<GeneFeature> codec = new GffCodec(gffType);
TabixIndex index = IndexUtils.createTabixIndex(file, codec, TabixFormat.GFF);
index.write(indexFile);
}
if (type.equals(GeneFileType.ORIGINAL)) {
BiologicalDataItem indexItem = new BiologicalDataItem();
indexItem.setCreatedDate(new Date());
indexItem.setPath(indexFile.getAbsolutePath());
indexItem.setFormat(BiologicalDataItemFormat.GENE_INDEX);
indexItem.setType(BiologicalDataItemResourceType.FILE);
indexItem.setName("");
indexItem.setCreatedBy(AuthUtils.getCurrentUserId());
geneFile.setIndex(indexItem);
}
}
开发者ID:epam,项目名称:NGB,代码行数:57,代码来源:FileManager.java
示例11: VCFWrapperCodec
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
public VCFWrapperCodec(AsciiFeatureCodec wrappedCodec, Genome genome) {
super(VCFVariant.class);
this.wrappedCodec = wrappedCodec;
this.genome = genome;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:6,代码来源:VCFWrapperCodec.java
示例12: FeatureCodecParser
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
public FeatureCodecParser(AsciiFeatureCodec codec, Genome genome) {
this.codec = codec;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:4,代码来源:FeatureCodecParser.java
示例13: DecoderWrapper
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
public DecoderWrapper(AsciiFeatureCodec<T> wrappedCodec) {
this.wrappedCodec = wrappedCodec;
this.lineFeatureDecoder = this;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:5,代码来源:AsciiDecoder.java
示例14: RenameDecoder
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
public RenameDecoder(AsciiFeatureCodec<T> featureCodec){
super(new AsciiDecoder.DecoderWrapper<T>(featureCodec));
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:4,代码来源:RenameDecoder.java
示例15: makeGeneReader
import htsjdk.tribble.AsciiFeatureCodec; //导入依赖的package包/类
/**
* Create a {@code AbstractFeatureReader<GeneFeature, LineIterator>} reader for given file, optionally
* uses an index
*
* @param path a path to gene file with .gff, .gtf, .gff.gz or .gtf.gz extensions
* @param index a path to index file whith .tbi extension, set null if no index should be used
* @param useIndex {@code boolean} determines if index should be used
* @return {@code AbstractFeatureReader<GeneFeature, LineIterator>} a reader to work with gene file
*/
public AbstractFeatureReader<GeneFeature, LineIterator> makeGeneReader(String path, String index,
boolean useIndex) {
String extension = getGeneFileExtension(path);
Assert.notNull(extension, getMessage(MessagesConstants.ERROR_UNSUPPORTED_GENE_FILE_EXTESION));
AsciiFeatureCodec<GeneFeature> codec = new GffCodec(GffCodec.GffType.forExt(extension));
return AbstractFeatureReader.getFeatureReader(path, index, codec, useIndex);
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:18,代码来源:FileManager.java
注:本文中的htsjdk.tribble.AsciiFeatureCodec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论