File: proteinindexcons.c

package info (click to toggle)
wise 2.4.1-21
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 27,140 kB
  • sloc: ansic: 276,365; makefile: 1,003; perl: 886; lex: 93; yacc: 81; sh: 24
file content (209 lines) | stat: -rw-r--r-- 6,095 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#ifdef _cplusplus
extern "C" {
#endif
#include "proteinindexcons.h"

/* Function:  new_SeqLookupInterface_from_ProteinIndexConstructor(pic)
 *
 * Descrip:    Makes a new SeqLookupInterface from ProteinIndexConstructor
 *
 *
 * Arg:        pic [UNKN ] Undocumented argument [ProteinIndexConstructor *]
 *
 * Return [UNKN ]  Undocumented return value [SeqLookupInterface *]
 *
 */
# line 34 "proteinindexcons.dy"
SeqLookupInterface * new_SeqLookupInterface_from_ProteinIndexConstructor(ProteinIndexConstructor * pic)
{
  switch(pic->type) {

    case ProteinIndexConstructor_Array  :
    return new_ArraySeq_SeqLookupInterface(SEQLOOKUP_5AA_SIZE,1000);
    
    case  ProteinIndexConstructor_Hash :
    return new_ghash_SeqLookupInterface();
    
    case ProteinIndexConstructor_Stream : 
    return new_ProteinStreamedIndex_SeqLookupInterface(pic->waypost);
    
    case ProteinIndexConstructor_Shadow :
    return new_ShadowSequenceIndex_SeqLookupInterface(pic->shadowlength,pic->has_maxlen,pic->max_seqlen,pic->shadow_error);
    
    default:
    fatal("Cannot process type %d as protein index constructor",pic->type);
  }
  return NULL;
}

/* Function:  show_help_ProteinIndexConstructor(ofp)
 *
 * Descrip:    provides help for protein index constructor
 *
 *
 * Arg:        ofp [UNKN ] Undocumented argument [FILE *]
 *
 */
# line 59 "proteinindexcons.dy"
void show_help_ProteinIndexConstructor(FILE * ofp)
{
  fprintf(ofp,"Protein Index construction options\n");
  fprintf(ofp,"   -pitype [array/hash/stream/shadow] - default array\n");
  fprintf(ofp,"   -piwaypost [number]  - waypost for streamed cases, default 3\n");
  fprintf(ofp,"   -pishadow [number]   - shadow length for shadow cases, default 15\n");
  fprintf(ofp,"   -pishadow_err [number] - errors per 100 identities tolerated, 3\n");
  fprintf(ofp,"   -piseqmax            - indexes can assumme maximum length of seq\n");
  fprintf(ofp,"   -piseqmax_len [number] - assummed max sequnce length, default 1000\n"); 

  return;
}


/* Function:  new_ProteinIndexConstructor_from_argv(argc,argv)
 *
 * Descrip:    Provides a ProteinIndexConstructor argument from argv
 *
 *
 * Arg:        argc [UNKN ] Undocumented argument [int *]
 * Arg:        argv [UNKN ] Undocumented argument [char **]
 *
 * Return [UNKN ]  Undocumented return value [ProteinIndexConstructor *]
 *
 */
# line 76 "proteinindexcons.dy"
ProteinIndexConstructor * new_ProteinIndexConstructor_from_argv(int * argc,char ** argv)
{
  ProteinIndexConstructor * out;
  char * temp;

  out = ProteinIndexConstructor_alloc();

  temp = strip_out_assigned_argument(argc,argv,"pitype");
  if( temp != NULL ) {
    if( strcmp(temp,"array") == 0 ) {
      out->type = ProteinIndexConstructor_Array;
    } else if ( strcmp(temp,"hash") == 0 ) {
      out->type = ProteinIndexConstructor_Hash;
    } else if ( strcmp(temp,"stream") == 0 ) {
      out->type = ProteinIndexConstructor_Stream;
    } else if ( strcmp(temp,"shadow") == 0 ) {
      out->type = ProteinIndexConstructor_Shadow;
    } else {
      fatal("Could not interpret %s as a protein index type",temp);
    }
  }

  strip_out_integer_argument(argc,argv,"piwaypost",&out->waypost);
  strip_out_integer_argument(argc,argv,"pishadow",&out->shadowlength);

  strip_out_boolean_def_argument(argc,argv,"piseqmax",&out->waypost);
  strip_out_integer_argument(argc,argv,"piseqmax_len",&out->shadowlength);


  return out;

}

# line 100 "proteinindexcons.c"
/* Function:  hard_link_ProteinIndexConstructor(obj)
 *
 * Descrip:    Bumps up the reference count of the object
 *             Meaning that multiple pointers can 'own' it
 *
 *
 * Arg:        obj [UNKN ] Object to be hard linked [ProteinIndexConstructor *]
 *
 * Return [UNKN ]  Undocumented return value [ProteinIndexConstructor *]
 *
 */
ProteinIndexConstructor * hard_link_ProteinIndexConstructor(ProteinIndexConstructor * obj) 
{
    if( obj == NULL )    {  
      warn("Trying to hard link to a ProteinIndexConstructor object: passed a NULL object"); 
      return NULL;   
      }  
    obj->dynamite_hard_link++;   
    return obj;  
}    


/* Function:  ProteinIndexConstructor_alloc(void)
 *
 * Descrip:    Allocates structure: assigns defaults if given 
 *
 *
 *
 * Return [UNKN ]  Undocumented return value [ProteinIndexConstructor *]
 *
 */
ProteinIndexConstructor * ProteinIndexConstructor_alloc(void) 
{
    ProteinIndexConstructor * out;  /* out is exported at end of function */ 


    /* call ckalloc and see if NULL */ 
    if((out=(ProteinIndexConstructor *) ckalloc (sizeof(ProteinIndexConstructor))) == NULL)  {  
      warn("ProteinIndexConstructor_alloc failed "); 
      return NULL;  /* calling function should respond! */ 
      }  
    out->dynamite_hard_link = 1; 
#ifdef PTHREAD   
    pthread_mutex_init(&(out->dynamite_mutex),NULL);     
#endif   
    out->type = ProteinIndexConstructor_Array;   
    out->waypost = 3;    
    out->shadowlength = 15;  
    out->has_maxlen = 0; 
    out->max_seqlen = 1000;  
    out->shadow_error = 3;   


    return out;  
}    


/* Function:  free_ProteinIndexConstructor(obj)
 *
 * Descrip:    Free Function: removes the memory held by obj
 *             Will chain up to owned members and clear all lists
 *
 *
 * Arg:        obj [UNKN ] Object that is free'd [ProteinIndexConstructor *]
 *
 * Return [UNKN ]  Undocumented return value [ProteinIndexConstructor *]
 *
 */
ProteinIndexConstructor * free_ProteinIndexConstructor(ProteinIndexConstructor * obj) 
{
    int return_early = 0;    


    if( obj == NULL) {  
      warn("Attempting to free a NULL pointer to a ProteinIndexConstructor obj. Should be trappable");   
      return NULL;   
      }  


#ifdef PTHREAD   
    assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); 
#endif   
    if( obj->dynamite_hard_link > 1)     {  
      return_early = 1;  
      obj->dynamite_hard_link--; 
      }  
#ifdef PTHREAD   
    assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);   
#endif   
    if( return_early == 1)   
      return NULL;   


    ckfree(obj); 
    return NULL; 
}    



#ifdef _cplusplus
}
#endif