当前位置: 首页 > news >正文

GATK AlleleList接口介绍

在 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);}}
}

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • SpringBoot3 简单集成 Spring AI 并使用
  • 图的应用
  • 使用 Python 绘制词云图的详细教程
  • SpringBoot的异常java.lang.ClassNotFoundException: io.r2dbc.spi.ValidationDepth
  • 【算法基础实验】图论-最小生成树-Prim的即时实现
  • Java学习笔记(01)final关键字的使用
  • 【论文阅读】通用的语义-几何表征的机器人操作
  • EmguCV学习笔记 VB.Net 第6章 形状操作
  • K8S 版本发版
  • 电脑开机LOGO修改教程_BIOS启动图片替换方法
  • Compose知识分享
  • js实现点击图片放大效果
  • 科研绘图配色大全
  • 0821作业+思维导图
  • C++ //练习 18.22 已知存在如下所示的类的继承体系,其中每个类都定义了一个默认构造函数:
  • Angular2开发踩坑系列-生产环境编译
  • C学习-枚举(九)
  • express如何解决request entity too large问题
  • Facebook AccountKit 接入的坑点
  • IDEA 插件开发入门教程
  • Java 9 被无情抛弃,Java 8 直接升级到 Java 10!!
  • JavaSE小实践1:Java爬取斗图网站的所有表情包
  • magento2项目上线注意事项
  • mockjs让前端开发独立于后端
  • open-falcon 开发笔记(一):从零开始搭建虚拟服务器和监测环境
  • Python连接Oracle
  • STAR法则
  • 闭包--闭包作用之保存(一)
  • 关于List、List?、ListObject的区别
  • 汉诺塔算法
  • 基于阿里云移动推送的移动应用推送模式最佳实践
  • 巧用 TypeScript (一)
  • 如何使用Mybatis第三方插件--PageHelper实现分页操作
  • 深度学习在携程攻略社区的应用
  • 实战:基于Spring Boot快速开发RESTful风格API接口
  • 手机app有了短信验证码还有没必要有图片验证码?
  • -- 数据结构 顺序表 --Java
  • 微信小程序上拉加载:onReachBottom详解+设置触发距离
  • 微信支付JSAPI,实测!终极方案
  • 3月27日云栖精选夜读 | 从 “城市大脑”实践,瞭望未来城市源起 ...
  • C# - 为值类型重定义相等性
  • Java总结 - String - 这篇请使劲喷我
  • ​​​​​​​sokit v1.3抓手机应用socket数据包: Socket是传输控制层协议,WebSocket是应用层协议。
  • ​secrets --- 生成管理密码的安全随机数​
  • ​必胜客礼品卡回收多少钱,回收平台哪家好
  • #鸿蒙生态创新中心#揭幕仪式在深圳湾科技生态园举行
  • #前后端分离# 头条发布系统
  • #我与Java虚拟机的故事#连载19:等我技术变强了,我会去看你的 ​
  • $.type 怎么精确判断对象类型的 --(源码学习2)
  • $con= MySQL有关填空题_2015年计算机二级考试《MySQL》提高练习题(10)
  • (04)odoo视图操作
  • (android 地图实战开发)3 在地图上显示当前位置和自定义银行位置
  • (保姆级教程)Mysql中索引、触发器、存储过程、存储函数的概念、作用,以及如何使用索引、存储过程,代码操作演示
  • (精确度,召回率,真阳性,假阳性)ACC、敏感性、特异性等 ROC指标
  • (五)网络优化与超参数选择--九五小庞