| 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 |
* NCBI Sequence Read Archive schema |
| 29 |
*/ |
| 30 |
version 1; |
| 31 |
|
| 32 |
include 'ncbi/sra.vschema'; |
| 33 |
include 'ncbi/spotname.vschema'; |
| 34 |
|
| 35 |
|
| 36 |
/*-------------------------------------------------------------------------- |
| 37 |
* NCBI:SRA:tbl:clip |
| 38 |
* common clip column processing |
| 39 |
* shared by 454 and ion-torrent |
| 40 |
* |
| 41 |
* uses spotdesc because it has a dependency upon spot_len |
| 42 |
* |
| 43 |
* history: |
| 44 |
* 1.0.1 - base explicitly upon spotdesc #1.0.1 |
| 45 |
* 1.0.2 - base explicitly upon spotdesc #1.0.2 |
| 46 |
*/ |
| 47 |
table NCBI:SRA:tbl:clip #1.0.2 = INSDC:SRA:tbl:spotdesc #1.0.2 |
| 48 |
{ |
| 49 |
/* CLIP_ADAPTER_LEFT, CLIP_ADAPTER_RIGHT |
| 50 |
* adapter clips in 1-based coordinates |
| 51 |
* when value is 0, implies that they are NOT SET |
| 52 |
*/ |
| 53 |
column INSDC:coord:one CLIP_ADAPTER_LEFT = out_clip_adapt_left; |
| 54 |
column INSDC:coord:one CLIP_ADAPTER_RIGHT = out_clip_adapt_right; |
| 55 |
|
| 56 |
// casts are required to allow multple storage formats |
| 57 |
INSDC:coord:one out_clip_adapt_left = cast ( .CLIP_ADAPTER_LEFT ); |
| 58 |
INSDC:coord:one out_clip_adapt_right = cast ( .CLIP_ADAPTER_RIGHT ); |
| 59 |
|
| 60 |
|
| 61 |
/* CLIP_QUALITY_LEFT, CLIP_QUALITY_RIGHT |
| 62 |
* quality clips in 1-based coordinates |
| 63 |
* when value is 0, implies that they are NOT SET |
| 64 |
*/ |
| 65 |
column INSDC:coord:one CLIP_QUALITY_LEFT = out_clip_qual_left; |
| 66 |
column INSDC:coord:one CLIP_QUALITY_RIGHT = out_clip_qual_right; |
| 67 |
|
| 68 |
// casts are required to allow multple storage formats |
| 69 |
INSDC:coord:one out_clip_qual_left |
| 70 |
= cast ( .CLIP_QUALITY_LEFT ) |
| 71 |
| < INSDC:coord:one > echo < 1 > (); |
| 72 |
INSDC:coord:one out_clip_qual_right |
| 73 |
= cast ( .CLIP_QUALITY_RIGHT ) |
| 74 |
| cast ( spot_len ); |
| 75 |
|
| 76 |
// support for reading 16-bit clips, as in v1 schema |
| 77 |
readonly column U16 CLIP_ADAPTER_LEFT |
| 78 |
= .CLIP_ADAPTER_LEFT |
| 79 |
| cast ( out_clip_adapt_left ); |
| 80 |
readonly column U16 CLIP_ADAPTER_RIGHT |
| 81 |
= .CLIP_ADAPTER_RIGHT |
| 82 |
| cast ( out_clip_adapt_right ); |
| 83 |
readonly column U16 CLIP_QUALITY_LEFT = cast ( out_clip_qual_left ); |
| 84 |
readonly column U16 CLIP_QUALITY_RIGHT = cast ( out_clip_qual_right ); |
| 85 |
|
| 86 |
|
| 87 |
/* CLIP-MANIA |
| 88 |
*/ |
| 89 |
|
| 90 |
// 1-based fully-closed right edge is row-length |
| 91 |
INSDC:coord:one spot_right = ( INSDC:coord:one ) spot_len; |
| 92 |
|
| 93 |
// processed 1-based coordinates >= 1 |
| 94 |
INSDC:coord:one lim_clip_adapt_left |
| 95 |
= < INSDC:coord:one > clip < 1, 0x7FFFFFFF > ( out_clip_adapt_left ); |
| 96 |
INSDC:coord:one max_clip_adapt_right |
| 97 |
= < INSDC:coord:one, INSDC:coord:one > map < 0, 0x7FFFFFFF > ( out_clip_adapt_right ); |
| 98 |
INSDC:coord:one lim_clip_adapt_right |
| 99 |
= < INSDC:coord:one > min ( spot_right, max_clip_adapt_right ); |
| 100 |
INSDC:coord:one lim_clip_qual_left |
| 101 |
= < INSDC:coord:one > clip < 1, 0x7FFFFFFF > ( out_clip_qual_left ); |
| 102 |
INSDC:coord:one max_clip_qual_right |
| 103 |
= < INSDC:coord:one, INSDC:coord:one > map < 0, 0x7FFFFFFF > ( out_clip_qual_right ); |
| 104 |
INSDC:coord:one lim_clip_qual_right |
| 105 |
= < INSDC:coord:one > min ( spot_right, max_clip_qual_right ); |
| 106 |
|
| 107 |
// read-only columns with 0-based coordinates |
| 108 |
readonly column INSDC:coord:zero CLIP_ADAPTER_LEFT |
| 109 |
= ( INSDC:coord:zero ) < I32 > diff < 1 > ( lim_clip_adapt_left ); |
| 110 |
readonly column INSDC:coord:zero CLIP_ADAPTER_RIGHT |
| 111 |
= ( INSDC:coord:zero ) < I32 > diff < 1 > ( lim_clip_adapt_right ); |
| 112 |
readonly column INSDC:coord:zero CLIP_QUALITY_LEFT |
| 113 |
= ( INSDC:coord:zero ) < I32 > diff < 1 > ( lim_clip_qual_left ); |
| 114 |
readonly column INSDC:coord:zero CLIP_QUALITY_RIGHT |
| 115 |
= ( INSDC:coord:zero ) < I32 > diff < 1 > ( lim_clip_qual_right ); |
| 116 |
|
| 117 |
// combined clips |
| 118 |
INSDC:coord:one max_clip_left |
| 119 |
= < INSDC:coord:one > max ( lim_clip_adapt_left, lim_clip_qual_left ) |
| 120 |
| lim_clip_adapt_left |
| 121 |
| lim_clip_qual_left; |
| 122 |
INSDC:coord:zero max_zclip_left |
| 123 |
= ( INSDC:coord:zero ) < I32 > diff < 1 > ( max_clip_left ); |
| 124 |
INSDC:coord:one min_clip_right |
| 125 |
= < INSDC:coord:one > min ( lim_clip_adapt_right, lim_clip_qual_right ) |
| 126 |
| lim_clip_adapt_right |
| 127 |
| lim_clip_qual_right; |
| 128 |
|
| 129 |
|
| 130 |
/* TRIMMED SEQUENCE |
| 131 |
* need to find the 0-based trim_start and trim_len |
| 132 |
*/ |
| 133 |
INSDC:coord:zero bio_start |
| 134 |
= NCBI:SRA:bio_start ( out_read_start, out_read_type ); |
| 135 |
INSDC:coord:zero trim_start |
| 136 |
= < INSDC:coord:zero > max ( bio_start, max_zclip_left ) |
| 137 |
| bio_start; |
| 138 |
|
| 139 |
INSDC:coord:zero bio_end |
| 140 |
= NCBI:SRA:bio_end < false > ( out_read_start, out_read_type, out_read_len ); |
| 141 |
|
| 142 |
I32 trim_stop |
| 143 |
= < I32 > max ( min_clip_right, trim_start ) |
| 144 |
| spot_right; |
| 145 |
INSDC:coord:len trim_len |
| 146 |
= ( INSDC:coord:len ) < I32 > diff ( trim_stop, trim_start ); |
| 147 |
}; |