在GATK中,FeatureContext
类是用于在基因组分析中提供特征数据上下文的关键类。它帮助在特定的基因组位置或区域获取相关的特征信息,这对于很多变异调用和基因组分析任务是至关重要的。
FeatureContext
类
FeatureContext
类在GATK中用于处理和管理与给定基因组位置相关的特征数据。这些特征数据可以包括变异、基因组注释、SNPs、INDELs等。FeatureContext
主要用于在分析时提供上下文信息,例如在调用变异时获取附近的基因或注释信息。
主要功能:
-
获取特征数据:提供对在特定位置附近的基因组特征的访问。例如,你可以使用
FeatureContext
来获取特定变异位置附近的基因注释或其他相关特征。 -
数据过滤:可以对特征数据进行过滤,确保只获取与当前分析任务相关的特征。
-
上下文支持:为分析算法提供上下文支持,帮助理解特征数据与给定基因组位置之间的关系。例如,在计算变异的影响时,你可能需要了解变异所在的基因或功能区域的信息。
-
简化数据访问:通过
FeatureContext
,可以简化从不同数据源(如注释文件、变异数据库)获取和操作特征数据的过程。
使用场景:
- 变异调用:在变异调用工具中,
FeatureContext
可以用来获取变异位置的基因组注释和其他特征信息,以帮助评估变异的影响。 - 基因组注释:在基因组注释分析中,
FeatureContext
用于获取和处理与特定基因组位置相关的注释数据。 - 数据整合:整合来自不同数据源的特征数据,为分析任务提供丰富的上下文信息。
源码:
package org.broadinstitute.hellbender.engine;
import com.google.common.annotations.VisibleForTesting;
import htsjdk.samtools.util.Locatable;
import htsjdk.tribble.Feature;
import org.broadinstitute.hellbender.cmdline.CommandLineProgram;
import org.broadinstitute.hellbender.utils.SimpleInterval;
import org.broadinstitute.hellbender.utils.Utils;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;
/**
* Wrapper around FeatureManager that presents Feature data from a particular interval to a client tool
* without improperly exposing engine internals.
*
* The client passes in one or more FeatureInputs that were declared as tool arguments, and gets back a List
* of all Features from those FeatureInputs overlapping the interval spanned by this FeatureContext.
*
* Features returned may optionally be additionally constrained to start at a particular position.
*
* Features are returned strongly-typed based on the type parameter of each FeatureInput requested,
* so a query on a FeatureInput<VariantContext> will return VariantContext objects (no casting
* required by tool authors).
*
* Feature sources are lazily queried, so there's no overhead if the client chooses not to examine
* the FeatureContext it's passed.
*
* A FeatureContext may have no backing data source and/or interval. In these cases, queries on it will always
* return empty Lists. You can determine whether there is a backing source of Features via
* {@link #hasBackingDataSource()}, and whether there is an interval via {@link #getInterval}
*
* Note: This class is NOT intended to be extended outside of the testing harness.
*/
@DoNotSubclass
public class FeatureContext {
/**
* FeatureManager containing backing data sources for all discovered Feature arguments.
* Null if there are no sources of Features.
*/
private final FeatureManager featureManager;
/**
* We will return Features overlapping this interval. Null if this context has no known location
* (eg., we are dealing with unmapped data).
*/
private final SimpleInterval interval;
/**
* Creates an empty FeatureContext with no backing data source. All queries on this context will
* return an empty List.
*/
public FeatureContext() {
this((FeatureManager)null, null);
}
/**
* Creates a new FeatureContext given a FeatureManager and a query interval. These may be null if
* no sources of Features are available and/or we don't have a known location on the reference,
* in which case all queries on this context will return an empty List.
*
* @param featureManager FeatureManager containing backing data sources for all discove