Debian Codegraph @

atac-driver/gapShifter/testAtac.C

raw symbols SCIP
1 // This file is part of A2Amapper.cxx . . $ `<file>/atac-driver/gapShifter/testAtac.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 // Reads a set of atac matches, computes the percent identity of the
27 // regions, and warns if any identites are low.
28
29 void
30 usagecxx . . $ usage(fda57c8427c60377).(char *name) {
31 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-d identity] [-i identity] -m matches\n", name);
32 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -i print a warning if a match is below this percent identity\n");
33 }
34
35 int
36 maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) {
37 char *matchesFile = 0L;
38 double identityLimit = 0.9;
39
40 int arg=1;
41 while (arg < argc) {
42 if (strcmp(argv[arg], "-m") == 0) {
43 matchesFile = argv[++arg];
44 } else if (strcmp(argv[arg], "-i") == 0) {
45 identityLimit = atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg]);
46 if (identityLimit > 1.0)
47 identityLimit /= 100;
48 } else {
49 usagecxx . . $ usage(fda57c8427c60377).(argv[0]);
50 exitcxx . . $ exit(44ed87f96534fad7).(1);
51 }
52 arg++;
53 }
54
55 if (matchesFile == 0L)
56 usagecxx . . $ usage(fda57c8427c60377).(argv[0]), exitcxx . . $ exit(44ed87f96534fad7).(1);
57
58 atacFilecxx . . $ atacFile# AFcxx . . $ atacFile#atacFile(85c52e162fed56f9).(matchesFile);
59 atacMatchListcxx . . $ atacMatchList# &ML = *AF.matchescxx . . $ atacFile#matches(33e88ebc28d05bce).();
60 seqCachecxx . . $ seqCache# Acachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(AF.assemblyFileAcxx . . $ atacFileBase#assemblyFileA(41208ce6ca65dd58).(), 0, false);
61 seqCachecxx . . $ seqCache# Bcachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(AF.assemblyFileBcxx . . $ atacFileBase#assemblyFileB(41208ce6ca65dd58).(), 0, false);
62
63 Acache.loadAllSequencescxx . . $ seqCache#loadAllSequences(49f6e7a06ebc5aa8).();
64 Bcache.loadAllSequencescxx . . $ seqCache#loadAllSequences(49f6e7a06ebc5aa8).();
65
66 for (uint32cxx . . $ uint32# i=0; i<ML.numMatchescxx . . $ atacMatchList#numMatches(db52760e79bf9054).(); i++) {
67 atacMatchcxx . . $ atacMatch# *m = ML.getMatchcxx . . $ atacMatchList#getMatch(4b949e4d42dbfd78).(i);
68
69 uint32cxx . . $ uint32# identities = 0;
70
71 char *a = Acache.getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(m->iid1cxx . . $ atacMatch#iid1.)->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).() + m->pos1cxx . . $ atacMatch#pos1.;
72 char *b = Bcache.getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(m->iid2cxx . . $ atacMatch#iid2.)->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).() + m->pos2cxx . . $ atacMatch#pos2.;
73
74 if (m->fwd2cxx . . $ atacMatch#fwd2.) {
75 for (uint32cxx . . $ uint32# p=0; p<m->len1cxx . . $ atacMatch#len1.; p++) {
76 if (toUpper[(int)a[p]] == toUpper[(int)b[p]])
77 identities++;
78 }
79 } else {
80 for (uint32cxx . . $ uint32# p=0, q=m->len2cxx . . $ atacMatch#len2.-1; p<m->len1cxx . . $ atacMatch#len1.; p++, q--) {
81 if (toUpper[(int)a[p]] == toUpper[complementSymbol[(int)b[q]]])
82 identities++;
83 }
84 }
85
86 double myIdentity = (double)identities / m->len1cxx . . $ atacMatch#len1.;
87
88 if (myIdentity < identityLimit) {
89 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "match "uint32FMTcxx . . $ `libutil/util.h:65:10`!" is only %6.2f%% identity: ",
90 i, 100.0 * identities / m->len1cxx . . $ atacMatch#len1.);
91 m->printcxx . . $ atacMatch#print(f61d327ebbdda89f).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, AF.labelAcxx . . $ atacFileBase#labelA(41208ce6ca65dd58).(), AF.labelBcxx . . $ atacFileBase#labelB(41208ce6ca65dd58).());
92 if (m->len1cxx . . $ atacMatch#len1. < 200) {
93 char tmp[1000];
94
95 strncpy(tmp, a, m->len1cxx . . $ atacMatch#len1.);
96 tmp[m->len1cxx . . $ atacMatch#len1.] = 0;
97 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " %s\n", tmp);
98
99 strncpy(tmp, b, m->len1cxx . . $ atacMatch#len1.);
100 tmp[m->len1cxx . . $ atacMatch#len1.] = 0;
101 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " %s\n", tmp);
102 }
103 }
104 }
105
106 return(0);
107 }