Class: Google::Apis::GenomicsV1::Read
- Inherits:
-
Object
- Object
- Google::Apis::GenomicsV1::Read
- Includes:
- Core::Hashable, Core::JsonObjectSupport
- Defined in:
- generated/google/apis/genomics_v1/classes.rb,
generated/google/apis/genomics_v1/representations.rb,
generated/google/apis/genomics_v1/representations.rb
Overview
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. For more genomics resource definitions, see Fundamentals of Google Genomics
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
Instance Attribute Summary collapse
-
#aligned_quality ⇒ Array<Fixnum>
The quality of the read sequence contained in this alignment record (equivalent to QUAL in SAM).
-
#aligned_sequence ⇒ String
The bases of the read sequence contained in this alignment record, without CIGAR operations applied (equivalent to SEQ in SAM).
-
#alignment ⇒ Google::Apis::GenomicsV1::LinearAlignment
A linear alignment can be represented by one CIGAR string.
-
#duplicate_fragment ⇒ Boolean
(also: #duplicate_fragment?)
The fragment is a PCR or optical duplicate (SAM flag 0x400).
-
#failed_vendor_quality_checks ⇒ Boolean
(also: #failed_vendor_quality_checks?)
Whether this read did not pass filters, such as platform or vendor quality controls (SAM flag 0x200).
-
#fragment_length ⇒ Fixnum
The observed length of the fragment, equivalent to TLEN in SAM.
-
#fragment_name ⇒ String
The fragment name.
-
#id ⇒ String
The server-generated read ID, unique across all reads.
-
#info ⇒ Hash<String,Array<Object>>
A map of additional read alignment information.
-
#next_mate_position ⇒ Google::Apis::GenomicsV1::Position
An abstraction for referring to a genomic position, in relation to some already known reference.
-
#number_reads ⇒ Fixnum
The number of reads in the fragment (extension to SAM flag 0x1).
-
#proper_placement ⇒ Boolean
(also: #proper_placement?)
The orientation and the distance between reads from the fragment are consistent with the sequencing protocol (SAM flag 0x2).
-
#read_group_id ⇒ String
The ID of the read group this read belongs to.
-
#read_group_set_id ⇒ String
The ID of the read group set this read belongs to.
-
#read_number ⇒ Fixnum
The read number in sequencing.
-
#secondary_alignment ⇒ Boolean
(also: #secondary_alignment?)
Whether this alignment is secondary.
-
#supplementary_alignment ⇒ Boolean
(also: #supplementary_alignment?)
Whether this alignment is supplementary.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Read
constructor
A new instance of Read.
-
#update!(**args) ⇒ Object
Update properties of this object.
Methods included from Core::JsonObjectSupport
Methods included from Core::Hashable
Constructor Details
#initialize(**args) ⇒ Read
Returns a new instance of Read
2988 2989 2990 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2988 def initialize(**args) update!(**args) end |
Instance Attribute Details
#aligned_quality ⇒ Array<Fixnum>
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.
Corresponds to the JSON property alignedQuality
2902 2903 2904 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2902 def aligned_quality @aligned_quality end |
#aligned_sequence ⇒ String
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.
Corresponds to the JSON property alignedSequence
2964 2965 2966 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2964 def aligned_sequence @aligned_sequence end |
#alignment ⇒ Google::Apis::GenomicsV1::LinearAlignment
A linear alignment can be represented by one CIGAR string. Describes the
mapped position and local alignment of the read to the reference.
Corresponds to the JSON property alignment
2908 2909 2910 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2908 def alignment @alignment end |
#duplicate_fragment ⇒ Boolean Also known as: duplicate_fragment?
The fragment is a PCR or optical duplicate (SAM flag 0x400).
Corresponds to the JSON property duplicateFragment
2946 2947 2948 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2946 def duplicate_fragment @duplicate_fragment end |
#failed_vendor_quality_checks ⇒ Boolean Also known as: failed_vendor_quality_checks?
Whether this read did not pass filters, such as platform or vendor quality
controls (SAM flag 0x200).
Corresponds to the JSON property failedVendorQualityChecks
2890 2891 2892 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2890 def failed_vendor_quality_checks @failed_vendor_quality_checks end |
#fragment_length ⇒ Fixnum
The observed length of the fragment, equivalent to TLEN in SAM.
Corresponds to the JSON property fragmentLength
2884 2885 2886 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2884 def fragment_length @fragment_length end |
#fragment_name ⇒ String
The fragment name. Equivalent to QNAME (query template name) in SAM.
Corresponds to the JSON property fragmentName
2935 2936 2937 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2935 def fragment_name @fragment_name end |
#id ⇒ String
The server-generated read ID, unique across all reads. This is different
from the fragmentName.
Corresponds to the JSON property id
2919 2920 2921 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2919 def id @id end |
#info ⇒ Hash<String,Array<Object>>
A map of additional read alignment information. This must be of the form
mapinfo
2978 2979 2980 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2978 def info @info end |
#next_mate_position ⇒ Google::Apis::GenomicsV1::Position
An abstraction for referring to a genomic position, in relation to some
already known reference. For now, represents a genomic position as a
reference name, a base number on that reference (0-based), and a
determination of forward or reverse strand.
Corresponds to the JSON property nextMatePosition
2986 2987 2988 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2986 def next_mate_position @next_mate_position end |
#number_reads ⇒ Fixnum
The number of reads in the fragment (extension to SAM flag 0x1).
Corresponds to the JSON property numberReads
2913 2914 2915 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2913 def number_reads @number_reads end |
#proper_placement ⇒ Boolean Also known as: proper_placement?
The orientation and the distance between reads from the fragment are
consistent with the sequencing protocol (SAM flag 0x2).
Corresponds to the JSON property properPlacement
2878 2879 2880 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2878 def proper_placement @proper_placement end |
#read_group_id ⇒ String
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).
Corresponds to the JSON property readGroupId
2972 2973 2974 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2972 def read_group_id @read_group_id end |
#read_group_set_id ⇒ String
The ID of the read group set this read belongs to. A read belongs to
exactly one read group set.
Corresponds to the JSON property readGroupSetId
2941 2942 2943 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2941 def read_group_set_id @read_group_set_id end |
#read_number ⇒ Fixnum
The read number in sequencing. 0-based and less than numberReads. This
field replaces SAM flag 0x40 and 0x80.
Corresponds to the JSON property readNumber
2953 2954 2955 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2953 def read_number @read_number end |
#secondary_alignment ⇒ Boolean Also known as: secondary_alignment?
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.
Corresponds to the JSON property secondaryAlignment
2929 2930 2931 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2929 def secondary_alignment @secondary_alignment end |
#supplementary_alignment ⇒ Boolean Also known as: supplementary_alignment?
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.
Corresponds to the JSON property supplementaryAlignment
2871 2872 2873 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2871 def supplementary_alignment @supplementary_alignment end |
Instance Method Details
#update!(**args) ⇒ Object
Update properties of this object
2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 |
# File 'generated/google/apis/genomics_v1/classes.rb', line 2993 def update!(**args) @supplementary_alignment = args[:supplementary_alignment] if args.key?(:supplementary_alignment) @proper_placement = args[:proper_placement] if args.key?(:proper_placement) @fragment_length = args[:fragment_length] if args.key?(:fragment_length) @failed_vendor_quality_checks = args[:failed_vendor_quality_checks] if args.key?(:failed_vendor_quality_checks) @aligned_quality = args[:aligned_quality] if args.key?(:aligned_quality) @alignment = args[:alignment] if args.key?(:alignment) @number_reads = args[:number_reads] if args.key?(:number_reads) @id = args[:id] if args.key?(:id) @secondary_alignment = args[:secondary_alignment] if args.key?(:secondary_alignment) @fragment_name = args[:fragment_name] if args.key?(:fragment_name) @read_group_set_id = args[:read_group_set_id] if args.key?(:read_group_set_id) @duplicate_fragment = args[:duplicate_fragment] if args.key?(:duplicate_fragment) @read_number = args[:read_number] if args.key?(:read_number) @aligned_sequence = args[:aligned_sequence] if args.key?(:aligned_sequence) @read_group_id = args[:read_group_id] if args.key?(:read_group_id) @info = args[:info] if args.key?(:info) @next_mate_position = args[:next_mate_position] if args.key?(:next_mate_position) end |