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 #ifndef _h_ngs_read_collection_
28 #define _h_ngs_read_collection_
29 
30 typedef struct NGS_ReadCollection NGS_ReadCollection;
31 #ifndef NGS_READCOLLECTION
32 #define NGS_READCOLLECTION NGS_ReadCollection
33 #endif
34 
35 #ifndef _h_NGS_Refcount_
36     #ifndef NGS_REFCOUNT
37     #define NGS_REFCOUNT NGS_READCOLLECTION
38     #endif
39 #include "NGS_Refcount.h"
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /*--------------------------------------------------------------------------
47  * forwards
48  */
49 struct VDatabase;
50 struct VTable;
51 struct NGS_Read;
52 struct NGS_String;
53 struct NGS_ReadCollection_v1_vt;
54 extern struct NGS_ReadCollection_v1_vt ITF_ReadCollection_vt;
55 
56 /*--------------------------------------------------------------------------
57  * NGS_ReadCollection
58  */
59 
60 /* ToRefcount
61  *  inline cast that preserves const
62  */
63 #define NGS_ReadCollectionToRefcount( self ) \
64     ( & ( self ) -> dad )
65 
66 /* Release
67  *  release reference
68  */
69 #define NGS_ReadCollectionRelease( self, ctx ) \
70     NGS_RefcountRelease ( NGS_ReadCollectionToRefcount ( self ), ctx )
71 
72 /* Duplicate
73  *  duplicate reference
74  */
75 #define NGS_ReadCollectionDuplicate( self, ctx ) \
76     ( ( NGS_ReadCollection* ) NGS_RefcountDuplicate ( NGS_ReadCollectionToRefcount ( self ), ctx ) )
77 
78 /* Make
79  *  use provided specification to create an object
80  *  any error returns NULL as a result and sets error in ctx
81  */
82 NGS_ReadCollection * NGS_ReadCollectionMake ( ctx_t ctx, const char * spec );
83 
84 /* additional make functions
85  *  use provided specification to create an object
86  *  any error returns NULL as a result and sets error in ctx
87  */
88 NGS_ReadCollection * NGS_ReadCollectionMakeCSRA ( ctx_t ctx, struct VDatabase const *db, const char * spec );
89 NGS_ReadCollection * NGS_ReadCollectionMakeVDatabase ( ctx_t ctx, struct VDatabase const *db, const char * spec );
90 NGS_ReadCollection * NGS_ReadCollectionMakeVTable ( ctx_t ctx, struct VTable const *tbl, const char * spec );
91 
92 
93 /* GetName
94  */
95 struct NGS_String * NGS_ReadCollectionGetName ( NGS_ReadCollection * self, ctx_t ctx );
96 
97 
98 /* READ GROUPS
99  */
100 struct NGS_ReadGroup * NGS_ReadCollectionGetReadGroups ( NGS_ReadCollection * self, ctx_t ctx );
101 bool NGS_ReadCollectionHasReadGroup ( NGS_ReadCollection * self, ctx_t ctx, const char * spec );
102 struct NGS_ReadGroup * NGS_ReadCollectionGetReadGroup ( NGS_ReadCollection * self, ctx_t ctx, const char * spec );
103 
104 
105 /* REFERENCES
106  */
107 struct NGS_Reference * NGS_ReadCollectionGetReferences ( NGS_ReadCollection * self, ctx_t ctx );
108 bool NGS_ReadCollectionHasReference ( NGS_ReadCollection * self, ctx_t ctx, const char * spec );
109 struct NGS_Reference * NGS_ReadCollectionGetReference ( NGS_ReadCollection * self, ctx_t ctx, const char * spec );
110 
111 
112 /* ALIGNMENTS
113  */
114 struct NGS_Alignment * NGS_ReadCollectionGetAlignments ( NGS_ReadCollection * self, ctx_t ctx,
115     bool wants_primary, bool wants_secondary );
116 struct NGS_Alignment * NGS_ReadCollectionGetAlignment ( NGS_ReadCollection * self, ctx_t ctx, const char * alignmentId );
117 
118 uint64_t NGS_ReadCollectionGetAlignmentCount ( NGS_ReadCollection * self, ctx_t ctx,
119     bool wants_primary, bool wants_secondary );
120 
121 struct NGS_Alignment * NGS_ReadCollectionGetAlignmentRange ( NGS_ReadCollection * self, ctx_t ctx, uint64_t first, uint64_t count,
122     bool wants_primary, bool wants_secondary );
123 
124 /* READS
125  */
126 struct NGS_Read * NGS_ReadCollectionGetRead ( NGS_ReadCollection * self, ctx_t ctx, const char * readId );
127 struct NGS_Read * NGS_ReadCollectionGetReads ( NGS_ReadCollection * self, ctx_t ctx,
128     bool wants_full, bool wants_partial, bool wants_unaligned );
129 
130 uint64_t NGS_ReadCollectionGetReadCount ( NGS_ReadCollection * self, ctx_t ctx,
131     bool wants_full, bool wants_partial, bool wants_unaligned );
132 
133 struct NGS_Read * NGS_ReadCollectionGetReadRange ( NGS_ReadCollection * self,
134                                                    ctx_t ctx,
135                                                    uint64_t first,
136                                                    uint64_t count,
137                                                    bool wants_full,
138                                                    bool wants_partial,
139                                                    bool wants_unaligned );
140 
141 /* STATISTICS
142  */
143 struct NGS_Statistics* NGS_ReadCollectionGetStatistics ( NGS_ReadCollection * self, ctx_t ctx );
144 
145 /* FRAGMENT BLOBS
146  */
147 struct NGS_FragmentBlobIterator* NGS_ReadCollectionGetFragmentBlobs ( NGS_ReadCollection * self, ctx_t ctx );
148 
149 /*--------------------------------------------------------------------------
150  * implementation details
151  */
152 struct NGS_ReadCollection
153 {
154     NGS_Refcount dad;
155 };
156 
157 typedef struct NGS_ReadCollection_vt NGS_ReadCollection_vt;
158 struct NGS_ReadCollection_vt
159 {
160     NGS_Refcount_vt dad;
161 
162     struct NGS_String*      ( * get_name )              ( NGS_READCOLLECTION * self, ctx_t ctx );
163     struct NGS_ReadGroup*   ( * get_read_groups )       ( NGS_READCOLLECTION * self, ctx_t ctx );
164            bool             ( * has_read_group )        ( NGS_READCOLLECTION * self, ctx_t ctx, const char * spec );
165     struct NGS_ReadGroup*   ( * get_read_group )        ( NGS_READCOLLECTION * self, ctx_t ctx, const char * spec );
166     struct NGS_Reference*   ( * get_references )        ( NGS_READCOLLECTION * self, ctx_t ctx );
167            bool             ( * has_reference )         ( NGS_READCOLLECTION * self, ctx_t ctx, const char * spec );
168     struct NGS_Reference*   ( * get_reference )         ( NGS_READCOLLECTION * self, ctx_t ctx, const char * spec );
169     struct NGS_Alignment*   ( * get_alignments )        ( NGS_READCOLLECTION * self, ctx_t ctx, bool wants_primary, bool wants_secondary );
170     struct NGS_Alignment*   ( * get_alignment )         ( NGS_READCOLLECTION * self, ctx_t ctx, const char * alignmentId );
171     uint64_t                ( * get_alignment_count )   ( NGS_READCOLLECTION * self, ctx_t ctx, bool wants_primary, bool wants_secondary );
172     struct NGS_Alignment*   ( * get_alignment_range )   ( NGS_READCOLLECTION * self, ctx_t ctx, uint64_t first, uint64_t count, bool wants_primary, bool wants_secondary );
173     struct NGS_Read*        ( * get_reads )             ( NGS_READCOLLECTION * self, ctx_t ctx, bool wants_full, bool wants_partial, bool wants_unaligned );
174     struct NGS_Read*        ( * get_read )              ( NGS_READCOLLECTION * self, ctx_t ctx, const char * readId );
175     uint64_t                ( * get_read_count )        ( NGS_READCOLLECTION * self, ctx_t ctx,
176         bool wants_full, bool wants_partial, bool wants_unaligned );
177     struct NGS_Read*        ( * get_read_range )        ( NGS_READCOLLECTION * self, ctx_t ctx, uint64_t first, uint64_t count, bool wants_full, bool wants_partial, bool wants_unaligned );
178     struct NGS_Statistics*  ( * get_statistics )        ( NGS_READCOLLECTION * self, ctx_t ctx );
179 
180     struct NGS_FragmentBlobIterator *  ( * get_frag_blobs ) ( NGS_READCOLLECTION * self, ctx_t ctx );
181 };
182 
183 
184 /* Init
185  */
186 void NGS_ReadCollectionInit ( ctx_t ctx, NGS_ReadCollection * ref,
187     const NGS_ReadCollection_vt *vt, const char *clsname, const char *instname );
188 
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* _h_ngs_read_collection_ */
195