| 1 |
// Copyright 2016 Google Inc. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
syntax = "proto3"; |
| 16 |
|
| 17 |
package google.genomics.v1; |
| 18 |
|
| 19 |
import "google/api/annotations.proto"; |
| 20 |
import "google/genomics/v1/cigar.proto"; |
| 21 |
import "google/genomics/v1/position.proto"; |
| 22 |
import "google/protobuf/struct.proto"; |
| 23 |
|
| 24 |
option cc_enable_arenas = true; |
| 25 |
option go_package = "google.golang.org/genproto/googleapis/genomics/v1;genomics"; |
| 26 |
option java_multiple_files = true; |
| 27 |
option java_outer_classname = "ReadAlignmentProto"; |
| 28 |
option java_package = "com.google.genomics.v1"; |
| 29 |
|
| 30 |
|
| 31 |
// A linear alignment can be represented by one CIGAR string. Describes the |
| 32 |
// mapped position and local alignment of the read to the reference. |
| 33 |
message LinearAlignment { |
| 34 |
// The position of this alignment. |
| 35 |
Position position = 1; |
| 36 |
|
| 37 |
// The mapping quality of this alignment. Represents how likely |
| 38 |
// the read maps to this position as opposed to other locations. |
| 39 |
// |
| 40 |
// Specifically, this is -10 log10 Pr(mapping position is wrong), rounded to |
| 41 |
// the nearest integer. |
| 42 |
int32 mapping_quality = 2; |
| 43 |
|
| 44 |
// Represents the local alignment of this sequence (alignment matches, indels, |
| 45 |
// etc) against the reference. |
| 46 |
repeated CigarUnit cigar = 3; |
| 47 |
} |
| 48 |
|
| 49 |
// A read alignment describes a linear alignment of a string of DNA to a |
| 50 |
// [reference sequence][google.genomics.v1.Reference], in addition to metadata |
| 51 |
// about the fragment (the molecule of DNA sequenced) and the read (the bases |
| 52 |
// which were read by the sequencer). A read is equivalent to a line in a SAM |
| 53 |
// file. A read belongs to exactly one read group and exactly one |
| 54 |
// [read group set][google.genomics.v1.ReadGroupSet]. |
| 55 |
// |
| 56 |
// For more genomics resource definitions, see [Fundamentals of Google |
| 57 |
// Genomics](https://cloud.google.com/genomics/fundamentals-of-google-genomics) |
| 58 |
// |
| 59 |
// ### Reverse-stranded reads |
| 60 |
// |
| 61 |
// Mapped reads (reads having a non-null `alignment`) can be aligned to either |
| 62 |
// the forward or the reverse strand of their associated reference. Strandedness |
| 63 |
// of a mapped read is encoded by `alignment.position.reverseStrand`. |
| 64 |
// |
| 65 |
// If we consider the reference to be a forward-stranded coordinate space of |
| 66 |
// `[0, reference.length)` with `0` as the left-most position and |
| 67 |
// `reference.length` as the right-most position, reads are always aligned left |
| 68 |
// to right. That is, `alignment.position.position` always refers to the |
| 69 |
// left-most reference coordinate and `alignment.cigar` describes the alignment |
| 70 |
// of this read to the reference from left to right. All per-base fields such as |
| 71 |
// `alignedSequence` and `alignedQuality` share this same left-to-right |
| 72 |
// orientation; this is true of reads which are aligned to either strand. For |
| 73 |
// reverse-stranded reads, this means that `alignedSequence` is the reverse |
| 74 |
// complement of the bases that were originally reported by the sequencing |
| 75 |
// machine. |
| 76 |
// |
| 77 |
// ### Generating a reference-aligned sequence string |
| 78 |
// |
| 79 |
// When interacting with mapped reads, it's often useful to produce a string |
| 80 |
// representing the local alignment of the read to reference. The following |
| 81 |
// pseudocode demonstrates one way of doing this: |
| 82 |
// |
| 83 |
// out = "" |
| 84 |
// offset = 0 |
| 85 |
// for c in read.alignment.cigar { |
| 86 |
// switch c.operation { |
| 87 |
// case "ALIGNMENT_MATCH", "SEQUENCE_MATCH", "SEQUENCE_MISMATCH": |
| 88 |
// out += read.alignedSequence[offset:offset+c.operationLength] |
| 89 |
// offset += c.operationLength |
| 90 |
// break |
| 91 |
// case "CLIP_SOFT", "INSERT": |
| 92 |
// offset += c.operationLength |
| 93 |
// break |
| 94 |
// case "PAD": |
| 95 |
// out += repeat("*", c.operationLength) |
| 96 |
// break |
| 97 |
// case "DELETE": |
| 98 |
// out += repeat("-", c.operationLength) |
| 99 |
// break |
| 100 |
// case "SKIP": |
| 101 |
// out += repeat(" ", c.operationLength) |
| 102 |
// break |
| 103 |
// case "CLIP_HARD": |
| 104 |
// break |
| 105 |
// } |
| 106 |
// } |
| 107 |
// return out |
| 108 |
// |
| 109 |
// ### Converting to SAM's CIGAR string |
| 110 |
// |
| 111 |
// The following pseudocode generates a SAM CIGAR string from the |
| 112 |
// `cigar` field. Note that this is a lossy conversion |
| 113 |
// (`cigar.referenceSequence` is lost). |
| 114 |
// |
| 115 |
// cigarMap = { |
| 116 |
// "ALIGNMENT_MATCH": "M", |
| 117 |
// "INSERT": "I", |
| 118 |
// "DELETE": "D", |
| 119 |
// "SKIP": "N", |
| 120 |
// "CLIP_SOFT": "S", |
| 121 |
// "CLIP_HARD": "H", |
| 122 |
// "PAD": "P", |
| 123 |
// "SEQUENCE_MATCH": "=", |
| 124 |
// "SEQUENCE_MISMATCH": "X", |
| 125 |
// } |
| 126 |
// cigarStr = "" |
| 127 |
// for c in read.alignment.cigar { |
| 128 |
// cigarStr += c.operationLength + cigarMap[c.operation] |
| 129 |
// } |
| 130 |
// return cigarStr |
| 131 |
message Read { |
| 132 |
// The server-generated read ID, unique across all reads. This is different |
| 133 |
// from the `fragmentName`. |
| 134 |
string id = 1; |
| 135 |
|
| 136 |
// The ID of the read group this read belongs to. A read belongs to exactly |
| 137 |
// one read group. This is a server-generated ID which is distinct from SAM's |
| 138 |
// RG tag (for that value, see |
| 139 |
// [ReadGroup.name][google.genomics.v1.ReadGroup.name]). |
| 140 |
string read_group_id = 2; |
| 141 |
|
| 142 |
// The ID of the read group set this read belongs to. A read belongs to |
| 143 |
// exactly one read group set. |
| 144 |
string read_group_set_id = 3; |
| 145 |
|
| 146 |
// The fragment name. Equivalent to QNAME (query template name) in SAM. |
| 147 |
string fragment_name = 4; |
| 148 |
|
| 149 |
// The orientation and the distance between reads from the fragment are |
| 150 |
// consistent with the sequencing protocol (SAM flag 0x2). |
| 151 |
bool proper_placement = 5; |
| 152 |
|
| 153 |
// The fragment is a PCR or optical duplicate (SAM flag 0x400). |
| 154 |
bool duplicate_fragment = 6; |
| 155 |
|
| 156 |
// The observed length of the fragment, equivalent to TLEN in SAM. |
| 157 |
int32 fragment_length = 7; |
| 158 |
|
| 159 |
// The read number in sequencing. 0-based and less than numberReads. This |
| 160 |
// field replaces SAM flag 0x40 and 0x80. |
| 161 |
int32 read_number = 8; |
| 162 |
|
| 163 |
// The number of reads in the fragment (extension to SAM flag 0x1). |
| 164 |
int32 number_reads = 9; |
| 165 |
|
| 166 |
// Whether this read did not pass filters, such as platform or vendor quality |
| 167 |
// controls (SAM flag 0x200). |
| 168 |
bool failed_vendor_quality_checks = 10; |
| 169 |
|
| 170 |
// The linear alignment for this alignment record. This field is null for |
| 171 |
// unmapped reads. |
| 172 |
LinearAlignment alignment = 11; |
| 173 |
|
| 174 |
// Whether this alignment is secondary. Equivalent to SAM flag 0x100. |
| 175 |
// A secondary alignment represents an alternative to the primary alignment |
| 176 |
// for this read. Aligners may return secondary alignments if a read can map |
| 177 |
// ambiguously to multiple coordinates in the genome. By convention, each read |
| 178 |
// has one and only one alignment where both `secondaryAlignment` |
| 179 |
// and `supplementaryAlignment` are false. |
| 180 |
bool secondary_alignment = 12; |
| 181 |
|
| 182 |
// Whether this alignment is supplementary. Equivalent to SAM flag 0x800. |
| 183 |
// Supplementary alignments are used in the representation of a chimeric |
| 184 |
// alignment. In a chimeric alignment, a read is split into multiple |
| 185 |
// linear alignments that map to different reference contigs. The first |
| 186 |
// linear alignment in the read will be designated as the representative |
| 187 |
// alignment; the remaining linear alignments will be designated as |
| 188 |
// supplementary alignments. These alignments may have different mapping |
| 189 |
// quality scores. In each linear alignment in a chimeric alignment, the read |
| 190 |
// will be hard clipped. The `alignedSequence` and |
| 191 |
// `alignedQuality` fields in the alignment record will only |
| 192 |
// represent the bases for its respective linear alignment. |
| 193 |
bool supplementary_alignment = 13; |
| 194 |
|
| 195 |
// The bases of the read sequence contained in this alignment record, |
| 196 |
// **without CIGAR operations applied** (equivalent to SEQ in SAM). |
| 197 |
// `alignedSequence` and `alignedQuality` may be |
| 198 |
// shorter than the full read sequence and quality. This will occur if the |
| 199 |
// alignment is part of a chimeric alignment, or if the read was trimmed. When |
| 200 |
// this occurs, the CIGAR for this read will begin/end with a hard clip |
| 201 |
// operator that will indicate the length of the excised sequence. |
| 202 |
string aligned_sequence = 14; |
| 203 |
|
| 204 |
// The quality of the read sequence contained in this alignment record |
| 205 |
// (equivalent to QUAL in SAM). |
| 206 |
// `alignedSequence` and `alignedQuality` may be shorter than the full read |
| 207 |
// sequence and quality. This will occur if the alignment is part of a |
| 208 |
// chimeric alignment, or if the read was trimmed. When this occurs, the CIGAR |
| 209 |
// for this read will begin/end with a hard clip operator that will indicate |
| 210 |
// the length of the excised sequence. |
| 211 |
repeated int32 aligned_quality = 15; |
| 212 |
|
| 213 |
// The mapping of the primary alignment of the |
| 214 |
// `(readNumber+1)%numberReads` read in the fragment. It replaces |
| 215 |
// mate position and mate strand in SAM. |
| 216 |
Position next_mate_position = 16; |
| 217 |
|
| 218 |
// A map of additional read alignment information. This must be of the form |
| 219 |
// map<string, string[]> (string key mapping to a list of string values). |
| 220 |
map<string, google.protobuf.ListValue> info = 17; |
| 221 |
} |