-
Notifications
You must be signed in to change notification settings - Fork 7
/
GeneAssigner.cpp
125 lines (105 loc) · 2.29 KB
/
GeneAssigner.cpp
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
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
#include <vector>
char usage[] = "./gene-assigner [OPTIONS]:\n"
"Required:\n"
"\t-f STRING: fasta file containing the reference genome sequence\n"
"\t[Read file]\n"
"\t-u STRING: path to single-end read file\n"
"\t-1 STRING -2 STRING: path to paired-end files\n" ;
char nucToNum[26] = { 0, -1, 1, -1, -1, -1, 2,
-1, -1, -1, -1, -1, -1, 0,
-1, -1, -1, -1, -1, 3,
-1, -1, -1, -1, -1, -1 } ;
char numToNuc[4] = {'A', 'C', 'G', 'T'} ;
static const char *short_options = "f:u:1:2:o:t:" ;
int main(int argc, char *argv[])
{
int i, j, k ;
int c, option_index = 0 ;
if ( argc <= 1 )
{
fprintf( stderr, "%s", usage ) ;
return 0 ;
}
SeqSet refSet(9) ;
char outputPrefix[1024] = "kir" ;
ReadFiles reads ;
ReadFiles mateReads ;
bool hasMate = false ;
std::vector<struct _Read> read1 ;
std::vector<struct _Read> read2 ;
while (1)
{
c = getopt_long( argc, argv, short_options, long_options, &option_index ) ;
if ( c == -1 )
break ;
if ( c == 'f' )
{
//seqSet.InputRefFa( optarg ) ;
refSet.InputRefFa( optarg ) ;
}
else if ( c == 'u' )
{
reads.AddReadFile( optarg, false ) ;
}
else if ( c == '1' )
{
reads.AddReadFile( optarg, true ) ;
hasMate = true ;
}
else if ( c == '2' )
{
mateReads.AddReadFile( optarg, true ) ;
hasMate = true ;
}
else if ( c == 'o' )
{
strcpy( outputPrefix, optarg ) ;
}
else if ( c == 't' )
{
threadCnt = atoi( optarg ) ;
}
else
{
fprintf( stderr, "%s", usage ) ;
return EXIT_FAILURE ;
}
}
if ( refSet.Size() == 0 )
{
fprintf( stderr, "Need to use -f to specify the receptor genome sequence.\n" );
return EXIT_FAILURE;
}
i = 0;
while (reads.Next())
{
struct _Read nr ;
struct _Read mateR ;
nr.read = strdup(reads.seq) ;
nr.id = strdup(reads.id) ;
if (reads.qual != NULL)
nr.qual = strdup(reads.qual);
else
nr.qual = NULL;
reads1.push_back(nr);
if (hasMate)
{
mateR.read = strdup(mateReads.seq);
mateR.id = strdup(mateReads.id);
mateR.barcode = barcode;
mateR.umi = umi;
if (mateReads.qual != NULL)
mateR.qual = strdup( mateReads.qual );
else
mateR.qual = NULL;
read2.push_back(mateR);
}
++i;
}
return 0;