本文整理匯總了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;
}