# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.Genomics.V1.Model.Read do @moduledoc """ A read alignment describes a linear alignment of a string of DNA to a reference sequence, in addition to metadata about the fragment (the molecule of DNA sequenced) and the read (the bases which were read by the sequencer). A read is equivalent to a line in a SAM file. A read belongs to exactly one read group and exactly one read group set. ### Reverse-stranded reads Mapped reads (reads having a non-null `alignment`) can be aligned to either the forward or the reverse strand of their associated reference. Strandedness of a mapped read is encoded by `alignment.position.reverseStrand`. If we consider the reference to be a forward-stranded coordinate space of `[0, reference.length)` with `0` as the left-most position and `reference.length` as the right-most position, reads are always aligned left to right. That is, `alignment.position.position` always refers to the left-most reference coordinate and `alignment.cigar` describes the alignment of this read to the reference from left to right. All per-base fields such as `alignedSequence` and `alignedQuality` share this same left-to-right orientation; this is true of reads which are aligned to either strand. For reverse-stranded reads, this means that `alignedSequence` is the reverse complement of the bases that were originally reported by the sequencing machine. ### Generating a reference-aligned sequence string When interacting with mapped reads, it's often useful to produce a string representing the local alignment of the read to reference. The following pseudocode demonstrates one way of doing this: out = \"\" offset = 0 for c in read.alignment.cigar { switch c.operation { case \"ALIGNMENT_MATCH\", \"SEQUENCE_MATCH\", \"SEQUENCE_MISMATCH\": out += read.alignedSequence[offset:offset+c.operationLength] offset += c.operationLength break case \"CLIP_SOFT\", \"INSERT\": offset += c.operationLength break case \"PAD\": out += repeat(\"*\", c.operationLength) break case \"DELETE\": out += repeat(\"-\", c.operationLength) break case \"SKIP\": out += repeat(\" \", c.operationLength) break case \"CLIP_HARD\": break } } return out ### Converting to SAM's CIGAR string The following pseudocode generates a SAM CIGAR string from the `cigar` field. Note that this is a lossy conversion (`cigar.referenceSequence` is lost). cigarMap = { \"ALIGNMENT_MATCH\": \"M\", \"INSERT\": \"I\", \"DELETE\": \"D\", \"SKIP\": \"N\", \"CLIP_SOFT\": \"S\", \"CLIP_HARD\": \"H\", \"PAD\": \"P\", \"SEQUENCE_MATCH\": \"=\", \"SEQUENCE_MISMATCH\": \"X\", } cigarStr = \"\" for c in read.alignment.cigar { cigarStr += c.operationLength + cigarMap[c.operation] } return cigarStr ## Attributes - info (%{optional(String.t) => [ErrorUnknown]}): A map of additional read alignment information. This must be of the form map<string, string[]> (string key mapping to a list of string values). Defaults to: `null`. - alignedQuality ([integer()]): The quality of the read sequence contained in this alignment record (equivalent to QUAL in SAM). `alignedSequence` and `alignedQuality` may be shorter than the full read sequence and quality. This will occur if the alignment is part of a chimeric alignment, or if the read was trimmed. When this occurs, the CIGAR for this read will begin/end with a hard clip operator that will indicate the length of the excised sequence. Defaults to: `null`. - alignedSequence (String.t): The bases of the read sequence contained in this alignment record, **without CIGAR operations applied** (equivalent to SEQ in SAM). `alignedSequence` and `alignedQuality` may be shorter than the full read sequence and quality. This will occur if the alignment is part of a chimeric alignment, or if the read was trimmed. When this occurs, the CIGAR for this read will begin/end with a hard clip operator that will indicate the length of the excised sequence. Defaults to: `null`. - alignment (LinearAlignment): The linear alignment for this alignment record. This field is null for unmapped reads. Defaults to: `null`. - duplicateFragment (boolean()): The fragment is a PCR or optical duplicate (SAM flag 0x400). Defaults to: `null`. - failedVendorQualityChecks (boolean()): Whether this read did not pass filters, such as platform or vendor quality controls (SAM flag 0x200). Defaults to: `null`. - fragmentLength (integer()): The observed length of the fragment, equivalent to TLEN in SAM. Defaults to: `null`. - fragmentName (String.t): The fragment name. Equivalent to QNAME (query template name) in SAM. Defaults to: `null`. - id (String.t): The server-generated read ID, unique across all reads. This is different from the `fragmentName`. Defaults to: `null`. - nextMatePosition (Position): The mapping of the primary alignment of the `(readNumber+1)%numberReads` read in the fragment. It replaces mate position and mate strand in SAM. Defaults to: `null`. - numberReads (integer()): The number of reads in the fragment (extension to SAM flag 0x1). Defaults to: `null`. - properPlacement (boolean()): The orientation and the distance between reads from the fragment are consistent with the sequencing protocol (SAM flag 0x2). Defaults to: `null`. - readGroupId (String.t): The ID of the read group this read belongs to. A read belongs to exactly one read group. This is a server-generated ID which is distinct from SAM's RG tag (for that value, see ReadGroup.name). Defaults to: `null`. - readGroupSetId (String.t): The ID of the read group set this read belongs to. A read belongs to exactly one read group set. Defaults to: `null`. - readNumber (integer()): The read number in sequencing. 0-based and less than numberReads. This field replaces SAM flag 0x40 and 0x80. Defaults to: `null`. - secondaryAlignment (boolean()): Whether this alignment is secondary. Equivalent to SAM flag 0x100. A secondary alignment represents an alternative to the primary alignment for this read. Aligners may return secondary alignments if a read can map ambiguously to multiple coordinates in the genome. By convention, each read has one and only one alignment where both `secondaryAlignment` and `supplementaryAlignment` are false. Defaults to: `null`. - supplementaryAlignment (boolean()): Whether this alignment is supplementary. Equivalent to SAM flag 0x800. Supplementary alignments are used in the representation of a chimeric alignment. In a chimeric alignment, a read is split into multiple linear alignments that map to different reference contigs. The first linear alignment in the read will be designated as the representative alignment; the remaining linear alignments will be designated as supplementary alignments. These alignments may have different mapping quality scores. In each linear alignment in a chimeric alignment, the read will be hard clipped. The `alignedSequence` and `alignedQuality` fields in the alignment record will only represent the bases for its respective linear alignment. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :info => map(), :alignedQuality => list(any()), :alignedSequence => any(), :alignment => GoogleApi.Genomics.V1.Model.LinearAlignment.t(), :duplicateFragment => any(), :failedVendorQualityChecks => any(), :fragmentLength => any(), :fragmentName => any(), :id => any(), :nextMatePosition => GoogleApi.Genomics.V1.Model.Position.t(), :numberReads => any(), :properPlacement => any(), :readGroupId => any(), :readGroupSetId => any(), :readNumber => any(), :secondaryAlignment => any(), :supplementaryAlignment => any() } field(:info, type: :map) field(:alignedQuality, type: :list) field(:alignedSequence) field(:alignment, as: GoogleApi.Genomics.V1.Model.LinearAlignment) field(:duplicateFragment) field(:failedVendorQualityChecks) field(:fragmentLength) field(:fragmentName) field(:id) field(:nextMatePosition, as: GoogleApi.Genomics.V1.Model.Position) field(:numberReads) field(:properPlacement) field(:readGroupId) field(:readGroupSetId) field(:readNumber) field(:secondaryAlignment) field(:supplementaryAlignment) end defimpl Poison.Decoder, for: GoogleApi.Genomics.V1.Model.Read do def decode(value, options) do GoogleApi.Genomics.V1.Model.Read.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Genomics.V1.Model.Read do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end