GATK SampleList接口介绍

news2024/9/20 13:15:36

在 GATK 中,SampleList 是一个接口,用于表示一个样本列表。这些样本通常是在基因组分析过程中被处理的不同生物样本。SampleList 接口提供了访问这些样本的一些基本方法,通常用于多样本分析任务,比如变异检测或基因组重测序。

SampleList 接口的方法

SampleList 接口定义了一些关键方法,用于获取和处理样本信息:

SampleList接口的实现类

SampleList源代码

package org.broadinstitute.hellbender.utils.genotyper;

import org.broadinstitute.hellbender.utils.Utils;

import java.util.*;

/**
 * An immutable, indexed set of samples.
 *
 * <p>
 *     Implementing classes must guarantee that the sample list will remain <b>constant</b> through the life of the object.
 * </p>
 */
//Note: Names in this interface are unusual because of name clash in a subclass.
// For example the name of SampleList.numberOfSamples() cannot be simply size(), as would be usual,
// because {@link AlleleLikelihoods} implements AlleleList and SampleList and then size() would be ambiguous.
public interface SampleList  {

    static final SampleList EMPTY_LIST = new SampleList() {
        @Override
        public int numberOfSamples() {
            return 0;
        }

        @Override
        public int indexOfSample(final String sample) {
            Utils.nonNull(sample);
            return -1;
        }

        @Override
        public String getSample(final int sampleIndex) {
            throw new IllegalArgumentException("index is out of valid range");  //we know this without checking because it's an empty list
        }
    };

    /**
     * Empty list.
     *
     * @return never {@code null}
     */
    public static SampleList emptySampleList() {
        return EMPTY_LIST;
    }

    /**
     * Returns number of elements in the list.
     */
    public int numberOfSamples();

    /**
     * Returns the index of an object.
     * @param sample the sample of interest.
     *
     * @throws IllegalArgumentException if {@code sample} is {@code null}.
     *
     * @return {@code -1} if such a sample is not an element of this set, otherwise is index in the set thus a
     * values within [0,{@link #numberOfSamples()}).
     */
    public int indexOfSample(final String sample);

    /**
     * Returns the element given its index within the set.
     * @param sampleIndex the target samples's index.
     *
     * @throws IllegalArgumentException if {@code index} is not valid; in [0,{@link #numberOfSamples()}).
     *
     * @return never {@code null}; as null is not a valid element.
     */
    public String getSample(final int sampleIndex);

    /**
     * Checks whether two sample 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.
     */
    public static boolean equals(final SampleList first, final SampleList second) {
        Utils.nonNull(first, "first list is null");
        Utils.nonNull(second, "second list is null");
        final int sampleCount = first.numberOfSamples();
        if (sampleCount != second.numberOfSamples()) {
            return false;
        }

        for (int i = 0; i < sampleCount; i++) {
            final String firstSample = first.getSample(i);
            final String secondSample = second.getSample(i);
            if (!firstSample.equals(secondSample)) {
                return false;
            }
        }
        return true;
    }

    /**
     * Returns a {@link List} unmodifiable view of a sample-list
     *
     * @throws IllegalArgumentException if {@code list} is {@code null}.
     *
     * @return Unmodifiable view of the sample list. Never {@code null}.
     */
    default public List<String> asListOfSamples() {
        return new AbstractList<String>() {
                @Override
                public String get(final int index) {
                    return SampleList.this.getSample(index);
                }

                @Override
                public int size() {
                    return SampleList.this.numberOfSamples();
                }
        };
    }

    /**
     * Returns a {@link Set} unmodifiable view of the sample-list
     *
     * @return Unmodifiable view of the sample set. Never null.
     */
    default public Set<String> asSetOfSamples() {
        return new AbstractSet<String>() {
            @Override
            public Iterator<String> iterator() {
                return new Iterator<String>() {
                    private int index = 0;

                    @Override
                    public boolean hasNext() {
                        return index < SampleList.this.numberOfSamples();
                    }

                    @Override
                    public String next() {
                        if (index >= SampleList.this.numberOfSamples()) {
                            throw new NoSuchElementException("iterating beyond sample list end");
                        }
                        return SampleList.this.getSample(index++);
                    }

                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException("unsupported operation exception");
                    }
                };
            }

            @Override
            public int size() {
                return SampleList.this.numberOfSamples();
            }

            @Override
            public boolean contains(final Object obj) {
                //note: this handles null too (instanceof returns false)
                return (obj instanceof String) && SampleList.this.indexOfSample(((String) obj)) >= 0;
            }
        };
    }

    /**
     * Creates a list with a single sample.
     *
     * @param sampleName the sample name.
     * @return never {@code sampleName}
     */
    public static SampleList singletonSampleList(final String sampleName) {
        Utils.nonNull(sampleName, "the sample name cannot be null");
        return new SampleList() {
            @Override
            public int numberOfSamples() {
                return 1;
            }

            @Override
            public int indexOfSample(final String sample) {
                return sampleName.equals(sample) ? 0 : -1;
            }

            @Override
            public String getSample(final int sampleIndex) {
                if (sampleIndex == 0) {
                    return sampleName;
                }
                throw new IllegalArgumentException("index is out of bounds");
            }
        };
    }
}

注:1. EMPTY_LIST 的这种写法通过匿名内部类实现了 SampleList 接口,并且保持不可变性。它提供了一种高效且安全的方式来表示一个空的样本列表对象,既节省了内存,又提高了代码的可读性和可维护性。这种模式在 Java 中非常常见,尤其是在需要表示不可变的、通用对象实例时。2. singletonSampleList方法通过匿名内部类生成包含一个样本的SampleList实例。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2058172.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

入门request请求库使用

基础条件 想要入门request 打开pycharm的终端查看是否在虚拟环境下 在路径前面是否有&#xff08;venv&#xff09; 如果没有需要先配置虚拟环境 然后在终端中输入 pip install request 等待下载完成后就在我们的项目中导入 基本用法 1.发送GET请求 import requestsurl…

【C#】去掉字符串中的第一或最后一位

要去掉字符串中的第一或最后一位&#xff0c;可以使用以下几种方法&#xff1a; 1. 去掉第一位 如果想去除字符串的第一位&#xff0c;同样可以使用 Substring 方法。 1.1 使用 Substring 方法 string str "8,"; if (str.Length > 0) {str str.Substring(1)…

如何利用AI创作高质量的文章

讯飞星火 利用AI创作高质量的文章需要遵循以下步骤&#xff1a; 确定主题和目标受众&#xff1a;在开始写作之前&#xff0c;明确文章的主题和目标受众。这将帮助你确定文章的风格、结构和内容。 收集资料和信息&#xff1a;在撰写文章之前&#xff0c;进行充分的研究&#x…

推荐一款基于Spring Boot + VUE 框架开发的分布式文件管理系统,功能齐全、实用便捷(附源码)

前言 在数字化时代&#xff0c;文件管理是企业和个人用户的基本需求。然而&#xff0c;现有的文件管理系统往往存在一些痛点&#xff0c;如存储空间有限、文件共享困难、缺乏在线编辑功能、移动端适配性差等。这些问题限制了用户在不同设备和场景下的文件处理能力。 为了解-决…

利用开源项目加速AI+绘画设计与AI+视频生成的商业化进程

随着生成式人工智能技术的发展,越来越多的工具被开发出来,用于辅助创意工作者创作出令人惊叹的作品。本文将介绍两个开源项目——一个专注于将ComfyUI工作流转换为商业化的移动应用和网页,另一个则聚焦于利用AI技术简化视频创作过程。这两个项目不仅为创作者提供了强大的工具…

【Linux】2.Linux常见指令以及权限理解(1)

文章目录 1.Xshell的一些快捷键操作2.Linux指令2.1常用指令示例2.2常用指令选项2.2.1 ls指令2.2.2 cd/pwd/shoami指令2.2.3 touch指令2.2.4 mkdir指令2.2.5 rmdir指令2.2.6 rm指令 1.Xshell的一些快捷键操作 Xshell&#xff1a; altenter&#xff1a;Xshell自动全屏&#xff0c…

远程在线诊疗小程序的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;用户管理&#xff0c;医生管理&#xff0c;科室信息管理&#xff0c;科室类型管理&#xff0c;患者信息管理&#xff0c;通知公告管理&#xff0c;医院介绍&#xff0c;系统管理 微信端账号功能包括&a…

【吊打面试官系列-Memcached面试题】memcached 如何处理容错的?

大家好&#xff0c;我是锋哥。今天分享关于 【memcached 如何实现冗余机制&#xff1f; 】面试题&#xff0c;希望对大家有帮助&#xff1b; memcached 如何实现冗余机制&#xff1f; 不处理&#xff01; 在 memcached 节点失效的情况下&#xff0c;集群没有必要做任何容错处理…

机器人测试自动化智能化交流沙龙 —— 免费参与,线上线下同步进行,探索未来科技新篇章!

在这个科技日新月异的时代&#xff0c;机器人技术正以前所未有的速度推动着各行各业的变革。而在这场变革中&#xff0c;如何确保机器人系统的稳定性、可靠性及高效性&#xff0c;成为了每一个从业者必须面对的重要课题。为此&#xff0c;我们特地在成都这座充满活力的城市&…

ok,boomer xss的dom破坏

一、首先什么是dom破坏 在HTML中&#xff0c;如果使用一些特定的属性名&#xff08;id、name&#xff09;给DOM元素命名&#xff0c;这些属性会在全局作用域中创建同名的全局变量&#xff0c;指向对应的DOM元素。这种行为虽然有时可以方便地访问元素&#xff0c;但也会引发一些…

【Linux】Linux环境基础开发工具使用之Linux调试器-gdb使用

目录 一、程序发布模式1.1 debug模式1.2 release模式 二、默认发布模式三、gdb的使用结尾 一、程序发布模式 程序的发布方式有两种&#xff0c;debug模式和release模式 1.1 debug模式 目的&#xff1a;主要用于开发和测试阶段&#xff0c;目的是让开发者能够更容易地调试和跟…

【Go】实现字符切片零拷贝开销转为字符串

package mainimport ("fmt""unsafe" )func main() {bytes : []byte("hello world")s : *(*string)(unsafe.Pointer(&bytes))fmt.Println(s)bytes[0] Hfmt.Println(s) }slice的底层结构是底层数组、len字段、cap字段。string的底层结构是底层…

第1章-04-Chrome及Chrome Driver安装及测试

&#x1f3c6;作者简介&#xff0c;黑夜开发者&#xff0c;CSDN领军人物&#xff0c;全栈领域优质创作者✌&#xff0c;CSDN博客专家&#xff0c;阿里云社区专家博主&#xff0c;2023年CSDN全站百大博主。 &#x1f3c6;数年电商行业从业经验&#xff0c;历任核心研发工程师&am…

MYSQL定时任务使用手册

开发和管理数据库时&#xff0c;经常需要定时执行某些任务&#xff0c;比如每天备份数据库、每周统计报表等。MySQL提供了一个非常有用的工具&#xff0c;即事件调度器&#xff08;Event Scheduler&#xff09;&#xff0c;可以帮助我们实现定时任务调度的功能。本文将介绍如何…

Excel中的“块”操作

在Excel中&#xff0c;有offset、index、indirect三个对“区域”操作的函数&#xff0c;是较高版本Excel中“块”操作的利器。 (笔记模板由python脚本于2024年08月20日 19:25:21创建&#xff0c;本篇笔记适合喜欢用Excel处理数据的coder翻阅) 【学习的细节是欢悦的历程】 Pytho…

46、Python之模块和包:一切皆对象,模块和包也不例外

引言 在前面的文章中&#xff0c;我们介绍了变量、函数、类&#xff0c;在实际编程中&#xff0c;始终在贯彻的有两点&#xff1a; 1、在Python中一切皆对象&#xff0c;所以函数、类、模块、包也都是一等公民。 2、不管是基于面向过程还是面向对象&#xff0c;我们在实际编…

使用Element UI组件时,icon图标不显示

问题描述&#xff1a; 我在使用Element UI组件的日期选择器时&#xff0c;发现图标不显示(左边是原图&#xff0c;右边的问题图)。 经过检查我发现&#xff0c;我的JS&#xff0c;CSS文件都没有问题&#xff0c;只是缺少了element-icons.tff和element-icons.woff这两个文件。 …

JSON, YAML, XML, CSV交互可视化

1、jsoncrack https://jsoncrack.com/editor

O2OA(翱途)服务器配置与管理-如何修改服务器内存占用率?

o2server 启动后一般占用大约4G~6G内存空间,在启动脚本中默认设置 -Xms2g 限定heap(堆)的大小最小2G,可以通过设置-Xmx来设置堆的上限. Xms -Xms2g:设置JVM初始堆内存为2g.此值可以设置与-Xmx相同,以避免每次垃圾回收完成后JVM重新分配内存. Xmx -Xmx5g:设置JVM最大堆内存为5g.…

LLM 压缩之二: ShortGPT

0. 资源链接 论文: https://arxiv.org/pdf/2403.03853 项目代码: 待开源 1. 背景动机 现有的大语言模型 LLM 推理存在以下问题&#xff1a; LLM 模型因为 scale law 极大的提高模型的预测能力&#xff0c;但是同样带来较大的推理延时&#xff1b;对于 LLM 应用部署带来较大…