001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.nbio.genome.io.fastq; 022 023/** 024 * FASTQ formatted sequence. 025 * 026 * @since 3.0.3 027 */ 028public final class Fastq 029{ 030 /** Description of this FASTQ formatted sequence. */ 031 private final String description; 032 033 /** Sequence for this FASTQ formatted sequence. */ 034 private final String sequence; 035 036 /** Quality scores for this FASTQ formatted sequence. */ 037 private final String quality; 038 039 /** FASTQ sequence format variant for this FASTQ formatted sequence. */ 040 private final FastqVariant variant; 041 042 043 /** 044 * Create a new FASTQ formatted sequence from the specified description, sequence, quality scores, 045 * and sequence format variant. 046 * 047 * @param description description of this FASTQ formatted sequence, must not be null 048 * @param sequence sequence for this FASTQ formatted sequence, must not be null 049 * @param quality quality scores for this FASTQ formatted sequence, must not be null 050 * @param variant FASTQ sequence format variant for this FASTQ formatted sequence, must not be null 051 */ 052 Fastq(final String description, 053 final String sequence, 054 final String quality, 055 final FastqVariant variant) 056 { 057 if (description == null) 058 { 059 throw new IllegalArgumentException("description must not be null"); 060 } 061 if (sequence == null) 062 { 063 throw new IllegalArgumentException("sequence must not be null"); 064 } 065 if (quality == null) 066 { 067 throw new IllegalArgumentException("quality must not be null"); 068 } 069 if (variant == null) 070 { 071 throw new IllegalArgumentException("variant must not be null"); 072 } 073 this.description = description; 074 this.sequence = sequence; 075 this.quality = quality; 076 this.variant = variant; 077 } 078 079 080 /** 081 * Return the description of this FASTQ formatted sequence. 082 * The description will not be null. 083 * 084 * @return the description of this FASTQ formatted sequence 085 */ 086 public String getDescription() 087 { 088 return description; 089 } 090 091 /** 092 * Return the sequence for this FASTQ formatted sequence. 093 * The sequence will not be null. 094 * 095 * @return the sequence for this FASTQ formatted sequence 096 */ 097 public String getSequence() 098 { 099 return sequence; 100 } 101 102 /** 103 * Return the quality scores for this FASTQ formatted sequence. 104 * The quality scores will not be null. 105 * 106 * @return the quality scores for this FASTQ formatted sequence 107 */ 108 public String getQuality() 109 { 110 return quality; 111 } 112 113 /** 114 * Return the FASTQ sequence format variant for this FASTQ formatted sequence. 115 * The FASTQ sequence format variant will not be null. 116 * 117 * @return the FASTQ sequence format variant for this FASTQ formatted sequence 118 */ 119 public FastqVariant getVariant() 120 { 121 return variant; 122 } 123 124 /** 125 * Create and return a new FASTQ formatted sequence from this converted to the 126 * specified FASTQ sequence format variant. 127 * 128 * @since 4.2 129 * @param variant FASTQ sequence format variant, must not be null 130 * @return a new FASTQ formatted sequence from this converted to the 131 * specified FASTQ sequence format variant 132 */ 133 public Fastq convertTo(final FastqVariant variant) 134 { 135 return FastqTools.convert(this, variant); 136 } 137 138 /** 139 * Create and return a new FastqBuilder. 140 * The FastqBuilder will not be null. 141 * 142 * @return a new FastqBuilder 143 */ 144 public static final FastqBuilder builder() 145 { 146 return new FastqBuilder(); 147 } 148 149 /** 150 * Create and return a new FastqBuilder configured from the 151 * specified FASTQ formatted sequence. 152 * The FastqBuilder will not be null. 153 * 154 * @since 6.0.0 155 * @param fastq FASTQ formatted sequence, must not be null 156 * @return a new FastqBuilder configured from the specified FASTQ 157 * formatted sequence 158 */ 159 public static final FastqBuilder builder(final Fastq fastq) 160 { 161 return new FastqBuilder(fastq); 162 } 163}