在GATK4中,EventMap
类是用于处理和管理变异事件(如插入、缺失和替换)在基因组位置上的映射。这个类在复杂变异调用和变异分析中扮演了重要角色。以下是EventMap
类的主要功能和用途:
主要功能
-
存储变异事件:
EventMap
用于存储在特定基因组位置上发生的变异事件。这些事件可能包括插入、缺失或替换等类型的变异。
-
合并事件:
- 当多个变异事件发生在同一位置时,
EventMap
能够合并这些事件。合并过程通常涉及将不同类型的事件结合起来,以形成一个复合事件,从而便于进一步分析。
- 当多个变异事件发生在同一位置时,
-
查询事件:
- 可以通过位置查询特定的变异事件。这使得对特定区域或位置的变异进行详细分析成为可能。
-
更新事件:
- 提供方法来更新现有位置的变异事件,例如通过添加新的变异或修改现有变异的详细信息。
-
管理事件:
- 支持添加、删除和检查特定位置的变异事件,以及获取所有事件的位置和详情。
EventMap类和Haplotype类关系
-
事件和基因型的关联:
Haplotype
类可能会包含一个或多个EventMap
实例,表示其所描述的基因型中涉及的所有变异事件。这意味着一个Haplotype
可以关联多个变异事件,通过EventMap
管理这些事件。
-
变异分析过程中的协同作用:
- 在变异呼叫和分析中,
Haplotype
类用于描述具体的基因型,包括变异事件的上下文,而EventMap
则用于管理这些变异事件的位置和信息。它们协同工作来支持复杂的变异分析任务。
- 在变异呼叫和分析中,
-
复合事件处理:
EventMap
在处理复合事件时,可能会涉及到多个Haplotype
,每个Haplotype
可能包含不同的变异事件。EventMap
负责管理这些事件的详细信息,而Haplotype
则负责描述这些事件在基因组中的具体表现形式。
源码:
package org.broadinstitute.hellbender.utils.haplotype;
import com.google.common.annotations.VisibleForTesting;
import htsjdk.samtools.Cigar;
import htsjdk.samtools.CigarElement;
import htsjdk.samtools.util.Locatable;
import htsjdk.variant.variantcontext.Allele;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.broadinstitute.hellbender.exceptions.GATKException;
import org.broadinstitute.hellbender.tools.walkers.haplotypecaller.AssemblyBasedCallerUtils;
import org.broadinstitute.hellbender.utils.BaseUtils;
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.param.ParamUtils;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* Extract simple VariantContext events from a single haplotype
*/
public final class EventMap extends TreeMap<Integer, Event> {
private static final long serialVersionUID = 1L;
private static final Logger logger = LogManager.getLogger(EventMap.class);
public EventMap(final Collection<Event> events) {
super();
events.forEach(this::addEvent);
}
public static EventMap fromHaplotype(final Haplotype haplotype, final byte[] ref, final Locatable refLoc, final int maxMnpDistance) {
return new EventMap(getEvents(haplotype, ref, refLoc, maxMnpDistance));
}
public static EventMap fromHaplotype(final Haplotype haplotype, final byte[] ref, final int maxMnpDistance) {
return new EventMap(getEvents(haplotype, ref, haplotype, maxMnpDistance));
}
// this is really just a convenient way to make EventMap objects in unit tests
@VisibleForTesting