Debian Codegraph @

atac-driver/libatac/atacFeatureList.C

raw symbols SCIP
1 // This file is part of A2Amapper.cxx . . $ `<file>/atac-driver/libatac/atacFeatureList.C`/
2 // Copyright (c) 2006 J. Craig Venter Institute
3 // Author: Brian Walenz
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received (LICENSE.txt) a copy of the GNU General Public
16 // License along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <unistd.h>
22
23 #include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/
24 #include "atac.H"cxx . . $ `<file>/atac-driver/libatac/atac.H`/
25
26
27 atacFeatureListcxx . . $ atacFeatureList#::atacFeatureListcxx . . $ atacFeatureList#atacFeatureList(49f6e7a06ebc5aa8).() {
28 _featuresLencxx . . $ atacFeatureList#_featuresLen. = 0;
29 _featuresMaxcxx . . $ atacFeatureList#_featuresMax. = 256;
30 _featurescxx . . $ atacFeatureList#_features. = new atacFeaturecxx . . $ atacFeature# [_featuresMaxcxx . . $ atacFeatureList#_featuresMax.];
31 }
32
33 atacFeatureListcxx . . $ atacFeatureList#::~cxx . . $ atacFeatureList#`~atacFeatureList`(ced63f7c635d850d).atacFeatureListcxx . . $ atacFeatureList#() {
34 delete [] _featurescxx . . $ atacFeatureList#_features.;
35 }
36
37 void
38 atacFeatureListcxx . . $ atacFeatureList#::addcxx . . $ atacFeatureList#add(1b9a787d410f56d0).(atacFeaturecxx . . $ atacFeature# &m) {
39
40 if (_featuresLencxx . . $ atacFeatureList#_featuresLen. >= _featuresMaxcxx . . $ atacFeatureList#_featuresMax.) {
41 _featuresMaxcxx . . $ atacFeatureList#_featuresMax. <<= 2;
42 atacFeaturecxx . . $ atacFeature# *A = new atacFeaturecxx . . $ atacFeature# [_featuresMaxcxx . . $ atacFeatureList#_featuresMax.];
43 memcpy(A, _featurescxx . . $ atacFeatureList#_features., sizeof(atacFeaturecxx . . $ atacFeature#) * _featuresLencxx . . $ atacFeatureList#_featuresLen.);
44 delete [] _featurescxx . . $ atacFeatureList#_features.;
45 _featurescxx . . $ atacFeatureList#_features. = A;
46 }
47
48 memcpy(&_featurescxx . . $ atacFeatureList#_features.[_featuresLencxx . . $ atacFeatureList#_featuresLen.], &m, sizeof(atacFeaturecxx . . $ atacFeature#));
49
50 _featurescxx . . $ atacFeatureList#_features.[_featuresLencxx . . $ atacFeatureList#_featuresLen.].featureiidcxx . . $ atacFeature#featureiid. = _featuresLencxx . . $ atacFeatureList#_featuresLen.++;
51 }
52
53
54
55 static
56 int
57 sort_cxx . . $ sort_(9148c8c3ff42c9d8).(const void *a, const void *b) {
58 const atacFeaturecxx . . $ atacFeature# *A = (const atacFeaturecxx . . $ atacFeature# *)a;
59 const atacFeaturecxx . . $ atacFeature# *B = (const atacFeaturecxx . . $ atacFeature# *)b;
60
61 if (A->iidcxx . . $ atacFeature#iid. < B->iidcxx . . $ atacFeature#iid.) return(-1);
62 if (A->iidcxx . . $ atacFeature#iid. > B->iidcxx . . $ atacFeature#iid.) return(1);
63 if (A->poscxx . . $ atacFeature#pos. < B->poscxx . . $ atacFeature#pos.) return(-1);
64 if (A->poscxx . . $ atacFeature#pos. > B->poscxx . . $ atacFeature#pos.) return(1);
65 if (A->lencxx . . $ atacFeature#len. > B->lencxx . . $ atacFeature#len.) return(-1);
66 if (A->lencxx . . $ atacFeature#len. < B->lencxx . . $ atacFeature#len.) return(1);
67 return(0);
68 }
69
70 static
71 int
72 sortfeatureuid_cxx . . $ sortfeatureuid_(9148c8c3ff42c9d8).(const void *a, const void *b) {
73 const atacFeaturecxx . . $ atacFeature# *A = (const atacFeaturecxx . . $ atacFeature# *)a;
74 const atacFeaturecxx . . $ atacFeature# *B = (const atacFeaturecxx . . $ atacFeature# *)b;
75
76 int r = strcmp(A->featureuidcxx . . $ atacFeature#featureuid., B->featureuidcxx . . $ atacFeature#featureuid.);
77 if (r < 0) return(-1);
78 if (r > 0) return(1);
79 r = strcmp(A->parentuidcxx . . $ atacFeature#parentuid., B->parentuidcxx . . $ atacFeature#parentuid.);
80 if (r < 0) return(-1);
81 if (r > 0) return(1);
82
83 return(0);
84 }
85
86 static
87 int
88 sortparentuid_cxx . . $ sortparentuid_(9148c8c3ff42c9d8).(const void *a, const void *b) {
89 const atacFeaturecxx . . $ atacFeature# *A = (const atacFeaturecxx . . $ atacFeature# *)a;
90 const atacFeaturecxx . . $ atacFeature# *B = (const atacFeaturecxx . . $ atacFeature# *)b;
91
92 int r = strcmp(A->parentuidcxx . . $ atacFeature#parentuid., B->parentuidcxx . . $ atacFeature#parentuid.);
93 if (r < 0) return(-1);
94 if (r > 0) return(1);
95 r = strcmp(A->featureuidcxx . . $ atacFeature#featureuid., B->featureuidcxx . . $ atacFeature#featureuid.);
96 if (r < 0) return(-1);
97 if (r > 0) return(1);
98
99 return(0);
100 }
101
102
103 void
104 atacFeatureListcxx . . $ atacFeatureList#::sortcxx . . $ atacFeatureList#sort(b4d55b1286ff73e8).(uint32cxx . . $ uint32# first, uint32cxx . . $ uint32# len) {
105 if (len == 0) len = _featuresLencxx . . $ atacFeatureList#_featuresLen.;
106 qsortcxx . . $ qsort(ebb60b13a65e77d7).(_featurescxx . . $ atacFeatureList#_features. + first, len, sizeof(atacFeaturecxx . . $ atacFeature#), sort_cxx . . $ sort_(9148c8c3ff42c9d8).);
107 }
108
109 void
110 atacFeatureListcxx . . $ atacFeatureList#::sortFeatureUIDcxx . . $ atacFeatureList#sortFeatureUID(b4d55b1286ff73e8).(uint32cxx . . $ uint32# first, uint32cxx . . $ uint32# len) {
111 if (len == 0) len = _featuresLencxx . . $ atacFeatureList#_featuresLen.;
112 qsortcxx . . $ qsort(ebb60b13a65e77d7).(_featurescxx . . $ atacFeatureList#_features. + first, len, sizeof(atacFeaturecxx . . $ atacFeature#), sortfeatureuid_cxx . . $ sortfeatureuid_(9148c8c3ff42c9d8).);
113 }
114
115 void
116 atacFeatureListcxx . . $ atacFeatureList#::sortParentUIDcxx . . $ atacFeatureList#sortParentUID(b4d55b1286ff73e8).(uint32cxx . . $ uint32# first, uint32cxx . . $ uint32# len) {
117 if (len == 0) len = _featuresLencxx . . $ atacFeatureList#_featuresLen.;
118 qsortcxx . . $ qsort(ebb60b13a65e77d7).(_featurescxx . . $ atacFeatureList#_features. + first, len, sizeof(atacFeaturecxx . . $ atacFeature#), sortparentuid_cxx . . $ sortparentuid_(9148c8c3ff42c9d8).);
119 }