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 _h_sra_abi_
27 #define _h_sra_abi_
28 
29 #ifndef _h_sra_rd_extern_
30 #include <sra/rd-extern.h>
31 #endif
32 
33 #ifndef _h_sra_sradb_
34 #include <sra/sradb.h>
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*--------------------------------------------------------------------------
42  * AbsolidReader
43  */
44 typedef struct AbsolidReader AbsolidReader;
45 
46 /* Make
47  *  create AbsolidReader reference based
48  *  on opened table and properties:
49  *     table      - SRATable
50  *     accession  - accession
51  *     minReadLen - minimal length of the outputed read, 0 - no minimum (FUSE)
52  *     origFormat - excludes SRR accession & length on defline
53  *     noclip     - don't clip quality left and right
54  *     minSpotId  - starting spot id, 0 - ignored (run information used)
55  *     maxSpotId  - ending spot id, 0 - ignored (run information used)
56  *                  you cannot seek out of range of [minSpotId:maxSpotId]
57  */
58 SRA_RD_EXTERN rc_t CC AbsolidReaderMake(const AbsolidReader** self, const SRATable* table,
59                                         const char* accession, bool origFormat,
60                                         bool noClip, uint32_t minReadLen,
61                                         spotid_t minSpotId, spotid_t maxSpotId, bool signal);
62 
63 /* Whack
64  *  releases object obtained from AbsolidReaderMake
65  */
66 SRA_RD_EXTERN rc_t CC AbsolidReaderWhack(const AbsolidReader* self);
67 
68 /* FirstSpot
69  *  set current spot to first in the run
70  */
71 SRA_RD_EXTERN rc_t CC AbsolidReaderFirstSpot(const AbsolidReader* self);
72 
73 /* SeekSpot
74  *  set current spot
75  * if error occured current spot position becomes 0
76  */
77 SRA_RD_EXTERN rc_t CC AbsolidReaderSeekSpot(const AbsolidReader* self, spotid_t spot);
78 
79 /* NextSpot
80  *  Seek to next spot from current
81  */
82 SRA_RD_EXTERN rc_t CC AbsolidReaderNextSpot(const AbsolidReader* self);
83 
84 /* CurrentSpot
85  *  Get current spot
86  *  sopt [OUT] - pointer to assign value of the current spot
87  * returns GetRCState(rc) == rcExhausted when out of spots
88  */
89 SRA_RD_EXTERN rc_t CC AbsolidReaderCurrentSpot(const AbsolidReader* self, spotid_t* spot);
90 
91 /* SpotInfo
92  *  Get current spot information
93  *  spotname [OUT] - pointer to assign value of the current spot name (can be NULL)
94  *  spotname_sz [OUT] - pointer to assign value of the length of the spot name (can be NULL)
95  *  spot_len [OUT] - pointer to assign value of the current spot length (can be NULL)
96  *  num_reads[OUT] - pointer to assign value of the number of reads in current spot (can be NULL)
97  */
98 SRA_RD_EXTERN rc_t CC AbsolidReader_SpotInfo(const AbsolidReader* self,
99                                              const char** spotname, size_t* spotname_sz,
100                                              uint32_t* spot_len, uint32_t* num_reads);
101 /* SpotReadInfo
102  *  Get read information for current spot
103  *  readid    [IN]  - 1-based read id
104  *  read_type [OUT] - pointer to assign value of the read type (can be NULL)
105  *  read_label[OUT] - pointer to assign value of the read label (can be NULL)
106  *  read_label_sz [OUT] - pointer to assign value of the length of the read label (can be NULL)
107  *  read_start[OUT] - pointer to assign value of the read start in spot (can be NULL)
108  *  read_len  [OUT] - pointer to assign value of the read length (can be NULL)
109  *  cskey     [OUT] - pointer to assign value of the read color space key (can be NULL)
110  *  if start and len is == 0 read is empty
111  */
112 SRA_RD_EXTERN rc_t CC AbsolidReader_SpotReadInfo(const AbsolidReader* self, uint32_t readId, SRAReadTypes* read_type,
113                                                  const char** read_label, INSDC_coord_len* read_label_sz,
114                                                  INSDC_coord_zero* read_start, INSDC_coord_len* read_len);
115 
116 /* SpotPrefix
117  *  retrieve current spot name prefix
118  *  prefix [OUT] - pointer to assign value of the spot name prefix
119  *  prefix_sz [OUT] - pointer to assign value of the length of the spot name prefix
120  */
121 SRA_RD_EXTERN rc_t CC AbsolidReaderSpotName(const AbsolidReader* self,
122                                             const char** prefix, size_t* prefix_sz,
123                                             const char** suffix, size_t* suffix_sz);
124 
125 /* BaseName
126  *  retrieve name string for the spot, result always has '\0' at the and (asciiz string)
127  *  readid [IN] - 1-based, if <= 0 than the whole spot, otherwise particular read
128  *  label  [IN] - overrides read label appending (printLabel), set to NULL by default
129  *  data   [IN] - pointer to buffer for printing
130  *  dsize  [IN] - data buffer size
131  *  written [IN,OUT] - optional number of bytes occupied by string
132  *                     (not including the trailing '\0' used to end output), may by more than dsize
133  */
134 SRA_RD_EXTERN rc_t CC AbsolidReaderHeader(const AbsolidReader* self, uint32_t readId,
135                                           char* data, size_t dsize, size_t* written);
136 
137 /* Base
138  *  retrieve bases for the spot
139  *  other parameters see description for AbsolidReaderBaseName above
140  */
141 SRA_RD_EXTERN rc_t CC AbsolidReaderBase(const AbsolidReader* self, uint32_t readId,
142                                         char* data, size_t dsize, size_t* written);
143 
144 /* Quality
145  *  retrieve quality string for the spot
146  *  other parameters see description for AbsolidReaderBaseName above
147  */
148 SRA_RD_EXTERN rc_t CC AbsolidReaderQuality(const AbsolidReader* self, uint32_t readId,
149                                            char* data, size_t dsize, size_t* written);
150 
151 /* Signals
152  *  retrieve signal string for the spot
153  *  other parameters see description for AbsolidReaderBaseName above
154  */
155 SRA_RD_EXTERN rc_t CC AbsolidReaderSignalFTC(const AbsolidReader* self, uint32_t readId,
156                                              char* data, size_t dsize, size_t* written);
157 SRA_RD_EXTERN rc_t CC AbsolidReaderSignalCY3(const AbsolidReader* self, uint32_t readId,
158                                              char* data, size_t dsize, size_t* written);
159 SRA_RD_EXTERN rc_t CC AbsolidReaderSignalTXR(const AbsolidReader* self, uint32_t readId,
160                                              char* data, size_t dsize, size_t* written);
161 SRA_RD_EXTERN rc_t CC AbsolidReaderSignalCY5(const AbsolidReader* self, uint32_t readId,
162                                              char* data, size_t dsize, size_t* written);
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif /* _h_sra_abi_ */
168