GATK AlleleList接口介绍

server/2024/9/20 4:00:05/ 标签: java, 生物信息学

在 GATK(Genome Analysis Toolkit)中,AlleleList 接口是一个用来表示等位基因(alleles)列表的接口。Allele 是遗传学中用于表示某一特定基因座的不同形式的一个基本单位。AlleleList 接口定义了一些操作,使得处理和访问一组等位基因更加方便。

AlleleList 的实现类和继承接口

使用场景

AlleleList 及其实现类在 GATK 中主要用于表示和操作基因型数据中的等位基因集合。典型场景包括:

  • 变异检测:在不同样本中检测和分析不同的等位基因时,需要管理多个等位基因的集合,这时候会用到 AlleleList
  • 基因型计算:在计算样本的基因型时,可能需要迭代多个等位基因,并根据等位基因的组合进行计算。

通过 AlleleList 接口,GATK 提供了一个统一的方式来处理等位基因列表,增强了代码的可读性和模块化,使得等位基因的管理变得更加直观和高效。

AlleleList接口源码

package org.broadinstitute.hellbender.utils.genotyper;import htsjdk.variant.variantcontext.Allele;
import org.broadinstitute.hellbender.utils.Utils;import java.util.AbstractList;
import java.util.List;/*** Minimal interface for random access to a collection of Alleles.*/
//Note: Names in this interface are unusual because of name clash in a subclass.
// For example the name of AlleleList.alleleCount() cannot be simply size(), as would be usual,
// because {@link ReadLikelihoods} implements AlleleList and SampleList and then size() would be ambiguous.
public interface AlleleList<A extends Allele> {static <A extends Allele> AlleleList<A> newList(final List<A> alleles) {return new IndexedAlleleList<A>(alleles);}/*** Returns the number of alleles in this AlleleList.*/int numberOfAlleles();/*** Returns the index of the given Allele in this AlleleList.* Returns a negative number if the given allele is not present in this AlleleList.* @throws IllegalArgumentException if allele is null.*/int indexOfAllele(final Allele allele);/*** Returns the allele at the given index in this AlleleList.* @throws IllegalArgumentException if index is negative or equal* to or higher than the number of elements in this AlleleList {@link AlleleList#numberOfAlleles()}).*/A getAllele(final int index);/*** Returns <code>true</code> if this AlleleList contains the specified allele* and <code>false</code> otherwise.*/default boolean containsAllele(final Allele allele) {return indexOfAllele(allele) >= 0;}AlleleList<Allele> EMPTY_LIST = new AlleleList<Allele>() {@Overridepublic int numberOfAlleles() {return 0;}@Overridepublic int indexOfAllele(final Allele allele) {Utils.nonNull(allele);return -1;}@Overridepublic Allele getAllele(final int index) {throw new IllegalArgumentException("allele index is out of range");  //we know this without checking because it's an empty list}};/*** Returns an unmodifiable empty allele-list.* @param <A> the allele class.* @return never {@code null}.*/@SuppressWarnings("unchecked")static <A extends Allele> AlleleList<A> emptyAlleleList() {return (AlleleList<A>) EMPTY_LIST;}/*** Checks whether two allele lists are in fact the same.* @param first one list to compare.* @param second another list to compare.** @throws IllegalArgumentException if if either list is {@code null}.** @return {@code true} iff both list are equal.*/static <A extends Allele> boolean equals(final AlleleList<A> first, final AlleleList<A> second) {if (first == null || second == null) {throw new IllegalArgumentException("no null list allowed");}final int alleleCount = first.numberOfAlleles();if (alleleCount != second.numberOfAlleles()) {return false;}for (int i = 0; i < alleleCount; i++) {final A firstSample = first.getAllele(i);Utils.nonNull(firstSample, "no null samples allowed in sample-lists: first list at " + i);final A secondSample = second.getAllele(i);Utils.nonNull(secondSample,"no null samples allowed in sample-list: second list at " + i);if (!firstSample.equals(secondSample)) {return false;}}return true;}/*** Resolves the index of the reference allele in an allele-list.** <p>*     If there is no reference allele, it returns -1. If there is more than one reference allele,*     it returns the first occurrence (lowest index).* </p>*** @throws IllegalArgumentException if {@code list} is {@code null}.** @return -1 if there is no reference allele, or a values in [0,{@code list.alleleCount()}).*/default int indexOfReference() {final int alleleCount = this.numberOfAlleles();for (int i = 0; i < alleleCount; i++) {if (this.getAllele(i).isReference()) {return i;}}return -1;}/*** Returns a {@link List} unmodifiable view of this allele-list** @return never {@code null}.*/default List<A> asListOfAlleles() {return new AbstractList<A>() {@Overridepublic A get(final int index) {return AlleleList.this.getAllele(index);}@Overridepublic int size() {return AlleleList.this.numberOfAlleles();}};}/*** Returns a permutation between two allele lists.* @param target the target allele list.** @throws IllegalArgumentException if {@code target} is {@code null}, or* elements in {@code target} is not contained in {@code this}** @return never {@code null}*/default AlleleListPermutation<A> permutation(final AlleleList<A> target) {if (equals(this, target)) {return new NonPermutation<>(this);} else {return new ActualPermutation<>(this, target);}}/*** This is the identity permutation.*/final class NonPermutation<A extends Allele> implements AlleleListPermutation<A> {private final AlleleList<A> list;NonPermutation(final AlleleList<A> original) {list = original;}@Overridepublic boolean isPartial() {return false;}@Overridepublic boolean isNonPermuted() {return true;}@Overridepublic int toIndex(final int fromIndex) {return fromIndex;}@Overridepublic int fromIndex(final int toIndex) {return toIndex;}@Overridepublic boolean isKept(final int fromIndex) { return true; }@Overridepublic int fromSize() {return list.numberOfAlleles();}@Overridepublic int toSize() {return list.numberOfAlleles();}@Overridepublic List<A> fromList() {return list.asListOfAlleles();}@Overridepublic List<A> toList() {return list.asListOfAlleles();}@Overridepublic int numberOfAlleles() {return list.numberOfAlleles();}@Overridepublic int indexOfAllele(final Allele allele) {return list.indexOfAllele(allele);}@Overridepublic A getAllele(final int index) {return list.getAllele(index);}}final class ActualPermutation<A extends Allele> implements AlleleListPermutation<A> {private final AlleleList<A> from;private final AlleleList<A> to;private final int[] fromIndex;private final boolean[] keptFromIndices;private final boolean nonPermuted;private final boolean isPartial;private ActualPermutation(final AlleleList<A> original, final AlleleList<A> target) {this.from = original;this.to = target;keptFromIndices = new boolean[original.numberOfAlleles()];final int toSize = target.numberOfAlleles();final int fromSize = original.numberOfAlleles();if (fromSize < toSize) {throw new IllegalArgumentException("target allele list is not a permutation of the original allele list");}fromIndex = new int[toSize];boolean nonPermuted = fromSize == toSize;this.isPartial = !nonPermuted;for (int i = 0; i < toSize; i++) {final int originalIndex = original.indexOfAllele(target.getAllele(i));if (originalIndex < 0) {throw new IllegalArgumentException("target allele list is not a permutation of the original allele list");}keptFromIndices[originalIndex] = true;fromIndex[i] = originalIndex;nonPermuted &= originalIndex == i;}this.nonPermuted = nonPermuted;}@Overridepublic boolean isPartial() {return isPartial;}@Overridepublic boolean isNonPermuted() {return nonPermuted;}@Overridepublic int toIndex(final int fromIndex) {return to.indexOfAllele(from.getAllele(fromIndex));}@Overridepublic int fromIndex(final int toIndex) {return fromIndex[toIndex];}@Overridepublic boolean isKept(final int fromIndex) {return keptFromIndices[fromIndex];}@Overridepublic int fromSize() {return from.numberOfAlleles();}@Overridepublic int toSize() {return to.numberOfAlleles();}@Overridepublic List<A> fromList() {return from.asListOfAlleles();}@Overridepublic List<A> toList() {return to.asListOfAlleles();}@Overridepublic int numberOfAlleles() {return to.numberOfAlleles();}@Overridepublic int indexOfAllele(final Allele allele) {return to.indexOfAllele(allele);}@Overridepublic A getAllele(final int index) {return to.getAllele(index);}}
}


http://www.ppmy.cn/server/105431.html

相关文章

R语言function快速掌握-自定义函数

R语言在生物学中运用的比较多的还是吊包然后使用内置函数进行一次性工作&#xff0c;但是生物信息与计算生物学领域确实低估和忽视了R语言在循环和自定义函数方面的优势。 在R语言中&#xff0c;function 是一个核心概念&#xff0c;它允许用户创建可重用的代码块来执行特定的…

K8S基础和安装

一 、Kubernetes 概述 k8s用于自动部署、扩展和管理“容器化&#xff08;containerized&#xff09;应用程序”的开源系统&#xff0c;可以理解成 K8S 是负责自动化运维管理多个容器化程序&#xff08;比如 Docker&#xff09;的集群&#xff0c;是一个生态极其丰富的容器编排…

集合及数据结构第四节————List与顺序表

系列文章目录 集合及数据结构第四节————List、ArrayList与顺序表 List、ArrayList与顺序表 List的介绍常见接口介绍.List的使用什么是线性表顺序表接口的定义MyArrayList类里面实现这些接口&#xff08;&#xff09;功能顺序表的优缺点 文章目录 系列文章目录集合及数据…

2024年8月25日 十二生肖 今日运势

小运播报&#xff1a;2024年8月25日&#xff0c;星期日&#xff0c;农历七月廿二 &#xff08;甲辰年壬申月辛酉日&#xff09;&#xff0c;法定节假日。 红榜生肖&#xff1a;龙、牛、蛇 需要注意&#xff1a;鸡、狗、兔 喜神方位&#xff1a;西南方 财神方位&#xff1a;…

【Qt开发】建立自己的Qt基本类、函数库封装 包括图表、多线程、串口等

【Qt开发】建立自己的Qt基本类、函数库 包括图表、多线程、串口等 文章目录 前言QtCharts绘图继承QObject的QThread多线程QSerialPort串口配置、发送、接收回调函数附录&#xff1a;C语言到C的入门知识点&#xff08;主要适用于C语言精通到Qt的C开发入门&#xff09;C语言与C的…

Edge-TTS:微软推出的,免费、开源、支持多种中文语音语色的AI工具[Python代码]

Edge-TTS&#xff0c;由微软推出的这款免费、开源的AI工具&#xff0c;为用户带来了丰富多样的中文语音体验。它不仅支持多种中文语音语色&#xff0c;还能实现流畅自然的语音合成。Edge-TTS凭借其高度可定制化的特点&#xff0c;广泛应用于智能助手、语音播报、教育培训等领域…

【计算机组成原理】强化部分笔记

第一章 计算机系统概述 考点1 计算机系统层次结构 1.计算机发展历程已从大纲中删去 2. 3.指令和数据都存放在存储器中&#xff0c;通过指令周期不同来区分&#xff08;比如取指周期和执行周期&#xff09; 现代的计算机以存储器为中心 4. 5. 6.汇编语言&#xff1a;STORE、L…

PDF文件切割,无大小限制

前言 公司让学习一个东西&#xff0c;让写一个学习总结&#xff0c;我想这不是AI的拿手好戏&#xff0c;直接把近100M的PDF喂给他&#xff0c;然后他说吃不下&#xff0c;太大了 小事&#xff0c;那么多在线PDF工具网站&#xff0c;分分钟拆开&#xff0c;然后找了半天也都是…

微信小程序如何实现组件之间的数据传递?

在微信小程序中,组件之间的数据传递主要有以下几种方式: 父组件向子组件传值: 父组件可以通过设置子组件的属性(properties)来传递数据。首先,在子组件的 .json 文件中定义 properties: {"component": true,"usingComponents": {},"properties…

Vue解决父子组件传值,子组件改变值后父组件的值也改变的问题

vue开发过程中&#xff0c;父组件通过props传值给子组件&#xff0c;子组件在页面展示父组件的值&#xff0c;在操作子组件值以后&#xff0c;即使不点击确定按钮&#xff0c;父组件中的值也发生了变化&#xff0c;但是需求是操作子组件数据以后&#xff0c;必须点击"确定…

探索HarmonyOS中的列表组件及其自定义特性

在现代移动应用中&#xff0c;List组件是数据列表的关键元素。HarmonyOS中的List组件不仅具备传统的列表功能&#xff0c;还提供了丰富的自定义选项&#xff0c;允许开发者根据需求灵活调整列表的行为和外观展示。本文将探讨HarmonyOS中列举组件的自定义特性&#xff0c;包括自…

【LeetCode每日一题】——301.删除无效的括号

文章目录 一【题目类别】二【题目难度】三【题目编号】四【题目描述】五【题目示例】六【题目提示】七【解题思路】八【时间频度】九【代码实现】十【提交结果】 一【题目类别】 广度优先搜索 二【题目难度】 困难 三【题目编号】 301.删除无效的括号 四【题目描述】 给…

C#面:ASP.NET MVC 中如何用表单认证?

在 ASP.NET MVC 中&#xff0c;可以使用表单认证来验证用户的身份。 表单认证是一种基于 Cookie 的认证方式&#xff0c;它通过在用户登录成功后生成一个包含用户身份信息的加密 Cookie&#xff0c;并将该 Cookie 发送给客户端保存。 当用户发送请求时&#xff0c;服务器会验…

19.缓存的认识和基本使用

缓存介绍 缓存是数据交换的缓冲区Cache&#xff0c;是临时存储数据的地方&#xff0c;一般读写性能较高。 数据库的缓存就是建立索引。 缓存的作用 1.降低后端负载。 2.提高读写效率&#xff0c;降低响应时间。 缓存的问题 1.保证数据的一致性。 2.增加代码维护成本。解…

iOS 开发:Object-C 和 Swift 的区别 (AI问答)

一&#xff1a;语言类型的区别&#xff08;最主要区别&#xff09; object-c 是动态类型语言&#xff1b; swift是静态类型语言&#xff1b; 看一下AI的回答&#xff0c;很全面~~ Objective-C 和 Swift 的语言类型区别主要体现在以下几个方面&#xff1a; 1. 静态类型 vs. 动…

如何选择最佳路线?

交通线路的选择 日常交通线路的选择&#xff0c;并不是按最短路径选择的。还要参考道路的等级&#xff0c;道路是否拥堵&#xff0c;道路通行速度等多种情形。本程序列举出所有能通行的线路&#xff0c;并计算出行驶距离&#xff0c;来供用户选择。当然&#xff0c;也可以加入…

机械学习—零基础学习日志(如何理解概率论7)

这里需要先理解伯努利试验。只有A与A逆&#xff0c;两种结果。 正态分布 再来一道习题~&#xff1a; 解析&#xff1a; 《概率论与数理统计期末不挂科|考研零基础入门4小时完整版&#xff08;王志超&#xff09;》学习笔记 王志超老师 &#xff08;UP主&#xff09;

有了孩子后,你需要知道的家庭教育知识

和程序员一样&#xff0c;做合格的父母也需要学习和经验。 家庭是孩子的第一个课堂&#xff0c;父母是孩子的第一任老师。 家庭教育做什么&#xff1f; 父母应该承担哪些家庭教育&#xff1f;《家庭教育促进法》对此做了明确规定&#xff1a;所谓家庭教育&#xff0c;是指父母…

Go语言标准错误error解析

错误类型 errorString 错误是程序中处理逻辑和系统稳定新的重要组成部分。在go语言中内置错误如下&#xff1a; // The error built-in interface type is the conventional interface for // representing an error condition, with the nil value representing no error. …

如何在 Ubuntu 系统中安装PyCharm集成开发环境?

在上一篇文章中&#xff0c;我们探讨了Jupyter notebook&#xff0c;今天再来看看另一款常用的Python 工具&#xff0c;Pycharm。 PyCharm也是我们日常开发和学习常用的Python 集成开发环境 (IDE)&#xff0c;由 JetBrains 开发。 PyCharm 带有一整套可以帮助用户在使用Pytho…