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 #ifndef _sra_load_srf_ 27 #define _sra_load_srf_ 28 29 #include "writer-illumina.h" 30 31 #define SRF_READ_BAD (1U << 0) 32 #define SRF_READ_WITHDRAWN (1U << 1) 33 34 #define SRF_CONTAINER_HEADER_MIN_SIZE (8) 35 #define SRF_BLOCK_HEADER_MIN_SIZE (5) 36 37 enum SRF_ChunkTypes { 38 SRF_ChunkTypeUnknown = '?', 39 SRF_ChunkTypeContainer = 'S', 40 SRF_ChunkTypeIndex = 'I', 41 SRF_ChunkTypeHeader = 'H', 42 SRF_ChunkTypeRead = 'R', 43 SRF_ChunkTypeXML = 'X' 44 }; 45 46 /* SRF_ParseChunk 47 try to parse an SRF chunk 48 49 returns: 50 0: no error 51 rcInsufficient: not enough src data to parse; 52 provide more data or declare an error 53 rcInvalid: the data is invalid 54 55 Parameters: 56 src [in, required]: the bytes to parse 57 srclen: the number of bytes parsable 58 size [out, required]: the total size of the chunk 59 the next chunk starts at src + size 60 type [out, required]: the type of chunk found 61 data [out, required]: the start of any inner data 62 in the chunk 63 */ 64 enum RCState SRF_ParseChunk(const uint8_t *src, 65 size_t srclen, 66 uint64_t *size, 67 enum SRF_ChunkTypes *type, 68 size_t *data); 69 70 /* SRF_ParseContainerHeader 71 try to parse an SRF Container Header 72 73 Returns: 74 0: no error 75 rcInsufficient: not enough data 76 rcInvalid: data invalid 77 78 Parameters: 79 src [in, required]: the bytes to parse 80 src_length: the length of src 81 versMajor, versMinor [out, optional]: SRF version 82 contType [out, optional]: type of the data contained in 83 this SRF; *contType should be 'Z' per the spec. 84 baseCaller [out, optional]: the base caller program that 85 generated the contained data 86 baseCallerVersion [out, optional]: the version of 87 base caller program 88 */ 89 int SRF_ParseContainerHeader(const uint8_t *src, 90 uint64_t src_length, 91 unsigned *versMajor, 92 unsigned *versMinor, 93 char *contType, 94 pstring *baseCaller, 95 pstring *baseCallerVersion); 96 97 /* SRF_ParseDataChunk 98 try to parse an SRF data chunk (i.e. block header type = 'H') 99 100 Returns: 101 0: no error 102 rcInsufficient: not enough data 103 rcInvalid: data invalid 104 105 Parameters: 106 src [in, required]: the bytes to parse 107 src_length: the length of src 108 parsed_length [out, required]: length of SRF data in 109 this chunk; the bytes src[parsed_length..src_length], 110 if any, are ZTR. 111 prefix [out, optional]: (pstring) read name prefix, if any 112 prefixType [out, optional]: read name prefix type 'E' or 'I' 113 counter [out, optional]: initial value of counter, only 114 relevant if prefixType == 'I' 115 */ 116 int SRF_ParseDataChunk(const uint8_t *src, 117 size_t src_length, 118 size_t *parsed_length, 119 pstring *prefix, 120 char *prefixType, 121 uint32_t *counter); 122 123 /* SRF_ParseReadChunk 124 try to parse an SRF read chunk (i.e. block header type = 'R') 125 126 Returns: 127 0: no error 128 rcInsufficient: not enough data 129 rcInvalid: data invalid 130 131 Parameters: 132 src [in, required]: the bytes to parse 133 src_length: the length of src 134 parsed_length [out, required]: length of SRF data in 135 this chunk; the bytes src[parsed_length..src_length], 136 if any, are ZTR. 137 flags [out, optional]: read flags 138 id [out, optional]: read Id 139 */ 140 int SRF_ParseReadChunk(const uint8_t *src, 141 size_t src_length, 142 size_t *parsed_length, 143 uint8_t *flags, 144 pstring *id); 145 146 #endif /* _sra_load_srf_ */ 147