| 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 | #include <vdb/extern.h>cxx . . $ `<file>/interfaces/vdb/extern.h`/ |
| 27 | |
| 28 | #include <sra/sradb.h>cxx . . $ `<file>/interfaces/sra/sradb.h`/ |
| 29 | #include <vdb/xform.h>cxx . . $ `<file>/interfaces/vdb/xform.h`/ |
| 30 | #include <klib/data-buffer.h>cxx . . $ `<file>/interfaces/klib/data-buffer.h`/ |
| 31 | #include <klib/text.h>cxx . . $ `<file>/interfaces/klib/text.h`/ |
| 32 | #include <klib/rc.h>cxx . . $ `<file>/interfaces/klib/rc.h`/ |
| 33 | #include "name-tokenizer.h"cxx . . $ `<file>/libs/sraxf/name-tokenizer.h`/ |
| 34 | #include <sysalloc.h>cxx . . $ `<file>/interfaces/os/unix/sysalloc.h`/ |
| 35 | |
| 36 | #include <stdlib.h> |
| 37 | #include <stdio.h> |
| 38 | #include <string.h> |
| 39 | #include <ctype.h> |
| 40 | #include <assert.h> |
| 41 | |
| 42 | |
| 43 | /* extract_spot_name |
| 44 | * generates input to .SPOT_NAME column |
| 45 | * |
| 46 | * on NCBI:SRA:name_token:unrecognized, produces the entire spot name row |
| 47 | * otherwise, produces an empty row |
| 48 | * |
| 49 | * "name" [ DATA ] - raw spot names from NAME column |
| 50 | * |
| 51 | * "tok" [ DATA ] - delimiting tokens produced by sub-table |
| 52 | function ascii |
| 53 | NCBI:SRA:extract_spot_name #1 ( ascii name, NCBI:SRA:spot_name_token tok ); |
| 54 | */ |
| 55 | |
| 56 | #define NAMcxx . . $ `libs/sraxf/extract-spot_name.c:56:9`! 0 |
| 57 | #define TOKcxx . . $ `libs/sraxf/extract-spot_name.c:57:9`! 1 |
| 58 | |
| 59 | static |
| 60 | rc_tcxx . . $ rc_t# CCcxx . . $ `interfaces/kfc/callconv.h:44:11`! extract_spot_namecxx . . $ extract_spot_name(c7f02ef3aabbc98b). ( void *self, const VXformInfocxx . . $ VXformInfo# *info, int64_tcxx . . $ int64_t# row_id, |
| 61 | VRowResultcxx . . $ VRowResult# *rslt, uint32_tcxx . . $ uint32_t# argc, const VRowDatacxx . . $ VRowData# argv [] ) |
| 62 | { |
| 63 | uint32_tcxx . . $ uint32_t# i; |
| 64 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! name_copy; |
| 65 | |
| 66 | const spot_name_token_tcxx . . $ spot_name_token_t# *token = argv [ TOKcxx . . $ `libs/sraxf/extract-spot_name.c:57:9`! ] . ucxx . . $ VRowData#u. . datacxx . . $ VRowData#$anonymous_type_1#data. . basecxx . . $ VRowData#$anonymous_type_1#$anonymous_type_2#base.; |
| 67 | uint64_tcxx . . $ uint64_t# num_tokens = argv [ TOKcxx . . $ `libs/sraxf/extract-spot_name.c:57:9`! ] . ucxx . . $ VRowData#u. . datacxx . . $ VRowData#$anonymous_type_1#data. . elem_countcxx . . $ VRowData#$anonymous_type_1#$anonymous_type_2#elem_count.; |
| 68 | token += argv [ TOKcxx . . $ `libs/sraxf/extract-spot_name.c:57:9`! ] . ucxx . . $ VRowData#u. . datacxx . . $ VRowData#$anonymous_type_1#data. . first_elemcxx . . $ VRowData#$anonymous_type_1#$anonymous_type_2#first_elem.; |
| 69 | |
| 70 | for ( name_copy = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, i = 0; i < num_tokens; ++ i ) |
| 71 | { |
| 72 | if ( token [ i ] . scxx . . $ spot_name_token_t#s. . token_typecxx . . $ spot_name_token_t#$anonymous_type_0#token_type. == nt_unrecognizedcxx . . $ nt_unrecognized. ) |
| 73 | { |
| 74 | name_copy = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 75 | break; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | rslt -> elem_countcxx . . $ VRowResult#elem_count. = 0; |
| 80 | rslt -> datacxx . . $ VRowResult#data. -> elem_bitscxx . . $ KDataBuffer#elem_bits. = 8; |
| 81 | |
| 82 | if ( name_copy || num_tokens == 0 ) |
| 83 | { |
| 84 | const char *name = argv [ NAMcxx . . $ `libs/sraxf/extract-spot_name.c:56:9`! ] . ucxx . . $ VRowData#u. . datacxx . . $ VRowData#$anonymous_type_1#data. . basecxx . . $ VRowData#$anonymous_type_1#$anonymous_type_2#base.; |
| 85 | uint64_tcxx . . $ uint64_t# name_len = argv [ NAMcxx . . $ `libs/sraxf/extract-spot_name.c:56:9`! ] . ucxx . . $ VRowData#u. . datacxx . . $ VRowData#$anonymous_type_1#data. . elem_countcxx . . $ VRowData#$anonymous_type_1#$anonymous_type_2#elem_count.; |
| 86 | |
| 87 | rc_tcxx . . $ rc_t# rc = KDataBufferResizecxx . . $ KDataBufferResize(daabdf243431d3e4). ( rslt -> datacxx . . $ VRowResult#data., name_len ); |
| 88 | if ( rc != 0 ) |
| 89 | return rc; |
| 90 | |
| 91 | memmovecxx . . $ memmove(cc817cb175f282d). ( rslt -> datacxx . . $ VRowResult#data. -> basecxx . . $ KDataBuffer#base., name += argv [ NAMcxx . . $ `libs/sraxf/extract-spot_name.c:56:9`! ] . ucxx . . $ VRowData#u. . datacxx . . $ VRowData#$anonymous_type_1#data. . first_elemcxx . . $ VRowData#$anonymous_type_1#$anonymous_type_2#first_elem., name_len ); |
| 92 | rslt -> elem_countcxx . . $ VRowResult#elem_count. = name_len; |
| 93 | } |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | VTRANSFACT_IMPLcxx . . $ `interfaces/vdb/xform.h:791:9`! ( NCBI_SRA_extract_spot_name, 1, 0, 0 ) ( const void *self, |
| 99 | const VXfactInfocxx . . $ VXfactInfo# *info, VFuncDesccxx . . $ VFuncDesc# *rslt, const VFactoryParamscxx . . $ VFactoryParams# *cp, const VFunctionParamscxx . . $ VFunctionParams# *dp ) |
| 100 | { |
| 101 | rslt->variantcxx . . $ VFuncDesc#variant. = vftRowcxx . . $ vftRow.; |
| 102 | rslt->ucxx . . $ VFuncDesc#u..rfcxx . . $ VFuncDesc#$anonymous_type_7#rf. = extract_spot_namecxx . . $ extract_spot_name(c7f02ef3aabbc98b).; |
| 103 | |
| 104 | return 0; |
| 105 | } |