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 #include <ngs/adapter/ReadCollectionItf.hpp>
28 #include <ngs/adapter/StringItf.hpp>
29 #include <ngs/adapter/ReadGroupItf.hpp>
30 #include <ngs/adapter/ReferenceItf.hpp>
31 #include <ngs/adapter/AlignmentItf.hpp>
32 #include <ngs/adapter/ReadItf.hpp>
33 #include <ngs/adapter/ErrorMsg.hpp>
34 
35 #include "ErrBlock.hpp"
36 
37 namespace ngs_adapt
38 {
39 
40     /*----------------------------------------------------------------------
41      * ReadCollectionItf
42      */
43 
ReadCollectionItf()44     ReadCollectionItf :: ReadCollectionItf ()
45         : Refcount < ReadCollectionItf, NGS_ReadCollection_v1 > ( & ivt . dad )
46     {
47     }
48 
49 
get_name(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err)50     NGS_String_v1 * CC ReadCollectionItf :: get_name ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err )
51     {
52         const ReadCollectionItf * self = Self ( iself );
53         try
54         {
55             StringItf * val = self -> getName ();
56             return val -> Cast ();
57         }
58         catch ( ... )
59         {
60             ErrBlockHandleException ( err );
61         }
62 
63         return 0;
64     }
65 
get_read_groups(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err)66     NGS_ReadGroup_v1 * CC ReadCollectionItf :: get_read_groups ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err )
67     {
68         const ReadCollectionItf * self = Self ( iself );
69         try
70         {
71             ReadGroupItf * val = self -> getReadGroups ();
72             return val -> Cast ();
73         }
74         catch ( ... )
75         {
76             ErrBlockHandleException ( err );
77         }
78 
79         return 0;
80     }
81 
get_read_group(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,const char * spec)82     NGS_ReadGroup_v1 * CC ReadCollectionItf :: get_read_group ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
83             const char * spec )
84     {
85         const ReadCollectionItf * self = Self ( iself );
86         try
87         {
88             ReadGroupItf * val = self -> getReadGroup ( spec );
89             return val -> Cast ();
90         }
91         catch ( ... )
92         {
93             ErrBlockHandleException ( err );
94         }
95 
96         return 0;
97     }
98 
get_references(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err)99     NGS_Reference_v1 * CC ReadCollectionItf :: get_references ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err )
100     {
101         const ReadCollectionItf * self = Self ( iself );
102         try
103         {
104             ReferenceItf * val = self -> getReferences ();
105             return val -> Cast ();
106         }
107         catch ( ... )
108         {
109             ErrBlockHandleException ( err );
110         }
111 
112         return 0;
113     }
114 
get_reference(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,const char * spec)115     NGS_Reference_v1 * CC ReadCollectionItf :: get_reference ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
116             const char * spec )
117     {
118         const ReadCollectionItf * self = Self ( iself );
119         try
120         {
121             ReferenceItf * val = self -> getReference ( spec );
122             return val -> Cast ();
123         }
124         catch ( ... )
125         {
126             ErrBlockHandleException ( err );
127         }
128 
129         return 0;
130     }
131 
get_alignment(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,const char * alignmentId)132     NGS_Alignment_v1 * CC ReadCollectionItf :: get_alignment ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
133             const char * alignmentId )
134     {
135         const ReadCollectionItf * self = Self ( iself );
136         try
137         {
138             AlignmentItf * val = self -> getAlignment ( alignmentId );
139             return val -> Cast ();
140         }
141         catch ( ... )
142         {
143             ErrBlockHandleException ( err );
144         }
145 
146         return 0;
147     }
148 
get_alignments(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,bool wants_primary,bool wants_secondary)149     NGS_Alignment_v1 * CC ReadCollectionItf :: get_alignments ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
150             bool wants_primary, bool wants_secondary )
151     {
152         const ReadCollectionItf * self = Self ( iself );
153         try
154         {
155             AlignmentItf * val = self -> getAlignments ( wants_primary, wants_secondary );
156             return val -> Cast ();
157         }
158         catch ( ... )
159         {
160             ErrBlockHandleException ( err );
161         }
162 
163         return 0;
164     }
165 
get_align_count(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,bool wants_primary,bool wants_secondary)166     uint64_t CC ReadCollectionItf :: get_align_count ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
167             bool wants_primary, bool wants_secondary )
168     {
169         const ReadCollectionItf * self = Self ( iself );
170         try
171         {
172             return self -> getAlignmentCount ( wants_primary, wants_secondary );
173         }
174         catch ( ... )
175         {
176             ErrBlockHandleException ( err );
177         }
178 
179         return 0;
180     }
181 
get_align_range(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,uint64_t first,uint64_t count,bool wants_primary,bool wants_secondary)182     NGS_Alignment_v1 * CC ReadCollectionItf :: get_align_range ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
183             uint64_t first, uint64_t count, bool wants_primary, bool wants_secondary )
184     {
185         const ReadCollectionItf * self = Self ( iself );
186         try
187         {
188             AlignmentItf * val = self -> getAlignmentRange ( first, count, wants_primary, wants_secondary );
189             return val -> Cast ();
190         }
191         catch ( ... )
192         {
193             ErrBlockHandleException ( err );
194         }
195 
196         return 0;
197     }
198 
get_read(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,const char * readId)199     NGS_Read_v1 * CC ReadCollectionItf :: get_read ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
200             const char * readId )
201     {
202         const ReadCollectionItf * self = Self ( iself );
203         try
204         {
205             ReadItf * val = self -> getRead ( readId );
206             return val -> Cast ();
207         }
208         catch ( ... )
209         {
210             ErrBlockHandleException ( err );
211         }
212 
213         return 0;
214     }
215 
get_reads(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,bool wants_full,bool wants_partial,bool wants_unaligned)216     NGS_Read_v1 * CC ReadCollectionItf :: get_reads ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
217             bool wants_full, bool wants_partial, bool wants_unaligned )
218     {
219         const ReadCollectionItf * self = Self ( iself );
220         try
221         {
222             ReadItf * val = self -> getReads ( wants_full, wants_partial, wants_unaligned );
223             return val -> Cast ();
224         }
225         catch ( ... )
226         {
227             ErrBlockHandleException ( err );
228         }
229 
230         return 0;
231     }
232 
get_read_count(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,bool wants_full,bool wants_partial,bool wants_unaligned)233     uint64_t CC ReadCollectionItf :: get_read_count ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
234             bool wants_full, bool wants_partial, bool wants_unaligned )
235     {
236         const ReadCollectionItf * self = Self ( iself );
237         try
238         {
239             return self -> getReadCount ( wants_full, wants_partial, wants_unaligned );
240         }
241         catch ( ... )
242         {
243             ErrBlockHandleException ( err );
244         }
245 
246         return 0;
247     }
248 
get_read_range(const NGS_ReadCollection_v1 * iself,NGS_ErrBlock_v1 * err,uint64_t first,uint64_t count,bool wants_full,bool wants_partial,bool wants_unaligned)249     NGS_Read_v1 * CC ReadCollectionItf :: get_read_range ( const NGS_ReadCollection_v1 * iself, NGS_ErrBlock_v1 * err,
250             uint64_t first, uint64_t count, bool wants_full, bool wants_partial, bool wants_unaligned )
251     {
252         const ReadCollectionItf * self = Self ( iself );
253         try
254         {
255             ReadItf * val = self -> getReadRange ( first, count, wants_full, wants_partial, wants_unaligned );
256             return val -> Cast ();
257         }
258         catch ( ... )
259         {
260             ErrBlockHandleException ( err );
261         }
262 
263         return 0;
264     }
265 
266     NGS_ReadCollection_v1_vt ReadCollectionItf :: ivt =
267     {
268         {
269             "ngs_adapt::ReadCollectionItf",
270             "NGS_ReadCollection_v1",
271             0,
272             & OpaqueRefcount :: ivt . dad
273         },
274 
275         get_name,
276         get_read_groups,
277         get_read_group,
278         get_references,
279         get_reference,
280         get_alignment,
281         get_alignments,
282         get_align_count,
283         get_align_range,
284         get_read,
285         get_reads,
286         get_read_count,
287         get_read_range
288     };
289 
290 } // namespace ngs_adapt
291