001/*
002 * Copyright 2024 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.dwc.terms;
017
018import java.io.Serializable;
019import java.net.URI;
020import java.util.Arrays;
021
022/**
023 * All GenSC (Genomics Standards Consortium) Minimum Information about any Sequence (MIxS) terms
024 * with namespace https://w3id.org/mixs/ or https://w3id.org/gensc/terms/MIXS:.
025 *
026 * Note URIs here must use the https://w3id.org/mixs/0000001 form, but we keep the simple name for casual use
027 * (the enum names, the simpleName for CSV headers etc).
028 *
029 * See https://genomicsstandardsconsortium.github.io/mixs/
030 *
031 * See https://github.com/GenomicsStandardsConsortium/mixs/blob/main/src/mixs/schema/mixs.yaml
032 */
033public enum MixsTerm implements Term, AlternativeNames, Serializable {
034  samp_size("0000001"),
035  samp_collect_device("0000002"),
036  isol_growth_condt("0000003"),
037  contam_screen_input("0000005"),
038  wga_amp_kit("0000006"),
039  experimental_factor("0000008"),
040  env_broad_scale("0000012"),
041  env_local_scale("0000013"),
042  env_medium("0000014"),
043  rel_to_oxygen("0000015"),
044  samp_mat_process("0000016"),
045  size_frac("0000017"),
046  subspecf_gen_lin("0000020"),
047  ploidy("0000021"),
048  num_replicons("0000022"),
049  extrachrom_elements("0000023"),
050  estimated_size("0000024"),
051  ref_biomaterial("0000025"),
052  source_mat_id("0000026"),
053  pathogenicity("0000027"),
054  biotic_relationship("0000028"),
055  specific_host("0000029"),
056  host_spec_range("0000030"),
057  host_disease_stat("0000031"),
058  trophic_level("0000032"),
059  propagation("0000033"),
060  encoded_traits("0000034"),
061  source_uvig("0000035"),
062  virus_enrich_appr("0000036"),
063  nucl_acid_ext("0000037"),
064  nucl_acid_amp("0000038"),
065  lib_size("0000039"),
066  lib_reads_seqd("0000040"),
067  lib_layout("0000041", "http://gensc.org/ns/mixs/lib_const_meth"),
068  lib_vector("0000042"),
069  lib_screen("0000043"),
070  @Vocabulary
071  target_gene("0000044"),
072  target_subfragment("0000045"),
073  pcr_primers("0000046"),
074  mid("0000047"),
075  adapters("0000048"),
076  pcr_cond("0000049"),
077  seq_meth("0000050"),
078  seq_quality_check("0000051"),
079  chimera_check("0000052"),
080  tax_ident("0000053"),
081  sc_lysis_method("0000054"),
082  wga_amp_appr("0000055"),
083  assembly_qual("0000056", "http://gensc.org/ns/mixs/finishing_strategy"),
084  assembly_name("0000057", "http://gensc.org/ns/mixs/assembly"),
085  assembly_software("0000058"),
086  annot("0000059", "http://gensc.org/ns/mixs/annot_source"),
087  number_contig("0000060"),
088  feat_pred("0000061"),
089  ref_db("0000062"),
090  sim_search_meth("0000063"),
091  tax_class("0000064"),
092  _16s_recover("0000065", "16s_recover"),
093  _16s_recover_software("0000066", "16s_recover_software"),
094  trnas("0000067"),
095  trna_ext_software("0000068"),
096  compl_score("0000069"),
097  compl_software("0000070"),
098  compl_appr("0000071"),
099  contam_score("0000072"),
100  contam_screen_param("0000073"),
101  decontam_software("0000074"),
102  sort_tech("0000075"),
103  sc_lysis_approach("0000076"),
104  bin_param("0000077"),
105  bin_software("0000078"),
106  reassembly_bin("0000079"),
107  mag_cov_software("0000080"),
108  vir_ident_software("0000081"),
109  pred_genome_type("0000082"),
110  pred_genome_struc("0000083"),
111  detec_type("0000084"),
112  otu_class_appr("0000085"),
113  otu_seq_comp_appr("0000086"),
114  otu_db("0000087"),
115  host_pred_appr("0000088"),
116  host_pred_est_acc("0000089"),
117  sop("0000090"),
118  associated_resource("0000091"),
119  project_name("0000092"),
120  samp_vol_we_dna_ext("0000111"),
121  sieving("0000322"),
122  pool_dna_extracts("0000325"),
123  samp_name("0001107"),
124  samp_collect_method("0001225");
125
126  private static final String PREFIX = "mixs";
127
128  // This is the current and preferred namespace. The URI given on https://w3id.org/mixs/0000001 (which redirects to
129  // https://genomicsstandardsconsortium.github.io/mixs/0000001/) is itself, https://w3id.org/mixs/0000001.
130  private static final String NS = "https://w3id.org/mixs/";
131
132  // This was the namespace before 2022, and was used for the DNA extension.
133  private static final String OLD_NS = "https://w3id.org/gensc/terms/MIXS:";
134
135  // This was a proposed namespace, or may have been the real namespace. It is used in the GGBN extensions.
136  // https://bioregistry.io/registry/mixs says it was temporary, it's possible it was invented by TDWG people.
137  private static final String VERY_OLD_NS = "http://gensc.org/ns/mixs/";
138
139  private static final URI NS_URI = URI.create(NS);
140  private final String mixsIdentifier;
141  public final String[] alternatives;
142
143  @Override
144  public String toString() {
145    return prefixedName();
146  }
147
148  @Override
149  public String simpleName() {
150    if (this == _16s_recover) {
151      return "16s_recover";
152    }
153    if (this == _16s_recover_software) {
154      return "16s_recover_software";
155    }
156    return name();
157  }
158
159  @Override
160  public String[] alternativeNames() {
161    return alternatives;
162  }
163
164  @Override
165  public String qualifiedName() {
166    return namespace() + mixsIdentifier;
167  }
168
169  @Override
170  public boolean isClass() {
171    return false;
172  }
173
174  @Override
175  public String prefix() {
176    return PREFIX;
177  }
178
179  @Override
180  public URI namespace() {
181    return NS_URI;
182  }
183
184  MixsTerm(String mixsIdentifier, String... alternatives) {
185    this.mixsIdentifier = mixsIdentifier;
186    this.alternatives = Arrays.copyOf(alternatives, alternatives.length + 3);
187    this.alternatives[alternatives.length] = name();
188    this.alternatives[alternatives.length+1] = OLD_NS + mixsIdentifier;
189    this.alternatives[alternatives.length+2] = VERY_OLD_NS + name();
190  }
191}