Debian Codegraph @

atac-driver/gapShifter/extractSequence.C

raw symbols SCIP
1 // This file is part of A2Amapper.cxx . . $ `<file>/atac-driver/gapShifter/extractSequence.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 "atac.H"cxx . . $ `<file>/atac-driver/libatac/atac.H`/
24 #include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/
25 #include "seqCache.H"cxx . . $ `<file>/libseq/seqCache.H`/
26
27 // Reads a set of matches and outputs sequence that was mapped. Filters matches, etc.
28
29 void
30 extractAcxx . . $ extractA(24653bb9f46a2332).(seqCachecxx . . $ seqCache# *A, seqCachecxx . . $ seqCache# *B,
31 FILE *Aoutput, FILE *Boutput,
32 uint32cxx . . $ uint32# Aiid,
33 uint32cxx . . $ uint32# Biid,
34 atacMatchListcxx . . $ atacMatchList# &ML) {
35
36 }
37
38
39 void
40 usagecxx . . $ usage(fda57c8427c60377).(char *name) {
41 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-OP output.fasta] [-t trfile] -m matches\n", name);
42 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " OP\n");
43 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -a extract all unmapped sequence in A\n");
44 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -b extract all unmapped sequence in B\n");
45 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -ar extract within run unmapped sequence in A\n");
46 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -br extract within run unmapped sequence in B\n");
47 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " BOTH -ar and -br need to be specified!\n");
48 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
49 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -t mask out tandem repeats listed in trfile\n");
50 }
51
52 FILE *
53 openOutputFilecxx . . $ openOutputFile(102d3a3004848b86).(char *name) {
54 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
55 FILE *R = fopen(name, "w");
56 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)
57 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Failed to open '%s': %s\n", name, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)), exitcxx . . $ exit(44ed87f96534fad7).(1);
58 return(R);
59 }
60
61 int
62 maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) {
63 char *matchesFile = 0L;
64 FILE *Aoutput = 0L;
65 FILE *Boutput = 0L;
66 uint32cxx . . $ uint32# Aiid = ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!;
67 uint32cxx . . $ uint32# Biid = ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!;
68
69 int arg=1;
70 while (arg < argc) {
71 if (strcmp(argv[arg], "-m") == 0) {
72 matchesFile = argv[++arg];
73 } else if (strcmp(argv[arg], "-a") == 0) {
74 Aoutput = openOutputFilecxx . . $ openOutputFile(102d3a3004848b86).(argv[++arg]);
75 } else if (strcmp(argv[arg], "-b") == 0) {
76 Boutput = openOutputFilecxx . . $ openOutputFile(102d3a3004848b86).(argv[++arg]);
77
78 } else if (strcmp(argv[arg], "-1") == 0) {
79 Aiid = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
80 } else if (strcmp(argv[arg], "-2") == 0) {
81 Biid = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
82 } else {
83 usagecxx . . $ usage(fda57c8427c60377).(argv[0]);
84 exitcxx . . $ exit(44ed87f96534fad7).(1);
85 }
86 arg++;
87 }
88
89 if (matchesFile == 0L)
90 usagecxx . . $ usage(fda57c8427c60377).(argv[0]), exitcxx . . $ exit(44ed87f96534fad7).(1);
91
92 atacFilecxx . . $ atacFile# AFcxx . . $ atacFile#atacFile(85c52e162fed56f9).(matchesFile);
93 atacMatchListcxx . . $ atacMatchList# &ML = *AF.matchescxx . . $ atacFile#matches(33e88ebc28d05bce).();
94
95 seqCachecxx . . $ seqCache# *A = new seqCachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(AF.assemblyFileAcxx . . $ atacFileBase#assemblyFileA(41208ce6ca65dd58).(), 0, true);
96 seqCachecxx . . $ seqCache# *B = new seqCachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(AF.assemblyFileBcxx . . $ atacFileBase#assemblyFileB(41208ce6ca65dd58).(), 0, true);
97
98 A->loadAllSequencescxx . . $ seqCache#loadAllSequences(49f6e7a06ebc5aa8).();
99 B->loadAllSequencescxx . . $ seqCache#loadAllSequences(49f6e7a06ebc5aa8).();
100
101 for (uint32cxx . . $ uint32# x=0; x<ML.numMatchescxx . . $ atacMatchList#numMatches(db52760e79bf9054).(); x++) {
102 atacMatchcxx . . $ atacMatch# *m = ML[cxx . . $ atacMatchList#`operator[]`(4b949e4d42dbfd78).x];
103
104 if (((Aiid == ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!) || (Aiid == m->iid1cxx . . $ atacMatch#iid1.)) &&
105 ((Biid == ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!) || (Biid == m->iid2cxx . . $ atacMatch#iid2.))) {
106
107 if (Aoutput) {
108 seqInCorecxx . . $ seqInCore# *S = A->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(m->iid1cxx . . $ atacMatch#iid1.);
109
110 fprintf(Aoutput, "%s extracted from iid "uint32FMTcxx . . $ `libutil/util.h:65:10`!" pos "uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!" match %s(%s)\n",
111 S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(), S->getIIDcxx . . $ seqInCore#getIID(ddd8539a2fcdd4ce).(),
112 m->pos1cxx . . $ atacMatch#pos1., m->pos1cxx . . $ atacMatch#pos1. + m->len1cxx . . $ atacMatch#len1.,
113 m->matchuidcxx . . $ atacMatch#matchuid., m->parentuidcxx . . $ atacMatch#parentuid.);
114 fwrite(S->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).() + m->pos1cxx . . $ atacMatch#pos1., sizeof(char), m->len1cxx . . $ atacMatch#len1., Aoutput);
115 fprintf(Aoutput, "\n");
116 }
117
118 if (Boutput) {
119 seqInCorecxx . . $ seqInCore# *S = B->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(m->iid2cxx . . $ atacMatch#iid2.);
120
121 fprintf(Boutput, "%s extracted from iid "uint32FMTcxx . . $ `libutil/util.h:65:10`!" pos "uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!" match %s(%s)\n",
122 S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(), S->getIIDcxx . . $ seqInCore#getIID(ddd8539a2fcdd4ce).(),
123 m->pos2cxx . . $ atacMatch#pos2., m->pos2cxx . . $ atacMatch#pos2. + m->len2cxx . . $ atacMatch#len2.,
124 m->matchuidcxx . . $ atacMatch#matchuid., m->parentuidcxx . . $ atacMatch#parentuid.);
125 fwrite(S->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).() + m->pos2cxx . . $ atacMatch#pos2., sizeof(char), m->len2cxx . . $ atacMatch#len2., Boutput);
126 fprintf(Boutput, "\n");
127 }
128 }
129 }
130
131 if (Aoutput) fclose(Aoutput);
132 if (Boutput) fclose(Boutput);
133
134 return(0);
135 }