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_pl_zmw_
27 #define _h_pl_zmw_
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include "pl-tools.h"
34 #include "pl-progress.h"
35 #include "pl-regions.h"
36 #include <kapp/main.h>
37 #include <klib/rc.h>
38 
39 typedef struct zmw_tab
40 {
41     af_data HoleNumber;
42     af_data HoleStatus;
43     af_data HoleXY;
44     af_data NumEvent;
45     af_data NumPasses;
46 } zmw_tab;
47 
48 
49 #define ZMW_BLOCK_SIZE 8192
50 
51 typedef struct zmw_block
52 {
53     uint32_t NumEvent[ ZMW_BLOCK_SIZE ];
54     uint32_t HoleNumber[ ZMW_BLOCK_SIZE ];
55     uint8_t  HoleStatus[ ZMW_BLOCK_SIZE ];
56     uint16_t HoleXY[ ZMW_BLOCK_SIZE * 2 ];
57     uint32_t NumPasses[ ZMW_BLOCK_SIZE ];
58     uint64_t n_read;
59 } zmw_block;
60 
61 
62 typedef struct zmw_row
63 {
64     uint64_t offset;
65     uint64_t spot_nr;
66 
67     uint32_t NumEvent;
68     uint32_t HoleNumber;
69     uint16_t HoleXY[ 2 ];
70     uint8_t  HoleStatus;
71     uint32_t NumPasses;
72 } zmw_row;
73 
74 
75 typedef rc_t (*zmw_on_row)( VCursor *cursor, const uint32_t *col_idx,
76                             region_type_mapping *mapping,
77                             zmw_row *row, void * data );
78 
79 
80 void zmw_init( zmw_tab *tab );
81 void zmw_close( zmw_tab *tab );
82 
83 rc_t zmw_open( const KDirectory *hdf5_dir, zmw_tab *tab,
84                const bool num_passes, const char * path, bool supress_err_msg );
85 
86 uint64_t zmw_total( zmw_tab *tab );
87 
88 rc_t zmw_read_block( zmw_tab *tab, zmw_block * block,
89                      const uint64_t total_spots,
90                      const uint64_t pos,
91                      const bool with_num_passes );
92 
93 void zmw_block_row( zmw_block * block, zmw_row * row,
94                     const uint32_t idx );
95 
96 
97 rc_t zmw_for_each( zmw_tab *tab, const KLoadProgressbar ** xml_progress, VCursor * cursor,
98                    bool with_progress, const uint32_t *col_idx, region_type_mapping *mapping,
99                    const bool with_num_passes, zmw_on_row on_row, void * data );
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif
106