1 /* $Id: stsutil.h,v 6.0 1997/08/25 18:54:52 madden Exp $ 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government have not placed any restriction on its use or reproduction. 13 * 14 * Although all reasonable efforts have been taken to ensure the accuracy 15 * and reliability of the software and data, the NLM and the U.S. 16 * Government do not and cannot warrant the performance or results that 17 * may be obtained by using this software or data. The NLM and the U.S. 18 * Government disclaim all warranties, express or implied, including 19 * warranties of performance, merchantability or fitness for any particular 20 * purpose. 21 * 22 * Please cite the author in any work or product based on this material. 23 * 24 * =========================================================================== 25 * 26 * File Name: $RCSfile: stsutil.h,v $ 27 * 28 * Author: Sergei Shavirin 29 * 30 * Version Creation Date: 12/18/1996 31 * 32 * $Revision: 6.0 $ 33 * 34 * File Description: Header file for NCBI STS Search Tool utilities 35 * 36 * $Log: stsutil.h,v $ 37 * Revision 6.0 1997/08/25 18:54:52 madden 38 * Revision changed to 6.0 39 * 40 * Revision 1.2 1997/05/23 15:23:22 shavirin 41 * STS library on this step was made independent from little/big 42 * endian and memory mapping 43 * 44 * Revision 1.1 1996/12/18 20:53:38 shavirin 45 * Initial revision 46 * 47 * 48 * ========================================================================== 49 */ 50 51 #ifndef _STSUTILH_ 52 #define _STSUTILH_ stsutil 53 54 /****************************************************************************/ 55 /* DEFINES & TYPEDEFS */ 56 /****************************************************************************/ 57 58 typedef struct StsResult { 59 Int4 id_sts; /* STS database reference ID number */ 60 Int4 gi; /* GI currently is not available */ 61 CharPtr acc; /* GenBank Accession number */ 62 Int4 pos; /* Start position of STS in query sequence */ 63 CharPtr sts_name; /* STS name from STS database */ 64 Int4 real_len; /* Amplicon length detected in search */ 65 Int4 exp_len; /* Amplicon length, that was expected */ 66 CharPtr org; /* Organism STS belong to */ 67 CharPtr chrom; /* Chromosom ( may be few ) */ 68 CharPtr pr1; /* First STS primer */ 69 CharPtr pr2; /* Second STS primer */ 70 CharPtr sequence; /* Piece of query sequence containing STS */ 71 Int4 start; /* Start of STS in returned piece */ 72 struct StsResult *next; /* Pointer to the next Result structure */ 73 } StsResult, PNTR StsResultPtr; 74 75 typedef struct STSOrg { 76 Int4 id; /* Organism id number (used only in this search) */ 77 Int4 num; /* Number of entries in STS dump file */ 78 CharPtr string; /* Organism name as a string */ 79 } STSOrg, PNTR STSOrgPtr; 80 81 typedef struct STSDbNames { 82 CharPtr sts_db_name; /* Override default STS database name */ 83 CharPtr sts_map_name; /* Override default STS map file name */ 84 CharPtr sts_org_name; /* Override default STS organism list name */ 85 } STSDbNames, PNTR STSDbNamesPtr; 86 87 typedef struct STSData { 88 CharPtr sts_db_name; /* STS database filename */ 89 CharPtr sts_org_name; /* Organism index name */ 90 CharPtr sts_map_name; /* Formatted STS search file */ 91 Int4 margin; 92 CharPtr MMAddress; /* address of MM hash file */ 93 Nlm_MemMapPtr mmp; /* Memory mapping pointer */ 94 STSOrgPtr PNTR OrgTable; /* Pointer to organism table */ 95 FILE *fd_stsdb; /* File with STS db information */ 96 } STSData, PNTR STSDataPtr; 97 98 #define MAXORGNUM 50 /* Maximum number of organisms to be initialized */ 99 100 /****************************************************************************/ 101 /* FINCTION DEFINITIONS */ 102 /****************************************************************************/ 103 104 #ifdef __cplusplus 105 extern "C" { 106 #endif 107 108 /* ------------------------- STSSearch --------------------------- 109 Purpose: To search given string in IUPACna encoding for 110 STS primer pairs. 111 112 Parameters: query - Input IUPACna string 113 organism - index of organism in STS search database 114 0 will search all organisms 115 result - returned STSResult structure of found STS 116 if result == NULL no hits found 117 Returns: FALSE returned in case of fatal error 118 NOTE: First check for returned TRUE if search was correct 119 then check if result not == NULL. Result is linked list, 120 so few entries may be returned at once. 121 ------------------------------------------------------------------*/ 122 Boolean STSSearch(CharPtr query, 123 Int4 organism, 124 StsResultPtr PNTR result 125 ); 126 Boolean STSSearch_r(STSDataPtr sts_data, 127 CharPtr query, Int4 organism, 128 StsResultPtr PNTR result_out); 129 130 /* ----------------------- InitSTSSearch -------------------------- 131 Purpose: All main structures, tables and memory mappings 132 will be initiated. To override default filenames of 133 main STS Search files use non-NULL parameter 134 Parameters: Structure, that contains filenames of 3 main files 135 used in search - override default names. 136 Returns: Number of STS in initialised database of -1 if 137 error. 138 NOTE: Default filenames will be set to centralized place 139 accessible via NFS. To speed up initialization 140 reccommended to copy these files on local computer 141 and initialise "db_name" structure. 142 ------------------------------------------------------------------*/ 143 Int4 InitSTSSearch(STSDbNamesPtr db_names); 144 Int4 InitSTSSearch_r(STSDbNamesPtr db_name, STSDataPtr PNTR data_out); 145 146 /* ----------------------- FiniSTSSearch ------------------------- 147 Purpose: Terminate memory mapping, deallocate structures and 148 close opened files. 149 Parameters: None 150 Returns: FALSE if error, TRUE mean success 151 NOTE: 152 ------------------------------------------------------------------*/ 153 Boolean FiniSTSSearch(void); 154 155 156 /* ----------------------- STSGetOrgTable ------------------------- 157 Purpose: To return pointer to OrgTable used in STS Search 158 if It was not yet initialised filename will be used 159 to initialize it NULL initialize default filename 160 161 Parameters: none 162 163 Returns: Pointer to global Orgtable (non-reentrant) 164 ------------------------------------------------------------------*/ 165 STSOrgPtr PNTR STSGetOrgTable(void); 166 167 168 /* ---------------------- STSGetOrganismIndex --------------------- 169 Purpose: To return organism index by organism name 170 Parameters: Organism name 171 Returns: Index in OrgTable 172 NOTE: OrgTable will be initialized with default filename 173 if it was not done before 174 ------------------------------------------------------------------*/ 175 Int4 STSGetOrganismIndex(STSDataPtr sts_data, CharPtr name); 176 177 178 /* ---------------------- STSGetOrganismName ---------------------- 179 Purpose: To return Organism name by index 180 Parameters: Inderx in STS Search OrgTable 181 Returns: Pointer to organism name 182 NOTE: OrgTable will be initialized with default filename 183 if it was not done before 184 ------------------------------------------------------------------*/ 185 CharPtr STSGetOrganismName(STSDataPtr sts_data, Int4 id); 186 187 /* ------------------------- STSResultNew ------------------------- 188 Purpose: To allocate space for Result structure 189 Parameters: None 190 Returns: Pointer to allocated STSResult structure 191 NOTE: 192 ------------------------------------------------------------------*/ 193 StsResultPtr StsResultNew(void); 194 195 196 /* ------------------------- STSResultFree ------------------------ 197 Purpose: To deallocate result structure 198 Parameters: STSResult structure 199 Returns: None 200 NOTE: 201 ------------------------------------------------------------------*/ 202 void StsResultFree(StsResultPtr result); 203 void STSDataFree(STSDataPtr sts_data); 204 205 206 #ifdef __cplusplus 207 } 208 #endif 209 210 211 #endif 212