public class ReadMappingUtils
@Nullable public static kotlin.Array[] encodeHapIdMapping(@NotNull java.util.Map<java.util.List,java.lang.Integer> hapIdMapping)
Function to encode the HapId Map into a byte array and compress it.
@Nullable public static kotlin.Array[] encodeHapIdsAsBitSet(@NotNull java.util.Map<java.util.List,java.lang.Integer> hapIdMapping, @NotNull java.util.Map<java.lang.Integer,? extends net.maizegenetics.pangenome.api.ReferenceRange> hapIdToRefRangeMap, @NotNull java.util.Map<java.lang.Integer,? extends java.util.Map<java.lang.Integer,java.lang.Integer>> refRangeToHapIdMap)
Encodes haplotypeSet counts by first translating each haplotypeSet into a BitSet.
hapIdMapping
maps a list of haplotype ids to their counts.
hapIdToRefRangeMap
is a map of haplotype id to ReferenceRange.
refRangeToHapIdMap
maps refRangeId to a map of haplotype id to its index,
where the index represents the order of the haplotype ids in that ReferenceRange,
The haplotype ids in each reference range are indexed in ascending order.
hapIdMapping
,
hapIdToRefRangeMap
,
refRangeToHapIdMap
@NotNull public static java.util.List<java.lang.Integer> bitSetToIntList(@NotNull java.util.BitSet bitSet)
@NotNull public static java.util.Map<java.util.List,java.lang.Integer> decodeHapIdMapping(@NotNull kotlin.Array[] encodedReadMapping)
Function to decode the HapId byte array into the Mapping to be used by Path Finding.
public static void exportReadMapping(@NotNull java.lang.String outputFileName, @NotNull java.util.Map<java.util.List,java.lang.Integer> hapIdMapping, @NotNull java.lang.String taxon, @NotNull java.lang.String fileGroupName, @NotNull java.lang.String methodName, @NotNull java.lang.String methodDescription)
Function to export the read mapping files to disk. This is mostly for debugging purposes.
@NotNull public static com.google.common.collect.Multimap<net.maizegenetics.pangenome.api.ReferenceRange,net.maizegenetics.pangenome.hapCalling.HapIdSetCount> readInReadMappings(@NotNull java.lang.String inputFileName, @NotNull HaplotypeGraph graph)
@NotNull public static java.util.Map<java.util.List,java.lang.Integer> importReadMapping(@NotNull java.lang.String inputFileName)
Function to read in the Readmapping file into a Map
public static void exportBestHitMap(@NotNull java.util.Map<kotlin.Pair,net.maizegenetics.pangenome.hapCalling.BestAlignmentGroup> bestHitMap, @NotNull java.lang.String readMappingFile)
Function to export the best hit mapping. This allows for easier debugging.
public static void exportMultimap(@NotNull com.google.common.collect.Multimap<net.maizegenetics.pangenome.api.ReferenceRange,net.maizegenetics.pangenome.hapCalling.SingleHapMapping> bestMapping, @NotNull java.lang.String outputFileName)
Function to write out the multimap data structure to a file. This requires the whole multimap to be constructed first
@NotNull public static java.util.List<kotlin.Pair> convertHitMapToSingleHapMapping(@NotNull java.util.Set<java.lang.String> readNames, @NotNull java.util.Map<kotlin.Pair,net.maizegenetics.pangenome.hapCalling.BestAlignmentGroup> bestHitMap, @NotNull java.util.Map<java.lang.Integer,? extends net.maizegenetics.pangenome.api.ReferenceRange> hapIdToRangeMap, @NotNull kotlin.jvm.functions.Function2<? super java.lang.String,? super java.util.Map<kotlin.Pair<java.lang.String,java.lang.Boolean>,net.maizegenetics.pangenome.hapCalling.BestAlignmentGroup>,java.lang.Boolean> filterFunction, @NotNull kotlin.jvm.functions.Function2<? super java.lang.String,? super java.util.Map<kotlin.Pair<java.lang.String,java.lang.Boolean>,net.maizegenetics.pangenome.hapCalling.BestAlignmentGroup>,? extends kotlin.Pair<java.lang.String,? extends java.util.Set<java.lang.Integer>>> mapToListFunction)
Function to do some filtering on read mappings then will convert the mappings into the correct datastructure for the multimaps
This can handle both paired end and single ends depending on the mapping functions passed in.
The first is a filter function takes a String for the readName and the Mapping
The second function is a mapping function which creates a Pair
For instance in paired end mode, the filter function makes sure that both strand reads are represented in the map And the mapping function will take the intersection of the hapids for both strands which helps remove the bad mapping regions
The single end is basically making sure that the read name is in the Map and the mapping function will just take the hapIds and put it in a Pair
@NotNull public static com.google.common.collect.Multimap<java.lang.String,java.lang.String> readInMultimapHitsFromFile(@NotNull java.lang.String inputFileName)
Function to read in the multimapHits from a text file.
@NotNull public static com.google.common.collect.Multimap<net.maizegenetics.pangenome.api.ReferenceRange,net.maizegenetics.pangenome.hapCalling.SingleHapMapping> readInListOfMultimapHits(@NotNull java.util.List<java.lang.String> inputFiles, @NotNull HaplotypeGraph graph)
Function to read in the multimap Hits from a file and store it in a list. The graph is needed to get a refRangeId to RefRange mapping
@NotNull public static com.google.common.collect.Multimap<net.maizegenetics.pangenome.api.ReferenceRange,net.maizegenetics.pangenome.hapCalling.SingleHapMapping> readInListOfMultimapHits(@NotNull java.util.List<java.lang.String> inputFiles, @NotNull java.util.Map<java.lang.Integer,? extends net.maizegenetics.pangenome.api.ReferenceRange> rangeIdToRangeMap)
Function to read in the Multimap
@NotNull public static com.google.common.collect.Multimap<net.maizegenetics.pangenome.api.ReferenceRange,net.maizegenetics.pangenome.hapCalling.SingleHapMapping> readInMultimapHits(@NotNull java.lang.String inputFileName, @NotNull HaplotypeGraph graph)
Function to read in the multimap Hits from a file and store it in a Multimap. The graph is needed to get a refRangeId to RefRange mapping
@NotNull public static com.google.common.collect.Multimap<net.maizegenetics.pangenome.api.ReferenceRange,net.maizegenetics.pangenome.hapCalling.SingleHapMapping> readInMultimapHits(@NotNull java.lang.String inputFileName, @NotNull java.util.Map<java.lang.Integer,? extends net.maizegenetics.pangenome.api.ReferenceRange> rangeIdToRangeMap)
Function to read in the multimap hits.
@NotNull public static java.util.List<java.lang.String> getHaplotypeMethodsForReadMappings(@NotNull com.google.common.collect.Multimap<net.maizegenetics.pangenome.api.ReferenceRange,net.maizegenetics.pangenome.hapCalling.HapIdSetCount> readMap, int numberOfRefRanges)
@NotNull public static java.util.List<java.lang.String> getHaplotypeMethodForHapids(@NotNull java.util.Collection<java.lang.Integer> hapidList)