本文整理汇总了Java中htsjdk.variant.vcf.VCFCompoundHeaderLine类的典型用法代码示例。如果您正苦于以下问题:Java VCFCompoundHeaderLine类的具体用法?Java VCFCompoundHeaderLine怎么用?Java VCFCompoundHeaderLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VCFCompoundHeaderLine类属于htsjdk.variant.vcf包,在下文中一共展示了VCFCompoundHeaderLine类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isUniqueHeaderLine
import htsjdk.variant.vcf.VCFCompoundHeaderLine; //导入依赖的package包/类
private static boolean isUniqueHeaderLine(VCFHeaderLine line, Set<VCFHeaderLine> currentSet) {
if ( !(line instanceof VCFCompoundHeaderLine) )
return true;
for ( VCFHeaderLine hLine : currentSet ) {
if ( hLine instanceof VCFCompoundHeaderLine && ((VCFCompoundHeaderLine)line).sameLineTypeAndName((VCFCompoundHeaderLine)hLine) )
return false;
}
return true;
}
示例2: postProcessIndexEntries
import htsjdk.variant.vcf.VCFCompoundHeaderLine; //导入依赖的package包/类
/**
* Post processes fetched VCF index entries to add gene information and split them to resolve ambiguous fields
* @param entries list of entries to process
* @param geneFiles list of {@link GeneFile}s to fetch gene information from
* @param chromosome a {@code Chromosome}, from which entries came
* @param vcfHeader a header of VCF file
* @param vcfReader a reader for VCF file
* @return a list of post-processed index entries, ready to write into index
* @throws GeneReadingException if an exception was thrown when reading genes information
*/
public List<VcfIndexEntry> postProcessIndexEntries(List<VcfIndexEntry> entries, List<GeneFile> geneFiles,
Chromosome chromosome, VCFHeader vcfHeader, VcfFileReader vcfReader)
throws GeneReadingException {
List<VcfIndexEntry> processedEntries = new ArrayList<>();
int start = chromosome.getSize();
int end = 0;
for (FeatureIndexEntry entry : entries) {
start = Math.min(start, entry.getStartIndex());
end = Math.max(end, entry.getEndIndex());
}
Map<GeneFile, NggbIntervalTreeMap<List<Gene>>> intervalMapCache = new HashMap<>();
for (VcfIndexEntry indexEntry : entries) {
String geneIdsString = null;
String geneNamesString = null;
Set<VariationGeneInfo> geneIds = Collections.emptySet();
for (GeneFile geneFile : geneFiles) {
if (!intervalMapCache.containsKey(geneFile)) {
intervalMapCache.put(geneFile, loadGenesIntervalMap(geneFile, start, end, chromosome));
}
NggbIntervalTreeMap<List<Gene>> intervalMap = intervalMapCache.get(geneFile);
geneIds = fetchGeneIdsFromBatch(intervalMap, indexEntry.getStartIndex(), indexEntry.getEndIndex(),
chromosome);
geneIdsString = geneIds.stream().map(i -> i.geneId).collect(Collectors.joining(", "));
geneNamesString = geneIds.stream().map(i -> i.geneName).collect(Collectors.joining(", "));
indexEntry.setExon(geneIds.stream().anyMatch(i -> i.isExon));
}
Set<VariationType> types = new HashSet<>();
for (int i = 0; i < indexEntry.getVariantContext().getAlternateAlleles().size(); i++) {
Variation variation = vcfReader.createVariation(indexEntry.getVariantContext(), vcfHeader, i);
types.add(variation.getType());
}
List<String> ambiguousInfoFields = vcfHeader.getInfoHeaderLines().stream()
.filter(l -> l.getCount(indexEntry.getVariantContext()) > 1)
.map(VCFCompoundHeaderLine::getID)
.collect(Collectors.toList());
List<VcfIndexEntry> simplifiedEntries = simplifyVcfIndexEntries(indexEntry, indexEntry.getVariantContext(),
geneIds, types, geneIdsString, geneNamesString);
processedEntries.addAll(splitAmbiguousInfoFields(simplifiedEntries, ambiguousInfoFields));
}
return processedEntries;
}
示例3: postProcessIndexEntries
import htsjdk.variant.vcf.VCFCompoundHeaderLine; //导入依赖的package包/类
/**
* Post processes fetched VCF index entries to add gene information and split them to resolve ambiguous fields
* @param entries list of entries to process
* @param geneFiles list of {@link GeneFile}s to fetch gene information from
* @param chromosome a {@code Chromosome}, from which entries came
* @param vcfHeader a header of VCF file
* @param vcfReader a reader for VCF file
* @return a list of post-processed index entries, ready to write into index, must be cleared
* after use because disk-based implementation could be returned
* @throws GeneReadingException if an exception was thrown when reading genes information
*/
public List<VcfIndexEntry> postProcessIndexEntries(List<VcfIndexEntry> entries, List<GeneFile> geneFiles,
Chromosome chromosome, VCFHeader vcfHeader, VcfFileReader vcfReader)
throws GeneReadingException {
List<VcfIndexEntry> processedEntries =
new DiskBasedList<VcfIndexEntry>(maxVcfIndexEntriesInMemory / 2).adaptToList();
int start = chromosome.getSize();
int end = 0;
for (FeatureIndexEntry entry : entries) {
start = Math.min(start, entry.getStartIndex());
end = Math.max(end, entry.getEndIndex());
}
Map<GeneFile, NggbIntervalTreeMap<List<Gene>>> intervalMapCache = new HashMap<>();
for (VcfIndexEntry indexEntry : entries) {
String geneIdsString = null;
String geneNamesString = null;
Set<VariationGeneInfo> geneIds = Collections.emptySet();
for (GeneFile geneFile : geneFiles) {
if (!intervalMapCache.containsKey(geneFile)) {
intervalMapCache.put(geneFile, loadGenesIntervalMap(geneFile, start, end, chromosome));
}
NggbIntervalTreeMap<List<Gene>> intervalMap = intervalMapCache.get(geneFile);
geneIds = fetchGeneIdsFromBatch(intervalMap, indexEntry.getStartIndex(), indexEntry.getEndIndex(),
chromosome);
geneIdsString = geneIds.stream().map(i -> i.geneId).collect(Collectors.joining(", "));
geneNamesString = geneIds.stream().map(i -> i.geneName).collect(Collectors.joining(", "));
indexEntry.setExon(geneIds.stream().anyMatch(i -> i.isExon));
}
Set<VariationType> types = new HashSet<>();
for (int i = 0; i < indexEntry.getVariantContext().getAlternateAlleles().size(); i++) {
Variation variation = vcfReader.createVariation(indexEntry.getVariantContext(), vcfHeader, i);
types.add(variation.getType());
}
List<String> ambiguousInfoFields = vcfHeader.getInfoHeaderLines().stream()
.filter(l -> l.getCount(indexEntry.getVariantContext()) > 1
&& !isVariableLength(l.getCountType()))
.map(VCFCompoundHeaderLine::getID).collect(Collectors.toList());
List<VcfIndexEntry> simplifiedEntries = simplifyVcfIndexEntries(indexEntry, indexEntry.getVariantContext(),
geneIds, types, geneIdsString, geneNamesString);
processedEntries.addAll(splitAmbiguousInfoFields(simplifiedEntries, ambiguousInfoFields));
}
return processedEntries;
}