| 1 |
/*=========================================================================== |
| 2 |
* |
| 3 |
* PUBLIC DOMAIN NOTICE |
| 4 |
* National Center for Biotechnology Information |
| 5 |
* |
| 6 |
* This software/database is a "United States Government Work" under the |
| 7 |
* terms of the United States Copyright Act. It was written as part of |
| 8 |
* the author's official duties as a United States Government employee and |
| 9 |
* thus cannot be copyrighted. This software/database is freely available |
| 10 |
* to the public for use. The National Library of Medicine and the U.S. |
| 11 |
* Government have not placed any restriction on its use or reproduction. |
| 12 |
* |
| 13 |
* Although all reasonable efforts have been taken to ensure the accuracy |
| 14 |
* and reliability of the software and data, the NLM and the U.S. |
| 15 |
* Government do not and cannot warrant the performance or results that |
| 16 |
* may be obtained by using this software or data. The NLM and the U.S. |
| 17 |
* Government disclaim all warranties, express or implied, including |
| 18 |
* warranties of performance, merchantability or fitness for any particular |
| 19 |
* purpose. |
| 20 |
* |
| 21 |
* Please cite the author in any work or product based on this material. |
| 22 |
* |
| 23 |
* =========================================================================== |
| 24 |
* |
| 25 |
*/ |
| 26 |
|
| 27 |
/*========================================================================== |
| 28 |
* VDB Alignment types, functions and tables |
| 29 |
*/ |
| 30 |
version 1; |
| 31 |
|
| 32 |
include 'vdb/vdb.vschema'; |
| 33 |
include 'ncbi/seq.vschema'; |
| 34 |
include 'ncbi/sra.vschema'; |
| 35 |
include 'ncbi/stats.vschema'; |
| 36 |
include 'align/seq.vschema'; |
| 37 |
include 'align/qstat.vschema'; |
| 38 |
include 'sra/abi.vschema'; |
| 39 |
include 'align/mate-cache.vschema'; |
| 40 |
|
| 41 |
|
| 42 |
/*-------------------------------------------------------------------------- |
| 43 |
* data types |
| 44 |
*/ |
| 45 |
|
| 46 |
/* ploidy |
| 47 |
* the number of sets of chromosomes in a cell |
| 48 |
*/ |
| 49 |
typedef U32 NCBI:align:ploidy; |
| 50 |
|
| 51 |
/* ro_type |
| 52 |
* the type of event causing ref-offset |
| 53 |
*/ |
| 54 |
typedef U8 NCBI:align:ro_type; |
| 55 |
|
| 56 |
const NCBI:align:ro_type NCBI:align:ro_normal = 0; // normal ref-offset |
| 57 |
const NCBI:align:ro_type NCBI:align:ro_soft_clip = 1; // soft-clipping |
| 58 |
const NCBI:align:ro_type NCBI:align:ro_intron_plus = 2; // intron on positive strand |
| 59 |
const NCBI:align:ro_type NCBI:align:ro_intron_minus = 3; // intron on negative strand |
| 60 |
const NCBI:align:ro_type NCBI:align:ro_intron_unknown = 4; // intron strand not specified |
| 61 |
const NCBI:align:ro_type NCBI:align:ro_complete_genomics = 5; // |
| 62 |
|
| 63 |
|
| 64 |
/*-------------------------------------------------------------------------- |
| 65 |
* functions |
| 66 |
*/ |
| 67 |
|
| 68 |
|
| 69 |
/* cigar |
| 70 |
* construct "cigar" alignment string or length arrays |
| 71 |
* |
| 72 |
* "ctype" [ CONST ] - select variant of format |
| 73 |
* 0 => both matches and mismatches represented as M |
| 74 |
* 1 => matches represented as '=' mismatches as 'X' |
| 75 |
* |
| 76 |
* "has_mismatch" [ DATA ] - a boolean for each base in aligned sequence |
| 77 |
* where a value of false means the base aligned to the reference |
| 78 |
* |
| 79 |
* "has_ref_offset" [ DATA ] - a boolean for each base in the aligned sequence |
| 80 |
* where a value of true means there is a corresponding offset to position on reference |
| 81 |
* |
| 82 |
* "ref_offset" [ DATA ] - a packed sequence of signed offsets to aligned position |
| 83 |
* one entry for every true in "has_ref_offset" |
| 84 |
* |
| 85 |
* "read_len" [ DATA ] - v2: elem_count defines PLOIDY and values are an actual length of reads in spot |
| 86 |
*/ |
| 87 |
extern function |
| 88 |
ascii NCBI:align:cigar #1 < U8 ctype > ( bool has_mismatch, bool has_ref_offset, |
| 89 |
I32 ref_offset, * INSDC:coord:len ref_len ) = ALIGN:cigar; |
| 90 |
|
| 91 |
/* history: |
| 92 |
* 2.1 - added "ref_offset_type" optional parameter |
| 93 |
* NB - reverting to 2.0 due to linker bug in older code |
| 94 |
*/ |
| 95 |
extern function < type T > |
| 96 |
T NCBI:align:cigar #2.0 < U8 ctype > ( bool has_mismatch, bool has_ref_offset, |
| 97 |
I32 ref_offset, INSDC:coord:len read_len, * INSDC:coord:len ref_len, NCBI:align:ro_type ref_offset_type ) |
| 98 |
= ALIGN:cigar_2; |
| 99 |
|
| 100 |
extern function U32 NCBI:align:edit_distance #1 |
| 101 |
( bool has_mismatch, bool has_ref_offset, I32 ref_offset ); |
| 102 |
|
| 103 |
extern function U32 NCBI:align:edit_distance #2 |
| 104 |
( bool has_mismatch, bool has_ref_offset, I32 ref_offset, INSDC:coord:len ref_len, *INSDC:coord:len read_len) |
| 105 |
= NCBI:align:edit_distance_2; |
| 106 |
|
| 107 |
extern function U32 NCBI:align:edit_distance #3 |
| 108 |
( bool has_mismatch, bool has_ref_offset, I32 ref_offset, NCBI:align:ro_type ref_offset_type, INSDC:coord:len read_len) |
| 109 |
= NCBI:align:edit_distance_3; |
| 110 |
|
| 111 |
/* rna_orientation |
| 112 |
* reads column REF_OFFSET_TYPE |
| 113 |
* returns '+' if has: |
| 114 |
* at least one NCBI:align:ro_intron_plus |
| 115 |
* none of NCBI:align:ro_intron_minus |
| 116 |
* returns '-' if has: |
| 117 |
* at least one NCBI:align:ro_intron_minus |
| 118 |
* none of NCBI:align:ro_intron_plus |
| 119 |
* returns empty string otherwise |
| 120 |
*/ |
| 121 |
extern function |
| 122 |
ascii NCBI:align:rna_orientation #1 ( NCBI:align:ro_type ref_offset_type ); |
| 123 |
|
| 124 |
/* project_from_sequence |
| 125 |
* projects column from SEQUENCE |
| 126 |
* |
| 127 |
* "T" [ TYPE ] |
| 128 |
* |
| 129 |
* "col" [ CONST ] |
| 130 |
* "use_read_len" [ CONST ] whether subset by read_len or by read_id only |
| 131 |
* |
| 132 |
* "seq_spot_id" [ DATA ] |
| 133 |
* |
| 134 |
* "seq_read_id" [ DATA ] |
| 135 |
*/ |
| 136 |
extern function < type T > |
| 137 |
T NCBI:align:project_from_sequence #1 < ascii col> ( I64 seq_spot_id, INSDC:coord:one seq_read_id ) |
| 138 |
= ALIGN:project_from_sequence; |
| 139 |
|
| 140 |
|
| 141 |
/* align_restore_read |
| 142 |
* restores read by applying alignment-based difference to ref_read |
| 143 |
* |
| 144 |
* "ref_read" [ DATA ] |
| 145 |
* |
| 146 |
* "has_mismatch" [ DATA ] and "mismatch" [ DATA ] |
| 147 |
* |
| 148 |
* "has_ref_offset" [ DATA ] and "ref_offset" [ DATA ] |
| 149 |
*/ |
| 150 |
extern function |
| 151 |
INSDC:4na:bin NCBI:align:align_restore_read #1 ( INSDC:4na:bin ref_read, bool has_mismatch, |
| 152 |
INSDC:4na:bin mismatch, bool has_ref_offset, I32 ref_offset * INSDC:coord:len read_len) |
| 153 |
= ALIGN:align_restore_read; |
| 154 |
|
| 155 |
|
| 156 |
/* raw_restore_read |
| 157 |
* restores read by applying alignment-based difference to align_read |
| 158 |
* |
| 159 |
* "align_read" [ DATA ] |
| 160 |
* |
| 161 |
* "ref_orientation" [ DATA ] |
| 162 |
*/ |
| 163 |
extern function |
| 164 |
INSDC:4na:bin NCBI:align:raw_restore_read #1 ( INSDC:4na:bin align_read, bool ref_orientation ) |
| 165 |
= ALIGN:raw_restore_read; |
| 166 |
|
| 167 |
|
| 168 |
/* raw_restore_qual |
| 169 |
* restores quality by applying alignment-based difference to align_qual |
| 170 |
* |
| 171 |
* "align_qual" [ DATA ] |
| 172 |
* |
| 173 |
* "ref_orientation" [ DATA ] |
| 174 |
*/ |
| 175 |
extern function |
| 176 |
INSDC:quality:phred NCBI:align:raw_restore_qual #1 ( INSDC:quality:phred align_qual, bool ref_orientation ); |
| 177 |
|
| 178 |
|
| 179 |
/* ref_sub_select |
| 180 |
* projects reference from sequence |
| 181 |
* |
| 182 |
* "id" [ DATA ] |
| 183 |
* |
| 184 |
* "start" [ DATA ] and "len" [ DATA ] |
| 185 |
* |
| 186 |
* "ref_ploidy" [ DATA, OPTIONAL ] |
| 187 |
*/ |
| 188 |
extern function |
| 189 |
INSDC:4na:bin NCBI:align:ref_sub_select #1 ( I64 id, INSDC:coord:zero start, |
| 190 |
INSDC:coord:len len * U32 ref_ploidy) |
| 191 |
= ALIGN:ref_sub_select; |
| 192 |
|
| 193 |
|
| 194 |
/* ref_restore_read |
| 195 |
* restores read from central storage |
| 196 |
* |
| 197 |
* "cmp_rd" [ DATA ] |
| 198 |
* |
| 199 |
* "seq_id" [ DATA ] |
| 200 |
* |
| 201 |
* "seq_start" [ DATA ] and "seq_len" [ DATA ] |
| 202 |
*/ |
| 203 |
extern function |
| 204 |
INSDC:4na:bin NCBI:align:ref_restore_read #1 ( INSDC:4na:bin cmp_rd, ascii seq_id, |
| 205 |
INSDC:coord:one seq_start, INSDC:coord:len seq_len) |
| 206 |
= ALIGN:ref_restore_read; |
| 207 |
|
| 208 |
|
| 209 |
/* seq_restore_read |
| 210 |
* projects read from align_deflate table to SEQUENCE |
| 211 |
* |
| 212 |
* "cmp_rd" [ DATA ] |
| 213 |
* |
| 214 |
* "align_id" [ DATA ] |
| 215 |
* |
| 216 |
* "read_len" [ DATA ] |
| 217 |
* |
| 218 |
* "rd_type" [ DATA ] |
| 219 |
*/ |
| 220 |
extern function |
| 221 |
INSDC:4na:bin NCBI:align:seq_restore_read #1 ( INSDC:4na:bin cmp_rd, I64 align_id, |
| 222 |
INSDC:coord:len read_len, INSDC:SRA:xread_type rd_type ) |
| 223 |
= ALIGN:seq_restore_read; |
| 224 |
|
| 225 |
|
| 226 |
/* seq_restore_linkage_group |
| 227 |
* projects LINKAGE_GROUP from PRIMARY_ALIGNMENT table to SEQUENCE |
| 228 |
* |
| 229 |
* "cmp_linkage_group" [ DATA ] |
| 230 |
* |
| 231 |
* "align_id" [ DATA ] |
| 232 |
*/ |
| 233 |
extern function |
| 234 |
ascii NCBI:align:seq_restore_linkage_group #1 ( ascii cmp_linkage_group, |
| 235 |
I64 align_id ) |
| 236 |
= ALIGN:seq_restore_linkage_group; |
| 237 |
|
| 238 |
|
| 239 |
/* generate_has_mismatch |
| 240 |
* generates has mismatch by doing actual compare of reference and subject, |
| 241 |
* *ref_offsets move comparisons reference-wise |
| 242 |
* |
| 243 |
* "reference" [ DATA ] |
| 244 |
* |
| 245 |
* "subject" [ DATA ] |
| 246 |
* |
| 247 |
* "has_ref_offset" [ DATA ] |
| 248 |
* |
| 249 |
* "ref_offset" [ DATA ] |
| 250 |
*/ |
| 251 |
extern function |
| 252 |
bool NCBI:align:generate_has_mismatch #1 ( INSDC:4na:bin reference, |
| 253 |
INSDC:4na:bin subject, bool has_ref_offset, I32 ref_offset) |
| 254 |
= ALIGN:generate_has_mismatch; |
| 255 |
|
| 256 |
|
| 257 |
/* generate_mismatch |
| 258 |
* |
| 259 |
* "reference" [ DATA ] |
| 260 |
* |
| 261 |
* "subject" [ DATA ] |
| 262 |
* |
| 263 |
* "has_ref_offset" [ DATA ] |
| 264 |
* |
| 265 |
* "ref_offset" [ DATA ] |
| 266 |
*/ |
| 267 |
extern function |
| 268 |
INSDC:4na:bin NCBI:align:generate_mismatch #1 ( INSDC:4na:bin reference, |
| 269 |
INSDC:4na:bin subject, bool has_ref_offset, I32 ref_offset ) |
| 270 |
= ALIGN:generate_mismatch; |
| 271 |
|
| 272 |
|
| 273 |
/* ref_pos |
| 274 |
* retrieves the alignment's positions on the reference |
| 275 |
* one per PLOIDY |
| 276 |
* |
| 277 |
* "ref_id" [ DATA ] |
| 278 |
* |
| 279 |
* "ref_start" [ DATA ] - one per PLOIDY |
| 280 |
*/ |
| 281 |
extern function |
| 282 |
INSDC:coord:zero NCBI:align:ref_pos #1 ( I64 ref_id, INSDC:coord:zero ref_start ); |
| 283 |
|
| 284 |
|
| 285 |
/* ref_name |
| 286 |
* retrieve the name from the reference |
| 287 |
* |
| 288 |
* "ref_id" [ DATA ] |
| 289 |
*/ |
| 290 |
extern function |
| 291 |
ascii NCBI:align:ref_name #1 ( I64 ref_id ); |
| 292 |
|
| 293 |
|
| 294 |
/* ref_seq_id |
| 295 |
* retrieve the seq_id from the reference |
| 296 |
* |
| 297 |
* "ref_id" [ DATA ] |
| 298 |
*/ |
| 299 |
extern function |
| 300 |
ascii NCBI:align:ref_seq_id #1 ( I64 ref_id ); |
| 301 |
|
| 302 |
|
| 303 |
/* local_ref_id |
| 304 |
* convert global ref_start into ref_id |
| 305 |
*/ |
| 306 |
extern function |
| 307 |
I64 NCBI:align:local_ref_id #1 ( U64 global_ref_start ); |
| 308 |
|
| 309 |
|
| 310 |
/* global_ref_id |
| 311 |
* convert global ref_start into ref_id |
| 312 |
*/ |
| 313 |
extern function |
| 314 |
INSDC:coord:zero NCBI:align:local_ref_start #1 ( U64 global_ref_start ); |
| 315 |
|
| 316 |
/* not_my_row |
| 317 |
* removes current row_id from the list |
| 318 |
*/ |
| 319 |
extern function I64 NCBI:align:not_my_row #1 ( I64 list ); |
| 320 |
|
| 321 |
/* template_len |
| 322 |
* compute template length, i.e. the distance from the left-most to the |
| 323 |
* right-most matching reference position |
| 324 |
*/ |
| 325 |
extern function I32 NCBI:align:template_len #1 ( |
| 326 |
INSDC:coord:zero pos, INSDC:coord:zero mate_pos, |
| 327 |
INSDC:coord:len reflen, INSDC:coord:len mate_reflen, |
| 328 |
ascii ref_name, ascii mate_ref_name, INSDC:coord:one read_id); |
| 329 |
|
| 330 |
/* get_sam_flags |
| 331 |
* compute the flags that would be in a SAM file |
| 332 |
* |
| 333 |
* version 1 works with full Alignment databases. |
| 334 |
* version 2 works with Alignment databases that have had SEQUENCE removed. |
| 335 |
*/ |
| 336 |
extern function U32 NCBI:align:get_sam_flags #1 ( |
| 337 |
INSDC:coord:len read_len, INSDC:coord:one read_id, I32 template_len, |
| 338 |
bool strand, bool mate_strand, bool is_secondary, * INSDC:SRA:read_filter filter); |
| 339 |
|
| 340 |
extern function U32 NCBI:align:get_sam_flags #2 ( |
| 341 |
I64 mate_id, INSDC:coord:one read_id, I32 template_len, |
| 342 |
bool strand, bool mate_strand, bool is_secondary, * INSDC:SRA:read_filter filter) |
| 343 |
= NCBI:align:get_sam_flags_2; |
| 344 |
|
| 345 |
/* get_left_soft_clip |
| 346 |
* compute the length of the soft clip on the left edge of the alignment |
| 347 |
*/ |
| 348 |
extern function INSDC:coord:len NCBI:align:get_left_soft_clip #1 |
| 349 |
( bool has_ref_offset, I32 ref_offset ); |
| 350 |
|
| 351 |
extern function INSDC:coord:len NCBI:align:get_left_soft_clip #2 |
| 352 |
( bool has_ref_offset, I32 ref_offset, INSDC:coord:len read_len ) |
| 353 |
= NCBI:align:get_left_soft_clip_2; |
| 354 |
|
| 355 |
/* get_right_soft_clip |
| 356 |
* compute the length of the soft clip on the right edge of the alignment |
| 357 |
*/ |
| 358 |
extern function INSDC:coord:len NCBI:align:get_right_soft_clip #1 |
| 359 |
( bool has_mismatch, INSDC:coord:len left_clip * bool has_ref_offset ); |
| 360 |
|
| 361 |
extern function INSDC:coord:len NCBI:align:get_right_soft_clip #2 |
| 362 |
( bool has_mismatch, INSDC:coord:len left_clip, bool has_ref_offset, I32 ref_offset ) |
| 363 |
= NCBI:align:get_right_soft_clip_2; |
| 364 |
|
| 365 |
extern function INSDC:coord:len NCBI:align:get_right_soft_clip #3 |
| 366 |
( bool has_ref_offset, I32 ref_offset, INSDC:coord:len ref_len ) |
| 367 |
= NCBI:align:get_right_soft_clip_3; |
| 368 |
|
| 369 |
extern function INSDC:coord:len NCBI:align:get_right_soft_clip #4 |
| 370 |
( bool has_ref_offset, I32 ref_offset, INSDC:coord:len read_len, INSDC:coord:len ref_len ) |
| 371 |
= NCBI:align:get_right_soft_clip_4; |
| 372 |
|
| 373 |
extern function INSDC:coord:len NCBI:align:get_right_soft_clip #5 |
| 374 |
( bool has_ref_offset, I32 ref_offset, NCBI:align:ro_type ref_offset_type, INSDC:coord:len read_len ) |
| 375 |
= NCBI:align:get_right_soft_clip_5; |
| 376 |
|
| 377 |
/* get_clipped_cigar |
| 378 |
* compute the CIGAR string with the soft clipping removed |
| 379 |
*/ |
| 380 |
extern function ascii NCBI:align:get_clipped_cigar #1 ( ascii cigar ); |
| 381 |
|
| 382 |
extern function < type T > |
| 383 |
T NCBI:align:get_clipped_cigar #2 ( ascii cigar, INSDC:coord:len cigar_len ) = NCBI:align:get_clipped_cigar_2; |
| 384 |
|
| 385 |
/* get_clipped_ref_offset |
| 386 |
* compute the reference offsets with the soft clipping removed |
| 387 |
*/ |
| 388 |
extern function I32 NCBI:align:get_clipped_ref_offset #1 |
| 389 |
( bool has_ref_offset, I32 ref_offset ); |
| 390 |
|
| 391 |
/* clip |
| 392 |
* remove the soft clipped bases (or qualities, or has_mismatch, or cetera) |
| 393 |
* works with things whose lengths are the same as SEQUENCE.READ |
| 394 |
*/ |
| 395 |
extern function < type T > T NCBI:align:clip #1 |
| 396 |
( T object, INSDC:coord:len left_clip, INSDC:coord:len right_clip); |
| 397 |
|
| 398 |
extern function < type T > T NCBI:align:clip #2 |
| 399 |
( T object, INSDC:coord:len read_len, INSDC:coord:len left_clip, INSDC:coord:len right_clip) |
| 400 |
= NCBI:align:clip_2; |
| 401 |
|
| 402 |
/* get_ref_len |
| 403 |
* compute reference length from alignment information |
| 404 |
*/ |
| 405 |
extern function INSDC:coord:len NCBI:align:get_ref_len #1 |
| 406 |
( bool has_ref_offset, I32 ref_offset, * INSDC:coord:len right_clip ); |
| 407 |
|
| 408 |
extern function INSDC:coord:len NCBI:align:get_ref_len_2 #2 |
| 409 |
( bool has_ref_offset, I32 ref_offset) |
| 410 |
= NCBI:align:get_ref_len_2; |
| 411 |
|
| 412 |
|
| 413 |
/* get_mismatch_read |
| 414 |
* generate the READ with matching bases replaced with '=' |
| 415 |
*/ |
| 416 |
extern function ascii NCBI:align:get_mismatch_read #1 |
| 417 |
( bool has_mismatch, INSDC:dna:text mismatch ); |
| 418 |
|
| 419 |
/* get_ref_mismatch |
| 420 |
* shows mismatch positions in reference space |
| 421 |
*/ |
| 422 |
function bool NCBI:align:get_ref_mismatch #1 |
| 423 |
( bool has_mismatch, bool has_ref_offset, I32 ref_offset, |
| 424 |
INSDC:coord:len ref_len ); |
| 425 |
|
| 426 |
/* get_ref_insert |
| 427 |
* shows positions of inserts in reference space |
| 428 |
* i.e. an insert occurs between each pair of true's |
| 429 |
*/ |
| 430 |
function bool NCBI:align:get_ref_insert #1 |
| 431 |
( bool has_mismatch, bool has_ref_offset, I32 ref_offset, |
| 432 |
INSDC:coord:len ref_len ); |
| 433 |
|
| 434 |
/* get_ref_delete |
| 435 |
* shows positions of deleted bases in reference space |
| 436 |
*/ |
| 437 |
function bool NCBI:align:get_ref_delete #1 |
| 438 |
( bool has_mismatch, bool has_ref_offset, I32 ref_offset, |
| 439 |
INSDC:coord:len ref_len ); |
| 440 |
|
| 441 |
extern function INSDC:quality:phred NCBI:align:compress_quality #1 |
| 442 |
( INSDC:quality:phred quality, bool preserved ); |
| 443 |
|
| 444 |
extern function INSDC:quality:phred NCBI:align:decompress_quality #1 |
| 445 |
< INSDC:quality:phred restored_qual_value > |
| 446 |
( INSDC:quality:phred cmp_quality, bool preserved ); |
| 447 |
|
| 448 |
/* make_cmp_read_start |
| 449 |
* |
| 450 |
*/ |
| 451 |
extern function INSDC:coord:zero NCBI:align:make_read_start #1 |
| 452 |
(INSDC:coord:len read_len); |
| 453 |
|
| 454 |
/* make_cmp_read_desc |
| 455 |
* determines whether an element of "operand" is aligned |
| 456 |
* by looking at the corresponding element of "align_id" |
| 457 |
* |
| 458 |
* zeros out unaligned elements of operand, unless "invert" is true, |
| 459 |
* in which case it zeros out aligned elements. |
| 460 |
* |
| 461 |
* "T" [ TYPE ] - type of operand |
| 462 |
* |
| 463 |
* "invert" [ CONST ] - if true, invert the logic of which elements |
| 464 |
* to zero out. |
| 465 |
* |
| 466 |
* "operand" [ DATA ] - uncompressed data |
| 467 |
* |
| 468 |
* "align_id" [ DATA ] - indication of alignment |
| 469 |
*/ |
| 470 |
extern function < type T > |
| 471 |
T NCBI:align:make_cmp_read_desc #1 <bool invert>(T operand, I64 align_id); |
| 472 |
|
| 473 |
/* seq_construct_read |
| 474 |
* assembles read from aligned and unaligned parts |
| 475 |
*/ |
| 476 |
extern function < type T > |
| 477 |
T NCBI:align:seq_construct_read #1 ( |
| 478 |
T aligned, INSDC:coord:len aligned_read_len, |
| 479 |
T unaligned, INSDC:coord:len unaligned_read_len ); |
| 480 |
|
| 481 |
extern function I64 NCBI:align:get_mate_align_id #1 ( I64 spot_id ); |
| 482 |
|
| 483 |
/*-------------------------------------------------------------------------- |
| 484 |
* tables |
| 485 |
*/ |
| 486 |
|
| 487 |
|
| 488 |
/* ref_block_cmn |
| 489 |
* common implementation ancestor for reference block |
| 490 |
*/ |
| 491 |
table NCBI:align:tbl:ref_block_cmn #1.0.0 |
| 492 |
{ |
| 493 |
readonly column ascii REF_TABLE |
| 494 |
= < ascii > meta:read < "CONFIG/REF_TABLE" > () |
| 495 |
| < ascii > echo < 'REFERENCE' > (); |
| 496 |
|
| 497 |
// REF_ID is rowid in Reference Table REF_TABLE |
| 498 |
extern column I64 REF_ID |
| 499 |
= out_ref_id; |
| 500 |
|
| 501 |
// this is a redefinition of REF_START |
| 502 |
// REF_START is the offset within REFERENCE.READ |
| 503 |
extern column INSDC:coord:zero REF_START |
| 504 |
= out_ref_start; |
| 505 |
|
| 506 |
// global REF_START |
| 507 |
extern column U64 GLOBAL_REF_START |
| 508 |
= out_global_ref_start; |
| 509 |
|
| 510 |
// REF_LEN the length of a read projection on reference |
| 511 |
INSDC:coord:len out_ref_len_internal |
| 512 |
= NCBI:align:get_ref_len_2 ( out_has_ref_offset, out_ref_offset ) |
| 513 |
| NCBI:align:get_ref_len ( out_has_ref_offset, out_ref_offset ); |
| 514 |
|
| 515 |
INSDC:coord:len out_ref_len |
| 516 |
= .REF_LEN |
| 517 |
/* | NCBI:align:get_ref_len ( out_has_ref_offset, out_ref_offset, out_right_clip ) */ |
| 518 |
| out_ref_len_internal; |
| 519 |
|
| 520 |
physical column < INSDC:coord:len > izip_encoding .REF_LEN = REF_LEN; |
| 521 |
extern column INSDC:coord:len REF_LEN = out_ref_len; |
| 522 |
|
| 523 |
// REF_ORIENTATION - relative orientation of original raw read to the reference |
| 524 |
// false -> same orientation, true -> opposite orientation |
| 525 |
// alignment and reference are always in the same orientation |
| 526 |
extern column bool_encoding REF_ORIENTATION; |
| 527 |
|
| 528 |
// REF_PLOIDY |
| 529 |
extern column < U32 > izip_encoding REF_PLOIDY; |
| 530 |
|
| 531 |
/* REF_POS |
| 532 |
* per PLOIDY |
| 533 |
*/ |
| 534 |
readonly column INSDC:coord:zero REF_POS |
| 535 |
= NCBI:align:ref_pos ( out_ref_id, out_ref_start ); |
| 536 |
|
| 537 |
/* REF_NAME |
| 538 |
* the name of the reference |
| 539 |
*/ |
| 540 |
readonly column ascii REF_NAME |
| 541 |
= NCBI:align:ref_name ( out_ref_id ); |
| 542 |
|
| 543 |
/* REF_SEQ_ID |
| 544 |
*/ |
| 545 |
readonly column ascii REF_SEQ_ID |
| 546 |
= NCBI:align:ref_seq_id ( out_ref_id ) |
| 547 |
| < ascii > echo < '' > (); |
| 548 |
}; |
| 549 |
|
| 550 |
|
| 551 |
/* global_ref_block |
| 552 |
* reference block favoring global ref-start |
| 553 |
*/ |
| 554 |
table NCBI:align:tbl:global_ref_block #1.0.0 |
| 555 |
= NCBI:align:tbl:ref_block_cmn #1.0.0 |
| 556 |
{ |
| 557 |
U64 out_global_ref_start = .GLOBAL_REF_START; |
| 558 |
physical < U64 > izip_encoding .GLOBAL_REF_START = GLOBAL_REF_START; |
| 559 |
|
| 560 |
I64 out_ref_id = NCBI:align:local_ref_id ( .GLOBAL_REF_START ); |
| 561 |
INSDC:coord:zero out_ref_start = NCBI:align:local_ref_start ( .GLOBAL_REF_START ); |
| 562 |
}; |
| 563 |
|
| 564 |
|
| 565 |
/* local_ref_block |
| 566 |
* reference block favoring local ref-start |
| 567 |
*/ |
| 568 |
table NCBI:align:tbl:local_ref_block #1.0.0 |
| 569 |
= NCBI:align:tbl:ref_block_cmn #1.0.0 |
| 570 |
{ |
| 571 |
I64 out_ref_id = .REF_ID; |
| 572 |
physical < I64 > izip_encoding .REF_ID = REF_ID; |
| 573 |
|
| 574 |
INSDC:coord:zero out_ref_start = .REF_START; |
| 575 |
physical < INSDC:coord:zero > izip_encoding .REF_START = REF_START; |
| 576 |
}; |
| 577 |
|
| 578 |
|
| 579 |
/* align_cmn |
| 580 |
* common interface and implementation for alignment object |
| 581 |
* |
| 582 |
* History: |
| 583 |
* 2.1.0 - added REF_OFFSET_TYPE and RNA_ORIENTATION columns |
| 584 |
* updated all cigar calculations |
| 585 |
* 2.1.1 - update ancestry |
| 586 |
*/ |
| 587 |
table NCBI:align:tbl:align_cmn #2.1.1 |
| 588 |
= NCBI:tbl:base_space_common #1.0.3 |
| 589 |
, NCBI:SRA:tbl:stats #1.2.1 |
| 590 |
, NCBI:align:tbl:ref_block_cmn #1.0.0 |
| 591 |
{ |
| 592 |
bool is_secondary = out_is_secondary; |
| 593 |
// temporary key |
| 594 |
extern column < U32 > izip_encoding TMP_KEY_ID; |
| 595 |
|
| 596 |
extern column <ascii> zip_encoding LINKAGE_GROUP; |
| 597 |
|
| 598 |
|
| 599 |
/* Raw Sequence Block */ |
| 600 |
// Points to sequence table, which may contain more information about the raw sequence. |
| 601 |
// row id in SEQUENCE table; 0 if not linked |
| 602 |
extern column < I64 > izip_encoding SEQ_SPOT_ID; |
| 603 |
|
| 604 |
// read number in SEQUENCE table; { SEQ_SPOT_ID, SEQ_READ_ID } is the unique link to the sequence |
| 605 |
extern column < INSDC:coord:one > izip_encoding SEQ_READ_ID; |
| 606 |
|
| 607 |
|
| 608 |
/* Soft-Clipped data block */ |
| 609 |
|
| 610 |
readonly column INSDC:coord:len LEFT_SOFT_CLIP |
| 611 |
= NCBI:align:get_left_soft_clip ( HAS_REF_OFFSET, REF_OFFSET, out_read_len ); |
| 612 |
|
| 613 |
INSDC:coord:len out_right_clip |
| 614 |
= NCBI:align:get_right_soft_clip #5 ( out_has_ref_offset, out_ref_offset, out_ro_type, out_read_len ) |
| 615 |
| NCBI:align:get_right_soft_clip #4 ( out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len ) |
| 616 |
| NCBI:align:get_right_soft_clip #3 ( out_has_ref_offset, out_ref_offset, out_ref_len ) |
| 617 |
| NCBI:align:get_right_soft_clip #2 ( out_has_mismatch, LEFT_SOFT_CLIP, out_has_ref_offset, out_ref_offset ); |
| 618 |
readonly column INSDC:coord:len RIGHT_SOFT_CLIP = out_right_clip; |
| 619 |
|
| 620 |
readonly column ascii CLIPPED_CIGAR_LONG |
| 621 |
= < ascii > NCBI:align:get_clipped_cigar ( CIGAR_LONG, CIGAR_LONG_LEN ); |
| 622 |
|
| 623 |
readonly column INSDC:coord:len CLIPPED_CIGAR_LONG_LEN |
| 624 |
= < INSDC:coord:len > NCBI:align:get_clipped_cigar ( CIGAR_LONG, CIGAR_LONG_LEN ); |
| 625 |
|
| 626 |
readonly column ascii CLIPPED_CIGAR_SHORT |
| 627 |
= < ascii > NCBI:align:get_clipped_cigar ( CIGAR_SHORT, CIGAR_SHORT_LEN ); |
| 628 |
|
| 629 |
readonly column INSDC:coord:len CLIPPED_CIGAR_SHORT_LEN |
| 630 |
= < INSDC:coord:len > NCBI:align:get_clipped_cigar ( CIGAR_SHORT, CIGAR_SHORT_LEN ); |
| 631 |
|
| 632 |
bool out_clipped_has_mismatch |
| 633 |
= < bool > NCBI:align:clip (out_has_mismatch, out_read_len, LEFT_SOFT_CLIP, RIGHT_SOFT_CLIP); |
| 634 |
|
| 635 |
readonly column ascii CLIPPED_HAS_MISMATCH |
| 636 |
= < U8 , ascii > map < [ 0 , 1 ] , '01' > ( out_clipped_has_mismatch ); |
| 637 |
|
| 638 |
readonly column bool CLIPPED_HAS_MISMATCH = out_clipped_has_mismatch; |
| 639 |
|
| 640 |
bool out_clipped_has_ref_offset |
| 641 |
= < bool > NCBI:align:clip (HAS_REF_OFFSET, out_read_len, LEFT_SOFT_CLIP, RIGHT_SOFT_CLIP); |
| 642 |
|
| 643 |
readonly column ascii CLIPPED_HAS_REF_OFFSET |
| 644 |
= < U8 , ascii > map < [ 0 , 1 ] , '01' > ( out_clipped_has_ref_offset ); |
| 645 |
|
| 646 |
readonly column bool CLIPPED_HAS_REF_OFFSET = out_clipped_has_ref_offset; |
| 647 |
|
| 648 |
// TBD cannot be computed right unless HAS_MISMATCH and! READ_LEN is used |
| 649 |
readonly column INSDC:dna:text CLIPPED_MISMATCH |
| 650 |
= < INSDC:dna:text > NCBI:align:clip #1 ( out_mismatch_dna_text, LEFT_SOFT_CLIP, RIGHT_SOFT_CLIP); |
| 651 |
|
| 652 |
readonly column I32 CLIPPED_REF_OFFSET |
| 653 |
= NCBI:align:get_clipped_ref_offset ( HAS_REF_OFFSET, REF_OFFSET ); |
| 654 |
|
| 655 |
readonly column INSDC:quality:phred CLIPPED_QUALITY |
| 656 |
= < INSDC:quality:phred > NCBI:align:clip (out_qual_phred, out_read_len, LEFT_SOFT_CLIP, RIGHT_SOFT_CLIP); |
| 657 |
|
| 658 |
readonly column INSDC:dna:text CLIPPED_READ |
| 659 |
= < INSDC:dna:text > NCBI:align:clip (READ, out_read_len, LEFT_SOFT_CLIP, RIGHT_SOFT_CLIP); |
| 660 |
|
| 661 |
/* Sequence Block */ |
| 662 |
|
| 663 |
extern column < NCBI:align:ploidy > izip_encoding PLOIDY; |
| 664 |
|
| 665 |
// Number of reads per spot; corresponds to the number of alternative alignments |
| 666 |
// all alternative alignments are computed against the same reference region |
| 667 |
U32 out_nreads |
| 668 |
= .PLOIDY |
| 669 |
| < U32 > echo < 1 > (); |
| 670 |
|
| 671 |
// READ_START and READ_LEN are position and length of the sequence |
| 672 |
physical < INSDC:coord:zero > izip_encoding .READ_START = READ_START; |
| 673 |
INSDC:coord:zero out_read_start |
| 674 |
= .READ_START |
| 675 |
| < INSDC:coord:zero > echo < 0 > (); |
| 676 |
|
| 677 |
physical < INSDC:coord:len > izip_encoding .READ_LEN = READ_LEN; |
| 678 |
|
| 679 |
INSDC:coord:len align_spot_len = ( INSDC:coord:len ) row_len ( out_has_ref_offset ); |
| 680 |
INSDC:coord:len out_read_len |
| 681 |
= .READ_LEN |
| 682 |
| align_spot_len; |
| 683 |
|
| 684 |
// associated qualities |
| 685 |
extern column INSDC:quality:phred CMP_QUALITY |
| 686 |
= .CMP_QUALITY |
| 687 |
| out_cmp_quality; |
| 688 |
physical column < INSDC:quality:phred > zip_encoding .CMP_QUALITY = CMP_QUALITY; |
| 689 |
|
| 690 |
INSDC:quality:phred out_raw_qual = < INSDC:quality:phred > |
| 691 |
NCBI:align:project_from_sequence < '( INSDC:quality:phred ) QUALITY'> ( .SEQ_SPOT_ID, .SEQ_READ_ID ); |
| 692 |
INSDC:quality:phred out_qual_phred |
| 693 |
= NCBI:align:raw_restore_qual ( out_raw_qual, .REF_ORIENTATION ) |
| 694 |
| < INSDC:quality:phred > echo < 30 > ( out_4na_bin ); |
| 695 |
readonly column INSDC:quality:text:phred_33 SAM_QUALITY = QUALITY ; |
| 696 |
|
| 697 |
// project read group and name |
| 698 |
ascii out_spot_group = < ascii > simple_sub_select < 'SEQUENCE','SPOT_GROUP'> (.SEQ_SPOT_ID); |
| 699 |
|
| 700 |
|
| 701 |
INSDC:SRA:spotid_t tmp_seq_spot_id |
| 702 |
= cast ( .SEQ_SPOT_ID ) |
| 703 |
; |
| 704 |
physical <ascii> zip_encoding .SEQ_NAME = SEQ_NAME; |
| 705 |
extern column ascii SEQ_NAME |
| 706 |
= .SEQ_NAME |
| 707 |
| < ascii > simple_sub_select < 'SEQUENCE','NAME'> (.SEQ_SPOT_ID) |
| 708 |
| sprintf < "%u" > ( tmp_seq_spot_id ); |
| 709 |
|
| 710 |
// compute sam flags |
| 711 |
/* blows up parser: starts at schema-tbl.c:2138 |
| 712 |
readonly column U32 SAM_FLAGS = NCBI:align:get_sam_flags(MATE_ALIGN_ID, |
| 713 |
.SEQ_READ_ID, out_template_len, REF_ORIENTATION, |
| 714 |
out_mate_ref_orientation, is_secondary); |
| 715 |
*/ |
| 716 |
INSDC:coord:len projected_read_len |
| 717 |
= < INSDC:coord:len > simple_sub_select < 'SEQUENCE', 'READ_LEN' > ( .SEQ_SPOT_ID ); |
| 718 |
|
| 719 |
readonly column U32 SAM_FLAGS |
| 720 |
= NCBI:align:get_sam_flags #1 (projected_read_len, |
| 721 |
.SEQ_READ_ID, out_template_len, REF_ORIENTATION, |
| 722 |
out_mate_ref_orientation, is_secondary, out_rd_filter) |
| 723 |
| NCBI:align:get_sam_flags #2 (out_mate_align_id, |
| 724 |
.SEQ_READ_ID, out_template_len, REF_ORIENTATION, |
| 725 |
out_mate_ref_orientation, is_secondary, out_rd_filter); |
| 726 |
|
| 727 |
ascii out_name_fmt = < ascii > echo < '$R' > (); |
| 728 |
|
| 729 |
INSDC:coord:zero trim_start |
| 730 |
= < INSDC:coord:zero > echo < 0 > (); |
| 731 |
INSDC:coord:len trim_len |
| 732 |
= align_spot_len; |
| 733 |
|
| 734 |
ascii out_label |
| 735 |
= .LABEL |
| 736 |
| < ascii > echo < "ploidy1" > (); |
| 737 |
INSDC:coord:zero out_label_start |
| 738 |
= .LABEL_START |
| 739 |
| < INSDC:coord:zero > echo < 0 > (); |
| 740 |
INSDC:coord:len out_label_len |
| 741 |
= .LABEL_LEN |
| 742 |
| < INSDC:coord:len > echo < 7 > (); |
| 743 |
|
| 744 |
physical < INSDC:SRA:read_filter > zip_encoding .RD_FILTER = READ_FILTER; |
| 745 |
INSDC:SRA:read_filter out_rd_filter |
| 746 |
= .RD_FILTER |
| 747 |
| < INSDC:SRA:read_filter > NCBI:align:project_from_sequence < 'READ_FILTER' > ( .SEQ_SPOT_ID, .SEQ_READ_ID ) |
| 748 |
| < INSDC:SRA:read_filter > echo < SRA_READ_FILTER_PASS > ( out_read_len ); |
| 749 |
|
| 750 |
INSDC:SRA:platform_id out_platform |
| 751 |
= .PLATFORM |
| 752 |
| < INSDC:SRA:platform_id > simple_sub_select < 'SEQUENCE','PLATFORM'> (.SEQ_SPOT_ID) |
| 753 |
| < INSDC:SRA:platform_id > echo < SRA_PLATFORM_UNDEFINED > (); |
| 754 |
|
| 755 |
U8 out_alignment_count = <U8> NCBI:align:project_from_sequence < 'ALIGNMENT_COUNT' > ( .SEQ_SPOT_ID, .SEQ_READ_ID ); |
| 756 |
|
| 757 |
/* out_read_type |
| 758 |
* set to SRA_READ_TYPE_FORWARD + SRA_READ_TYPE_BIOLOGICAL |
| 759 |
* which has a constant value of 3 |
| 760 |
*/ |
| 761 |
INSDC:SRA:xread_type out_read_type |
| 762 |
= < INSDC:SRA:xread_type > echo < 3 > ( out_read_len ); |
| 763 |
|
| 764 |
// stats inputs |
| 765 |
bool in_stats_bin = HAS_REF_OFFSET; |
| 766 |
|
| 767 |
INSDC:coord:len _alt_in_read_len |
| 768 |
= READ_LEN |
| 769 |
| ( INSDC:coord:len ) row_len #1 ( HAS_REF_OFFSET ); |
| 770 |
|
| 771 |
INSDC:SRA:xread_type _alt_in_read_type |
| 772 |
= READ_TYPE |
| 773 |
| < INSDC:SRA:xread_type > echo < SRA_READ_TYPE_BIOLOGICAL > (_alt_in_read_len); |
| 774 |
|
| 775 |
readonly column ascii MISMATCH_READ |
| 776 |
= NCBI:align:get_mismatch_read ( out_has_mismatch, out_mismatch_dna_text ); |
| 777 |
|
| 778 |
/* Alignment block */ |
| 779 |
|
| 780 |
// MAPQ - single value quality of the mapping; the scale is submitter specific |
| 781 |
extern column < I32 > izip_encoding MAPQ; |
| 782 |
|
| 783 |
extern column INSDC:coord:zero MATE_REF_POS = out_mate_ref_pos; |
| 784 |
extern column INSDC:coord:len MATE_REF_LEN = out_mate_ref_len; |
| 785 |
extern column I64 MATE_REF_ID = out_mate_ref_id; |
| 786 |
extern column I32 TEMPLATE_LEN = out_template_len; |
| 787 |
extern column bool MATE_REF_ORIENTATION = out_mate_ref_orientation; |
| 788 |
readonly column ascii MATE_REF_NAME = NCBI:align:ref_name ( out_mate_ref_id ); |
| 789 |
readonly column ascii MATE_REF_SEQ_ID = NCBI:align:ref_seq_id( out_mate_ref_id ); |
| 790 |
readonly column U8 ALIGNMENT_COUNT = out_alignment_count; |
| 791 |
|
| 792 |
|
| 793 |
/******************************** |
| 794 |
* Columns representing CIGARs |
| 795 |
********************************/ |
| 796 |
|
| 797 |
|
| 798 |
// one value per base i.e. length is same as sum of READ_LEN |
| 799 |
// partitioned by READ_START and READ_LEN into alternative alignments |
| 800 |
// flags the shifts in reference position preceeding the base |
| 801 |
// if sequence of a partitioned read starts with a ref_offset and one or more mismatches |
| 802 |
// then it represents a left soft clip |
| 803 |
// any run of mismatches at the end represents a right soft clip |
| 804 |
|
| 805 |
readonly column ascii HAS_REF_OFFSET = < U8 , ascii > map < [ 0 , 1 ] , '01' > ( out_has_ref_offset ); |
| 806 |
extern column bool_encoding HAS_REF_OFFSET; |
| 807 |
bool out_has_ref_offset = .HAS_REF_OFFSET; |
| 808 |
|
| 809 |
// has number of elements equal to number of true elements in HAS_REF_OFFSET |
| 810 |
extern column < I32 > izip_encoding REF_OFFSET; |
| 811 |
I32 out_ref_offset = .REF_OFFSET; |
| 812 |
|
| 813 |
// the type of offset recorded in REF_OFFSET |
| 814 |
extern column < NCBI:align:ro_type > izip_encoding REF_OFFSET_TYPE; |
| 815 |
NCBI:align:ro_type out_ro_type = .REF_OFFSET_TYPE; |
| 816 |
|
| 817 |
// DISPLAY Columns |
| 818 |
|
| 819 |
readonly column I64 ALIGN_ID = row_id (); |
| 820 |
|
| 821 |
// get projection of the reference |
| 822 |
readonly column INSDC:dna:text REF_READ |
| 823 |
= < INSDC:4na:bin, INSDC:dna:text > map < INSDC:4na:map:BINSET, INSDC:4na:map:CHARSET > ( REF_READ ); |
| 824 |
|
| 825 |
readonly column INSDC:4na:bin REF_READ |
| 826 |
= NCBI:align:ref_sub_select (out_ref_id, out_ref_start, out_ref_len, .REF_PLOIDY) |
| 827 |
| NCBI:align:ref_sub_select (out_ref_id, out_ref_start, out_ref_len ); |
| 828 |
|
| 829 |
INSDC:4na:bin ref_read_internal |
| 830 |
= NCBI:align:ref_sub_select (out_ref_id, out_ref_start, out_ref_len_internal, .REF_PLOIDY) |
| 831 |
| NCBI:align:ref_sub_select (out_ref_id, out_ref_start, out_ref_len_internal); |
| 832 |
|
| 833 |
// text forms of reads |
| 834 |
INSDC:dna:text out_dna_text |
| 835 |
= < INSDC:4na:bin, INSDC:dna:text > map < INSDC:4na:map:BINSET, INSDC:4na:map:CHARSET > ( out_4na_bin ); |
| 836 |
readonly column INSDC:dna:text RAW_READ |
| 837 |
= < INSDC:4na:bin, INSDC:dna:text > map < INSDC:4na:map:BINSET, INSDC:4na:map:CHARSET > ( out_raw_read ); |
| 838 |
readonly column INSDC:4na:bin RAW_READ |
| 839 |
= out_raw_read; |
| 840 |
|
| 841 |
// CIGARs |
| 842 |
readonly column ascii CIGAR_LONG |
| 843 |
= < ascii > NCBI:align:cigar #2 < 1 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len, out_ro_type) |
| 844 |
| < ascii > NCBI:align:cigar #2 < 1 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len) |
| 845 |
| < ascii > NCBI:align:cigar #2 < 1 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len) |
| 846 |
; |
| 847 |
readonly column INSDC:coord:len CIGAR_LONG_LEN |
| 848 |
= < INSDC:coord:len > NCBI:align:cigar #2 < 1 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len, out_ro_type) |
| 849 |
| < INSDC:coord:len > NCBI:align:cigar #2 < 1 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len) |
| 850 |
| < INSDC:coord:len > NCBI:align:cigar #2 < 1 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len) |
| 851 |
; |
| 852 |
readonly column ascii CIGAR_SHORT |
| 853 |
= < ascii > NCBI:align:cigar #2 < 0 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len, out_ro_type) |
| 854 |
| < ascii > NCBI:align:cigar #2 < 0 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len) |
| 855 |
| < ascii > NCBI:align:cigar #2 < 0 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len) |
| 856 |
; |
| 857 |
readonly column INSDC:coord:len CIGAR_SHORT_LEN |
| 858 |
= < INSDC:coord:len > NCBI:align:cigar #2 < 0 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len, out_ro_type) |
| 859 |
| < INSDC:coord:len > NCBI:align:cigar #2 < 0 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len, out_ref_len) |
| 860 |
| < INSDC:coord:len > NCBI:align:cigar #2 < 0 > (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_read_len) |
| 861 |
; |
| 862 |
|
| 863 |
readonly column ascii RNA_ORIENTATION |
| 864 |
= NCBI:align:rna_orientation ( out_ro_type ) |
| 865 |
; |
| 866 |
|
| 867 |
readonly column U32 EDIT_DISTANCE |
| 868 |
= NCBI:align:edit_distance #3 (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_ro_type, out_read_len) |
| 869 |
| NCBI:align:edit_distance #2 (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_ref_len, out_read_len) |
| 870 |
| NCBI:align:edit_distance #2 (out_has_mismatch, out_has_ref_offset, out_ref_offset, out_ref_len) |
| 871 |
| NCBI:align:edit_distance #1 (out_has_mismatch, out_has_ref_offset, out_ref_offset); |
| 872 |
|
| 873 |
readonly column ascii HAS_MISMATCH = < U8 , ascii > map < [ 0 , 1 ] , '01' > ( out_has_mismatch ); |
| 874 |
|
| 875 |
// needed for backward compatibility |
| 876 |
readonly column ascii SEQ_SPOT_GROUP = out_spot_group; |
| 877 |
|
| 878 |
|
| 879 |
/* These columns are purely informational. */ |
| 880 |
bool out_ref_mismatch = NCBI:align:get_ref_mismatch ( out_has_mismatch, out_has_ref_offset, out_ref_offset, out_ref_len ); |
| 881 |
readonly column ascii REF_MISMATCH = < U8 , ascii > map < [ 0 , 1 ] , '01' > ( out_ref_mismatch ); |
| 882 |
readonly column bool REF_MISMATCH = out_ref_mismatch; |
| 883 |
|
| 884 |
bool out_ref_insert = NCBI:align:get_ref_insert ( out_has_mismatch, out_has_ref_offset, out_ref_offset, out_ref_len ); |
| 885 |
readonly column ascii REF_INSERT = < U8 , ascii > map < [ 0 , 1 ] , '01' > ( out_ref_insert ); |
| 886 |
readonly column bool REF_INSERT = out_ref_insert; |
| 887 |
|
| 888 |
bool out_ref_delete = NCBI:align:get_ref_delete ( out_has_mismatch, out_has_ref_offset, out_ref_offset, out_ref_len ); |
| 889 |
readonly column ascii REF_DELETE = < U8 , ascii > map < [ 0 , 1 ] , '01' > ( out_ref_delete ); |
| 890 |
readonly column bool REF_DELETE = out_ref_delete; |
| 891 |
|
| 892 |
}; |
| 893 |
|
| 894 |
|
| 895 |
/* align_full |
| 896 |
* aligns externally stored sequence against reference |
| 897 |
* alignment transcript is calculated |
| 898 |
* |
| 899 |
* History: |
| 900 |
* 1.1.0 - respond to changes in base table |
| 901 |
* 1.1.1 - respond to changes in base table |
| 902 |
*/ |
| 903 |
table NCBI:align:tbl:align_full #1.1.1 |
| 904 |
= NCBI:align:tbl:align_cmn #2.1.1 |
| 905 |
{ |
| 906 |
bool out_is_secondary = <bool> echo < true > (); |
| 907 |
// restore reads to its raw form (orientation is restored) |
| 908 |
|
| 909 |
INSDC:4na:bin out_raw_read |
| 910 |
= < INSDC:4na:bin > simple_sub_select < 'PRIMARY_ALIGNMENT', '( INSDC:4na:bin ) RAW_READ' > (.PRIMARY_ALIGNMENT_ID) |
| 911 |
| < INSDC:4na:bin > NCBI:align:project_from_sequence < '( INSDC:4na:bin ) READ'> ( .SEQ_SPOT_ID, .SEQ_READ_ID ); |
| 912 |
|
| 913 |
INSDC:4na:bin out_4na_bin |
| 914 |
= NCBI:align:align_restore_read ( ref_read_internal, out_has_mismatch, tmp_out_mismatch_4na_bin, out_has_ref_offset, out_ref_offset, .READ_LEN ) |
| 915 |
| NCBI:align:align_restore_read ( ref_read_internal, out_has_mismatch, tmp_out_mismatch_4na_bin, out_has_ref_offset, out_ref_offset ) |
| 916 |
| NCBI:align:raw_restore_read ( out_raw_read, .REF_ORIENTATION ); |
| 917 |
|
| 918 |
|
| 919 |
// flags mismatches with the reference |
| 920 |
// produced by actual comparison of REF_READ and READ |
| 921 |
// TMP_HAS_MISMATCH is a hack to speed up retrieval during coverage recalculation |
| 922 |
column bool_encoding TMP_HAS_MISMATCH; |
| 923 |
bool out_has_mismatch |
| 924 |
= .TMP_HAS_MISMATCH |
| 925 |
| NCBI:align:generate_has_mismatch ( REF_READ, READ, out_has_ref_offset, out_ref_offset ); |
| 926 |
readonly column bool HAS_MISMATCH = out_has_mismatch; |
| 927 |
|
| 928 |
INSDC:4na:bin out_mismatch_4na_bin |
| 929 |
= NCBI:align:generate_mismatch ( REF_READ, READ, out_has_ref_offset, out_ref_offset ); |
| 930 |
|
| 931 |
INSDC:4na:bin tmp_out_mismatch_4na_bin = < INSDC:dna:text, INSDC:4na:bin > map < INSDC:4na:map:CHARSET, INSDC:4na:map:BINSET > ( .TMP_MISMATCH ); |
| 932 |
|
| 933 |
// temporary column for reference coverage calculation |
| 934 |
column < INSDC:dna:text> zip_encoding TMP_MISMATCH; |
| 935 |
|
| 936 |
INSDC:dna:text out_mismatch_dna_text |
| 937 |
= .TMP_MISMATCH |
| 938 |
| < INSDC:4na:bin, INSDC:dna:text > map < INSDC:4na:map:BINSET, INSDC:4na:map:CHARSET > ( out_mismatch_4na_bin ); |
| 939 |
|
| 940 |
readonly column INSDC:dna:text MISMATCH = out_mismatch_dna_text; |
| 941 |
readonly column INSDC:4na:bin MISMATCH = out_mismatch_4na_bin; |
| 942 |
|
| 943 |
physical column < INSDC:coord:zero > izip_encoding .MATE_REF_POS = MATE_REF_POS; |
| 944 |
INSDC:coord:zero out_mate_ref_pos = .MATE_REF_POS |
| 945 |
| < INSDC:coord:zero > simple_sub_select < '','REF_POS'> (MATE_ALIGN_ID); |
| 946 |
|
| 947 |
physical column < I64 > izip_encoding .MATE_REF_ID = MATE_REF_ID; |
| 948 |
I64 out_mate_ref_id = .MATE_REF_ID |
| 949 |
| < I64 > simple_sub_select < '','REF_ID'> (MATE_ALIGN_ID); |
| 950 |
|
| 951 |
INSDC:coord:len out_mate_ref_len = < INSDC:coord:len > simple_sub_select < '','REF_LEN'> (MATE_ALIGN_ID); |
| 952 |
physical column < I32 > izip_encoding .TEMPLATE_LEN = TEMPLATE_LEN; |
| 953 |
I32 out_template_len = .TEMPLATE_LEN |
| 954 |
| NCBI:align:template_len(REF_POS,out_mate_ref_pos,out_ref_len,out_mate_ref_len,REF_NAME,MATE_REF_NAME,SEQ_READ_ID); |
| 955 |
|
| 956 |
physical column < bool > izip_encoding .MATE_REF_ORIENTATION = MATE_REF_ORIENTATION; |
| 957 |
bool out_mate_ref_orientation = .MATE_REF_ORIENTATION |
| 958 |
| < bool > simple_sub_select < '','REF_ORIENTATION'> (MATE_ALIGN_ID); |
| 959 |
|
| 960 |
I64 out_mate_align_id = .MATE_ALIGN_ID; |
| 961 |
physical column <I64> izip_encoding .MATE_ALIGN_ID = MATE_ALIGN_ID; |
| 962 |
extern column I64 MATE_ALIGN_ID = out_mate_align_id; |
| 963 |
|
| 964 |
physical column < I64 > izip_encoding .PRIMARY_ALIGNMENT_ID = PRIMARY_ALIGNMENT_ID; |
| 965 |
|
| 966 |
I32 read_idx = <I32> cast (.SEQ_READ_ID); |
| 967 |
extern column I64 PRIMARY_ALIGNMENT_ID |
| 968 |
= .PRIMARY_ALIGNMENT_ID |
| 969 |
| <I64> simple_sub_select < 'SEQUENCE','PRIMARY_ALIGNMENT_ID' > (.SEQ_SPOT_ID,.SEQ_READ_ID); |
| 970 |
|
| 971 |
}; |
| 972 |
|
| 973 |
|
| 974 |
/* compressed_by_reference |
| 975 |
* aligns internally represented sequence against reference |
| 976 |
* alignment transcript is stored |
| 977 |
* original sequence is reconstructed |
| 978 |
* |
| 979 |
* History: |
| 980 |
* 1.2.0 - respond to changes in base table |
| 981 |
* 1.2.1 - respond to changes in base table |
| 982 |
*/ |
| 983 |
table NCBI:align:tbl:compressed_by_reference #1.2.1 |
| 984 |
= NCBI:align:tbl:align_cmn #2.1.1 |
| 985 |
{ |
| 986 |
bool out_is_secondary = <bool> echo < false > (); |
| 987 |
|
| 988 |
// one value per base i.e. length is same as sum of READ_LEN |
| 989 |
// partitioned by READ_START and READ_LEN into alternative alignments |
| 990 |
// flags mismatches with the reference |
| 991 |
extern default column bool_encoding HAS_MISMATCH; |
| 992 |
bool out_has_mismatch = .HAS_MISMATCH; |
| 993 |
|
| 994 |
// has number of elements equal to number of true elements in HAS_MISMATCH |
| 995 |
extern column INSDC:dna:text MISMATCH |
| 996 |
{ |
| 997 |
read = out_mismatch_dna_text; |
| 998 |
validate = < INSDC:dna:text > compare ( in_mismatch_dna_text, out_mismatch_dna_text ); |
| 999 |
} |
| 1000 |
|
| 1001 |
INSDC:dna:text in_mismatch_dna_text |
| 1002 |
= < INSDC:dna:text, INSDC:dna:text > map < '.acmgrsvtwyhkdbn','NACMGRSVTWYHKDBN' > ( MISMATCH ); |
| 1003 |
|
| 1004 |
INSDC:4na:bin in_mismatch_4na_bin |
| 1005 |
= < INSDC:dna:text, INSDC:4na:bin > map < INSDC:4na:map:CHARSET, INSDC:4na:map:BINSET > ( in_mismatch_dna_text ); |
| 1006 |
|
| 1007 |
extern column < ascii > zip_encoding ALIGN_GROUP; |
| 1008 |
|
| 1009 |
physical column < INSDC:4na:bin > zip_encoding .MISMATCH = in_mismatch_4na_bin; |
| 1010 |
|
| 1011 |
INSDC:4na:bin out_mismatch_4na_bin = .MISMATCH; |
| 1012 |
INSDC:dna:text out_mismatch_dna_text |
| 1013 |
= < INSDC:4na:bin, INSDC:dna:text > map < INSDC:4na:map:BINSET, INSDC:4na:map:CHARSET > ( out_mismatch_4na_bin ); |
| 1014 |
|
| 1015 |
I64 out_mate_align_id |
| 1016 |
= .MATE_ALIGN_ID |
| 1017 |
| NCBI:align:get_mate_align_id (.SEQ_SPOT_ID); |
| 1018 |
|
| 1019 |
physical column <I64> izip_encoding .MATE_ALIGN_ID = MATE_ALIGN_ID; |
| 1020 |
extern column I64 MATE_ALIGN_ID = out_mate_align_id; |
| 1021 |
|
| 1022 |
// restore reads from alignment columns and the reference |
| 1023 |
// optional .READ_LEN size defines PLOIDY |
| 1024 |
INSDC:4na:bin out_4na_bin |
| 1025 |
= NCBI:align:align_restore_read ( ref_read_internal, out_has_mismatch, .MISMATCH, out_has_ref_offset, out_ref_offset, .READ_LEN ) |
| 1026 |
| NCBI:align:align_restore_read ( ref_read_internal, out_has_mismatch, .MISMATCH, out_has_ref_offset, out_ref_offset ); |
| 1027 |
|
| 1028 |
// restore reads to its raw form (orientation is restored) |
| 1029 |
INSDC:4na:bin out_raw_read = NCBI:align:raw_restore_read (out_4na_bin,.REF_ORIENTATION); |
| 1030 |
|
| 1031 |
I64 primary_align_pair = < I64 > simple_sub_select < 'SEQUENCE','PRIMARY_ALIGNMENT_ID'> (.SEQ_SPOT_ID); |
| 1032 |
I64 out_mate_ref_id = < I64 > simple_sub_select < '','REF_ID'> (MATE_ALIGN_ID); |
| 1033 |
bool out_mate_ref_orientation = < bool > simple_sub_select < '','REF_ORIENTATION'> (MATE_ALIGN_ID); |
| 1034 |
INSDC:coord:zero out_mate_ref_pos = < INSDC:coord:zero > simple_sub_select < '','REF_POS'> (MATE_ALIGN_ID); |
| 1035 |
INSDC:coord:len out_mate_ref_len = < INSDC:coord:len > simple_sub_select < '','REF_LEN'> (MATE_ALIGN_ID); |
| 1036 |
readonly column U32 MATE_EDIT_DISTANCE = < U32 > simple_sub_select < '','EDIT_DISTANCE'> (MATE_ALIGN_ID); |
| 1037 |
readonly column ascii MATE_CIGAR_LONG = < ascii > simple_sub_select < '','CIGAR_LONG'> (MATE_ALIGN_ID); |
| 1038 |
readonly column ascii MATE_CIGAR_SHORT = < ascii > simple_sub_select < '','CIGAR_SHORT'> (MATE_ALIGN_ID); |
| 1039 |
readonly column INSDC:coord:len MATE_CIGAR_LONG_LEN = < INSDC:coord:len > simple_sub_select < '','CIGAR_LONG_LEN'> (MATE_ALIGN_ID); |
| 1040 |
readonly column INSDC:coord:len MATE_CIGAR_SHORT_LEN = < INSDC:coord:len > simple_sub_select < '','CIGAR_SHORT_LEN'> (MATE_ALIGN_ID); |
| 1041 |
|
| 1042 |
I32 out_template_len = NCBI:align:template_len (REF_POS,out_mate_ref_pos,out_ref_len,out_mate_ref_len,REF_NAME,MATE_REF_NAME,SEQ_READ_ID); |
| 1043 |
}; |
| 1044 |
|
| 1045 |
|
| 1046 |
/* align_sorted |
| 1047 |
* deflated alignment data sorted against reference |
| 1048 |
* |
| 1049 |
* History: |
| 1050 |
* 1.2.0 - respond to changes in base table |
| 1051 |
* 1.2.1 - respond to changes in base table |
| 1052 |
*/ |
| 1053 |
table NCBI:align:tbl:align_sorted #1.2.1 |
| 1054 |
= NCBI:align:tbl:compressed_by_reference #1.2.1 |
| 1055 |
, NCBI:align:tbl:global_ref_block #1.0.0 |
| 1056 |
{ |
| 1057 |
// 128K |
| 1058 |
column default limit = 131072; |
| 1059 |
}; |
| 1060 |
|
| 1061 |
|
| 1062 |
/* align_unsorted |
| 1063 |
* deflated alignment unsorted data |
| 1064 |
* |
| 1065 |
* History: |
| 1066 |
* 1.2.0 - respond to changes in base table |
| 1067 |
* 1.2.1 - respond to changes in base table |
| 1068 |
*/ |
| 1069 |
table NCBI:align:tbl:align_unsorted #1.2.1 |
| 1070 |
= NCBI:align:tbl:compressed_by_reference #1.2.1 |
| 1071 |
, NCBI:align:tbl:local_ref_block #1.0.0 |
| 1072 |
{ |
| 1073 |
// 128K |
| 1074 |
column default limit = 131072; |
| 1075 |
}; |
| 1076 |
|
| 1077 |
|
| 1078 |
/* align_mate_sorted |
| 1079 |
* |
| 1080 |
* History: |
| 1081 |
* 1.1.0 - respond to changes in base table |
| 1082 |
* 1.1.1 - respond to changes in base table |
| 1083 |
*/ |
| 1084 |
table NCBI:align:tbl:align_mate_sorted #1.1.1 |
| 1085 |
= NCBI:align:tbl:align_full #1.1.1 |
| 1086 |
, NCBI:align:tbl:global_ref_block #1.0.0 |
| 1087 |
{ |
| 1088 |
// 128K |
| 1089 |
column default limit = 131072; |
| 1090 |
}; |
| 1091 |
|
| 1092 |
|
| 1093 |
/* align_mate_unsorted |
| 1094 |
* |
| 1095 |
* History: |
| 1096 |
* 1.1.0 - respond to changes in base table |
| 1097 |
* 1.1.1 - respond to changes in base table |
| 1098 |
*/ |
| 1099 |
table NCBI:align:tbl:align_mate_unsorted #1.1.1 |
| 1100 |
= NCBI:align:tbl:align_full #1.1.1 |
| 1101 |
, NCBI:align:tbl:local_ref_block #1.0.0 |
| 1102 |
{ |
| 1103 |
// 128K |
| 1104 |
column default limit = 131072; |
| 1105 |
}; |
| 1106 |
|
| 1107 |
/* align_allele |
| 1108 |
* alleles coverage extension |
| 1109 |
* |
| 1110 |
* History: |
| 1111 |
* 1.2.0 - respond to changes in base table |
| 1112 |
* 1.2.1 - respond to changes in base table |
| 1113 |
*/ |
| 1114 |
table NCBI:align:tbl:align_allele #1.2.1 |
| 1115 |
= NCBI:align:tbl:align_unsorted #1.2.1 |
| 1116 |
{ |
| 1117 |
extern column < I64 > izip_encoding EVIDENCE_ALIGNMENT_IDS; |
| 1118 |
|
| 1119 |
/* |
| 1120 |
INSDC:quality:phred out_qual_phred |
| 1121 |
= < INSDC:quality:phred > echo < 30 > ( out_4na_bin ); |
| 1122 |
*/ |
| 1123 |
}; |
| 1124 |
|
| 1125 |
/*-------------------------------------------------------------------------- |
| 1126 |
* seq |
| 1127 |
* alignment sequence table |
| 1128 |
* |
| 1129 |
* history: |
| 1130 |
* 1.1.1 - respond to changes in base table |
| 1131 |
* 2.0.0 - NCBI:tbl:base_space uses metadata RNA_Flag to support RNA reads |
| 1132 |
*/ |
| 1133 |
physical |
| 1134 |
I64 NCBI:align:sorted:alignment_id_encoding #1.0 |
| 1135 |
{ |
| 1136 |
decode |
| 1137 |
{ |
| 1138 |
I64 outliers_removed = iunzip ( @ ); |
| 1139 |
return < I64 > outlier_decode < 0 > ( outliers_removed ); |
| 1140 |
} |
| 1141 |
|
| 1142 |
encode |
| 1143 |
{ |
| 1144 |
I64 outliers_removed = < I64 > outlier_encode < 0 > ( @ ); |
| 1145 |
return izip ( outliers_removed ); |
| 1146 |
} |
| 1147 |
} |
| 1148 |
|
| 1149 |
table NCBI:align:tbl:seq #2 = |
| 1150 |
NCBI:tbl:base_space #3, |
| 1151 |
NCBI:tbl:phred_quality #2.0, |
| 1152 |
NCBI:align:tbl:cmp_base_space #1, |
| 1153 |
NCBI:SRA:tbl:spotdesc #1.1, |
| 1154 |
NCBI:SRA:tbl:stats #1.2.1 |
| 1155 |
{ |
| 1156 |
// 128K |
| 1157 |
column default limit = 131072; |
| 1158 |
|
| 1159 |
// gets primary record in alignment table (size of column is NREADS) |
| 1160 |
// if sorted - should used special encoding |
| 1161 |
extern column <I64> izip_encoding PRIMARY_ALIGNMENT_ID; |
| 1162 |
|
| 1163 |
INSDC:coord:zero trim_start = < INSDC:coord:zero > echo < 0 > (); |
| 1164 |
INSDC:coord:len trim_len = _spot_len; |
| 1165 |
|
| 1166 |
// size is NREADS |
| 1167 |
extern column < U8 > zip_encoding ALIGNMENT_COUNT; |
| 1168 |
|
| 1169 |
// unparsed read name |
| 1170 |
extern column < ascii > zip_encoding RAW_NAME; |
| 1171 |
|
| 1172 |
// auto-generate name from row-id |
| 1173 |
ascii out_name_fmt = .RAW_NAME | < ascii > echo < '$R' > (); |
| 1174 |
|
| 1175 |
// temparary column |
| 1176 |
extern column < U64 > izip_encoding TMP_KEY_ID; |
| 1177 |
|
| 1178 |
// restored READ |
| 1179 |
INSDC:4na:bin out_dcmp_4na_bin |
| 1180 |
= NCBI:align:seq_restore_read (out_cmp_4na_bin, .PRIMARY_ALIGNMENT_ID, .READ_LEN, .READ_TYPE); |
| 1181 |
|
| 1182 |
extern column < U64 > izip_encoding TI; |
| 1183 |
|
| 1184 |
extern column <ascii> zip_encoding CMP_LINKAGE_GROUP; |
| 1185 |
|
| 1186 |
// restored LINKAGE_GROUP |
| 1187 |
readonly column ascii LINKAGE_GROUP = NCBI:align:seq_restore_linkage_group(.CMP_LINKAGE_GROUP, .PRIMARY_ALIGNMENT_ID) |
| 1188 |
| .CMP_LINKAGE_GROUP; |
| 1189 |
|
| 1190 |
}; |
| 1191 |
|
| 1192 |
/*********************************** |
| 1193 |
* Reference table - to store reference sequences |
| 1194 |
* Sequences are divided in chunks. Two sequences never share a chunk. |
| 1195 |
* SEQ_LEN - real size of a chunk should never exceed MAX_SEQ_LEN when it is set |
| 1196 |
* READ - inherited from NCBI:tbl:base_space |
| 1197 |
* CMP_READ,CMP_ALTREAD - are inherited from NCBI:align:tbl:cmp_base_space |
| 1198 |
* SEQ_ID,SEQ_START,SEQ_LEN are inherited from NCBI:align:tbl:seqloc |
| 1199 |
* .skey contains NAME of the chunk - it corresponds to actual name used in BAM (chr1,chr2, etc....) |
| 1200 |
* |
| 1201 |
* SEQ_START,SEQ_LEN,MAX_SEQ_LEN,SEQID and rowlen(READ) operate the following way |
| 1202 |
* - SEQ_LEN < MAX_SEQ_LEN - should only happen on the last chunk of the sequence |
| 1203 |
* - .READ is absent - there should be a retrieval from external services by SEQ_ID,SEQ_START,SEQ_LEN |
| 1204 |
* - rowlen(.READ) = 0 && SEQ_START==0 (used as flag) - the sequence is SEQ_LEN repetition of 'N' |
| 1205 |
* - rowlen(.READ) = 0 && SEQ_START >= 1 - the sequence have to be fetched from external sources |
| 1206 |
* - 0 < rowlen(.READ)< SEQ_LEN -- the sequence have to be filled with 'N's |
| 1207 |
* |
| 1208 |
* history: |
| 1209 |
* 2.0.1 - respond to changes in base table |
| 1210 |
* 3.0.0 - NCBI:tbl:base_space uses metadata RNA_Flag to support RNA reads |
| 1211 |
***********************************/ |
| 1212 |
table NCBI:align:tbl:reference #3 = |
| 1213 |
NCBI:align:tbl:cmp_base_space #1, |
| 1214 |
NCBI:tbl:base_space #3, |
| 1215 |
NCBI:tbl:seqloc #1, |
| 1216 |
NCBI:SRA:tbl:stats #1.2.1 |
| 1217 |
{ |
| 1218 |
INSDC:quality:phred out_qual_phred |
| 1219 |
= < INSDC:quality:phred > echo < 30 > ( out_dcmp_4na_bin ); |
| 1220 |
|
| 1221 |
// MAX_SEQ_LEN - should be a constant == static column |
| 1222 |
extern column < U32 > izip_encoding MAX_SEQ_LEN; |
| 1223 |
|
| 1224 |
// indicates if sequence has circular structure |
| 1225 |
// copied from refSeq |
| 1226 |
extern column bool_encoding CIRCULAR; |
| 1227 |
|
| 1228 |
// make CS_KEY writable |
| 1229 |
INSDC:dna:text in_cs_key |
| 1230 |
= < INSDC:dna:text, INSDC:dna:text > map < 'acgtn', 'ACGTN' > ( CS_KEY ); |
| 1231 |
physical column < INSDC:dna:text > zip_encoding .CS_KEY = in_cs_key; |
| 1232 |
|
| 1233 |
U32 in_spot_len = SEQ_LEN; |
| 1234 |
|
| 1235 |
INSDC:coord:len _alt_in_read_len |
| 1236 |
= READ_LEN |
| 1237 |
| SEQ_LEN; |
| 1238 |
|
| 1239 |
INSDC:SRA:xread_type _alt_in_read_type |
| 1240 |
= READ_TYPE |
| 1241 |
| < INSDC:SRA:xread_type > echo < SRA_READ_TYPE_BIOLOGICAL > (); |
| 1242 |
|
| 1243 |
// extra columns needed for CS conversion |
| 1244 |
INSDC:coord:zero out_read_start = < INSDC:coord:zero > echo < 0 > (); |
| 1245 |
INSDC:coord:len out_read_len = .SEQ_LEN; |
| 1246 |
|
| 1247 |
extern column utf8 NAME = out_spot_name_utf8; |
| 1248 |
physical utf8 .NAME = idx:text:insert #1.0 < 'i_name' > ( NAME ); |
| 1249 |
|
| 1250 |
utf8 out_spot_name_utf8 = idx:text:project #1.0 < 'i_name' > (.NAME ); |
| 1251 |
|
| 1252 |
ascii out_spot_name = cast ( out_spot_name_utf8 ); |
| 1253 |
|
| 1254 |
INSDC:coord:zero trim_start = < INSDC:coord:zero > echo < 0 > (); |
| 1255 |
INSDC:coord:len trim_len = base_space_spot_len; |
| 1256 |
|
| 1257 |
ascii out_label |
| 1258 |
= < ascii > echo < "reference" > (); |
| 1259 |
INSDC:coord:zero out_label_start |
| 1260 |
= < INSDC:coord:zero > echo < 0 > (); |
| 1261 |
INSDC:coord:len out_label_len |
| 1262 |
= < INSDC:coord:len > echo < 9 > (); |
| 1263 |
|
| 1264 |
U32 out_nreads |
| 1265 |
= < U32 > echo < 1 > (); |
| 1266 |
INSDC:SRA:xread_type out_read_type |
| 1267 |
= < INSDC:SRA:xread_type > echo < 3 > (); |
| 1268 |
INSDC:SRA:read_filter out_rd_filter |
| 1269 |
= < INSDC:SRA:read_filter > echo < SRA_READ_FILTER_PASS > (); |
| 1270 |
|
| 1271 |
|
| 1272 |
// Columns of computed coverages by alignment |
| 1273 |
|
| 1274 |
// TBD: use percentiles instead of min/max? |
| 1275 |
// maximum value clipped at 255 of the coverage density |
| 1276 |
// for a chunk |
| 1277 |
extern column < U8 > izip_encoding CGRAPH_HIGH; |
| 1278 |
|
| 1279 |
// minimum value clipped at 255 of the coverage density |
| 1280 |
// for a chunk |
| 1281 |
extern column < U8 > izip_encoding CGRAPH_LOW; |
| 1282 |
|
| 1283 |
// count of the number of mismatches in the chunk |
| 1284 |
extern column < U32 > izip_encoding CGRAPH_MISMATCHES; |
| 1285 |
|
| 1286 |
// count of the number of inserts and deletes in the chunk |
| 1287 |
extern column < U32 > izip_encoding CGRAPH_INDELS; |
| 1288 |
|
| 1289 |
// List of row ids from alignment tables |
| 1290 |
extern column < I64 > izip_encoding PRIMARY_ALIGNMENT_IDS; |
| 1291 |
extern column < I64 > izip_encoding SECONDARY_ALIGNMENT_IDS; |
| 1292 |
extern column < I64 > izip_encoding EVIDENCE_INTERVAL_IDS; |
| 1293 |
|
| 1294 |
// both OVERLAP_REF_* columns are array of three elements, matching number of *_IDS columns above. |
| 1295 |
// points back to an offset where the alignments to this chunk start |
| 1296 |
extern column < INSDC:coord:zero > izip_encoding OVERLAP_REF_POS; |
| 1297 |
// indicates the length of the longest tail of the alignmnent to this chunk which start in previous chunks |
| 1298 |
// if value of an element in this col is zero corresponding value of OVERLAP_REF_POS is meaningless |
| 1299 |
extern column < INSDC:coord:len > izip_encoding OVERLAP_REF_LEN; |
| 1300 |
|
| 1301 |
// Mechanism to seach for NAME |
| 1302 |
readonly column vdb:row_id_range NAME_RANGE |
| 1303 |
= idx:text:lookup #1.0 < 'i_name', 'QUERY_SEQ_NAME' > (); |
| 1304 |
|
| 1305 |
// Fully instantiates READ |
| 1306 |
INSDC:4na:bin out_dcmp_4na_bin |
| 1307 |
= NCBI:align:ref_restore_read (out_cmp_4na_bin, .SEQ_ID, .SEQ_START, .SEQ_LEN); |
| 1308 |
} |
| 1309 |
|
| 1310 |
// THE DATABASES |
| 1311 |
database NCBI:align:db:alignment_sorted #2 |
| 1312 |
{ |
| 1313 |
table NCBI:align:tbl:reference #3 REFERENCE; |
| 1314 |
table NCBI:align:tbl:align_sorted #1.2.1 PRIMARY_ALIGNMENT; |
| 1315 |
table NCBI:align:tbl:align_mate_sorted #1.1.1 SECONDARY_ALIGNMENT; |
| 1316 |
table NCBI:align:tbl:seq #2 SEQUENCE; |
| 1317 |
table NCBI:align:tbl:qstat #1.0 QUAL_STAT; |
| 1318 |
}; |
| 1319 |
|
| 1320 |
database NCBI:align:db:alignment_unsorted #2 |
| 1321 |
{ |
| 1322 |
table NCBI:align:tbl:reference #3 REFERENCE; |
| 1323 |
table NCBI:align:tbl:align_unsorted #1.2.1 PRIMARY_ALIGNMENT; |
| 1324 |
table NCBI:align:tbl:align_mate_unsorted #1.1.1 SECONDARY_ALIGNMENT; |
| 1325 |
table NCBI:align:tbl:seq #2 SEQUENCE; |
| 1326 |
table NCBI:align:tbl:qstat #1.0 QUAL_STAT; |
| 1327 |
}; |
| 1328 |
|
| 1329 |
database NCBI:align:db:alignment_evidence #2 |
| 1330 |
{ |
| 1331 |
table NCBI:align:tbl:reference #3 REFERENCE; |
| 1332 |
table NCBI:align:tbl:align_unsorted #1.2.1 PRIMARY_ALIGNMENT; |
| 1333 |
table NCBI:align:tbl:align_mate_unsorted #1.1.1 SECONDARY_ALIGNMENT; |
| 1334 |
table NCBI:align:tbl:align_allele #1.2.1 EVIDENCE_INTERVAL; |
| 1335 |
table NCBI:align:tbl:align_mate_unsorted #1.1.1 EVIDENCE_ALIGNMENT; |
| 1336 |
table NCBI:align:tbl:seq #2 SEQUENCE; |
| 1337 |
table NCBI:align:tbl:qstat #1.0 QUAL_STAT; |
| 1338 |
}; |
| 1339 |
|
| 1340 |
database NCBI:align:db:alignment_evidence_sorted #2 |
| 1341 |
{ |
| 1342 |
table NCBI:align:tbl:reference #3 REFERENCE; |
| 1343 |
table NCBI:align:tbl:align_sorted #1.2.1 PRIMARY_ALIGNMENT; |
| 1344 |
table NCBI:align:tbl:align_mate_sorted #1.1.1 SECONDARY_ALIGNMENT; |
| 1345 |
table NCBI:align:tbl:align_allele #1.2.1 EVIDENCE_INTERVAL; |
| 1346 |
table NCBI:align:tbl:align_mate_unsorted #1.1.1 EVIDENCE_ALIGNMENT; |
| 1347 |
table NCBI:align:tbl:seq #2 SEQUENCE; |
| 1348 |
table NCBI:align:tbl:qstat #1.0 QUAL_STAT; |
| 1349 |
}; |
| 1350 |
|
| 1351 |
database NCBI:align:db:unaligned #2 |
| 1352 |
{ |
| 1353 |
table NCBI:align:tbl:seq #2 SEQUENCE; |
| 1354 |
table NCBI:align:tbl:qstat #1.0 QUAL_STAT; |
| 1355 |
}; |