| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| |
| 5 |
|
| # include "src/Datatype.h" |
| 6 |
|
| # include "src/Writable.h" |
| 7 |
|
| # include "src/types.h" |
| 8 |
|
| |
| 9 |
0 |
| Datatype* create(const char * classname) { |
| 10 |
|
| Datatype *self; |
| 11 |
0 |
| Newx(self,1,Datatype); |
| 12 |
0 |
| initialize_datatype(self); |
| 13 |
0 |
| return self; |
| 14 |
|
| } |
| 15 |
|
| |
| 16 |
0 |
| void initialize_datatype(Datatype* self){ |
| 17 |
0 |
| initialize_writable((Writable*)self); |
| 18 |
0 |
| self->missing = '?'; |
| 19 |
0 |
| self->gap = '-'; |
| 20 |
0 |
| self->datatype = 0; |
| 21 |
0 |
| ((Identifiable*)self)->_type = _DATATYPE_; |
| 22 |
0 |
| ((Identifiable*)self)->_container = _NONE_; |
| 23 |
0 |
| ((Identifiable*)self)->_index = _DATATYPE_IDX_; |
| 24 |
0 |
| } |
| 25 |
|
| |
| 26 |
0 |
| Datatype* set_type(Datatype* self, char* type) { |
| 27 |
0 |
▶ | if ( tolower(type[0]) == 'd' ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( tolower(type[0]) == 'd' ) { |
0 |
0 |
0 |
|
| 28 |
0 |
| self->datatype = _DNA_; |
| 29 |
|
| } |
| 30 |
0 |
▶ | else if ( tolower(type[0]) == 'r' ) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( tolower(type[0]) == 'r' ) { |
0 |
0 |
0 |
|
| 31 |
0 |
| self->datatype = _RNA_; |
| 32 |
|
| } |
| 33 |
0 |
▶ | else if ( tolower(type[0]) == 'p' ) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( tolower(type[0]) == 'p' ) { |
0 |
0 |
0 |
|
| 34 |
0 |
| self->datatype = _PROTEIN_; |
| 35 |
|
| } |
| 36 |
0 |
▶ | else if ( tolower(type[0]) == 's' ) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( tolower(type[0]) == 's' ) { |
0 |
0 |
0 |
|
| 37 |
0 |
| self->datatype = _STANDARD_; |
| 38 |
|
| } |
| 39 |
0 |
▶ | else if ( tolower(type[0]) == 'c' ) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( tolower(type[0]) == 'c' ) { |
0 |
0 |
0 |
|
| 40 |
0 |
| self->datatype = _CONTINUOUS_; |
| 41 |
|
| } |
| 42 |
|
| else { |
| 43 |
0 |
| warn("Unsupported data type"); |
| 44 |
|
| } |
| 45 |
0 |
| return self; |
| 46 |
|
| } |
| 47 |
|
| |
| 48 |
0 |
| void _to_set_type(Datatype* self, char* type) { |
| 49 |
0 |
| set_type(self,type); |
| 50 |
0 |
| } |
| 51 |
|
| |
| 52 |
0 |
| char* get_type(Datatype* self) { |
| 53 |
|
| char* retval; |
| 54 |
0 |
| switch(self->datatype) { |
| 55 |
0 |
| case _DNA_: |
| 56 |
0 |
| retval = "dna"; |
| 57 |
0 |
| break; |
| 58 |
0 |
| case _RNA_: |
| 59 |
0 |
| retval = "rna"; |
| 60 |
0 |
| break; |
| 61 |
0 |
| case _PROTEIN_: |
| 62 |
0 |
| retval = "protein"; |
| 63 |
0 |
| break; |
| 64 |
0 |
| case _STANDARD_: |
| 65 |
0 |
| retval = "protein"; |
| 66 |
0 |
| break; |
| 67 |
0 |
| case _CONTINUOUS_: |
| 68 |
0 |
| retval = "continuous"; |
| 69 |
0 |
| break; |
| 70 |
0 |
| default: |
| 71 |
0 |
| warn("Datatype undefined"); |
| 72 |
0 |
| break; |
| 73 |
|
| } |
| 74 |
0 |
| return retval; |
| 75 |
|
| } |
| 76 |
|
| |
| 77 |
0 |
| char* _to_get_type(Datatype* self) { |
| 78 |
0 |
| return get_type(self); |
| 79 |
|
| } |
| 80 |
|
| |
| 81 |
0 |
| char get_missing(Datatype* self) { |
| 82 |
0 |
| return self->missing; |
| 83 |
|
| } |
| 84 |
|
| |
| 85 |
0 |
| Datatype* set_missing(Datatype* self, char missing) { |
| 86 |
0 |
| self->missing = missing; |
| 87 |
0 |
| return self; |
| 88 |
|
| } |
| 89 |
|
| |
| 90 |
0 |
| char get_gap(Datatype* self) { |
| 91 |
0 |
| return self->gap; |
| 92 |
|
| } |
| 93 |
|
| |
| 94 |
0 |
| Datatype* set_gap(Datatype* self, char gap) { |
| 95 |
0 |
| self->gap = gap; |
| 96 |
0 |
| return self; |
| 97 |
|
| } |
| 98 |
|
| |
| 99 |
0 |
| void destroy_datatype(Datatype* self) { |
| 100 |
0 |
| destroy_writable((Writable*)self); |
| 101 |
|
| //Safefree(self); |
| 102 |
0 |
| } |
| 103 |
|
| MODULE = Bio::PhyloXS::Matrices::Datatype PACKAGE = Bio::PhyloXS::Matrices::Datatype |
| 104 |
|
| |
| 105 |
|
| PROTOTYPES: DISABLE |
| 106 |
|
| |
| 107 |
|
| |
| 108 |
|
| Datatype * |
| 109 |
|
| create (classname) |
| 110 |
|
| const char * classname |
| 111 |
|
| |
| 112 |
|
| void |
| 113 |
|
| initialize_datatype (self) |
| 114 |
|
| Datatype * self |
| 115 |
|
| PREINIT: |
| 116 |
|
| I32* temp; |
| 117 |
|
| PPCODE: |
| 118 |
0 |
| temp = PL_markstack_ptr++; |
| 119 |
0 |
| initialize_datatype(self); |
| 120 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 121 |
|
| /* truly void, because dXSARGS not invoked */ |
| 122 |
0 |
| PL_markstack_ptr = temp; |
| 123 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 124 |
|
| } |
| 125 |
|
| /* must have used dXSARGS; list context implied */ |
| 126 |
0 |
| return; /* assume stack size is correct */ |
| 127 |
|
| |
| 128 |
|
| Datatype * |
| 129 |
|
| set_type (self, type) |
| 130 |
|
| Datatype * self |
| 131 |
|
| char * type |
| 132 |
|
| |
| 133 |
|
| void |
| 134 |
|
| _to_set_type (self, type) |
| 135 |
|
| Datatype * self |
| 136 |
|
| char * type |
| 137 |
|
| PREINIT: |
| 138 |
|
| I32* temp; |
| 139 |
|
| PPCODE: |
| 140 |
0 |
| temp = PL_markstack_ptr++; |
| 141 |
0 |
| _to_set_type(self, type); |
| 142 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 143 |
|
| /* truly void, because dXSARGS not invoked */ |
| 144 |
0 |
| PL_markstack_ptr = temp; |
| 145 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 146 |
|
| } |
| 147 |
|
| /* must have used dXSARGS; list context implied */ |
| 148 |
0 |
| return; /* assume stack size is correct */ |
| 149 |
|
| |
| 150 |
|
| char * |
| 151 |
|
| get_type (self) |
| 152 |
|
| Datatype * self |
| 153 |
|
| |
| 154 |
|
| char * |
| 155 |
|
| _to_get_type (self) |
| 156 |
|
| Datatype * self |
| 157 |
|
| |
| 158 |
|
| char |
| 159 |
|
| get_missing (self) |
| 160 |
|
| Datatype * self |
| 161 |
|
| |
| 162 |
|
| Datatype * |
| 163 |
|
| set_missing (self, missing) |
| 164 |
|
| Datatype * self |
| 165 |
|
| char missing |
| 166 |
|
| |
| 167 |
|
| char |
| 168 |
|
| get_gap (self) |
| 169 |
|
| Datatype * self |
| 170 |
|
| |
| 171 |
|
| Datatype * |
| 172 |
|
| set_gap (self, gap) |
| 173 |
|
| Datatype * self |
| 174 |
|
| char gap |
| 175 |
|
| |
| 176 |
|
| void |
| 177 |
|
| destroy_datatype (self) |
| 178 |
|
| Datatype * self |
| 179 |
|
| PREINIT: |
| 180 |
|
| I32* temp; |
| 181 |
|
| PPCODE: |
| 182 |
0 |
| temp = PL_markstack_ptr++; |
| 183 |
0 |
| destroy_datatype(self); |
| 184 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 185 |
|
| /* truly void, because dXSARGS not invoked */ |
| 186 |
0 |
| PL_markstack_ptr = temp; |
| 187 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 188 |
|
| } |
| 189 |
|
| /* must have used dXSARGS; list context implied */ |
| 190 |
0 |
| return; /* assume stack size is correct */ |
| 191 |
|
| |