Commit 2b773114 authored by Matthias Schroeder's avatar Matthias Schroeder

Commandline args added

parent b8d8021d
......@@ -19,8 +19,9 @@ typedef struct {
int rgroup;
} MOLS;
MOLS* mols;
int lastmols = 0;
int hom_ch2 = 1,
int lastmols = 0,
DO_DEBUG = 0;
int hom_ch2 = 0,
hom_o = 0,
hom_h2 = 0,
hom_co2 = 0,
......@@ -58,11 +59,13 @@ void read_homsearch_csv(char* fname) {
// printf("<%s>", line);
line_count += 1;
}
printf("linecount=%d\n", line_count);
fprintf(stderr, "linecount=%d\n", line_count);
mols = (MOLS *)malloc(line_count * sizeof(MOLS));
rewind(infh);
buf[0]= '\0'; bufcnt = 0;
fgets(line, LINE_SIZE, infh);
if (!fgets(line, LINE_SIZE, infh)) {
exit(9);
}
for (char* c = line; *c; c++) {
if (*c==',' || *c=='\n') {
buf[bufcnt++] = '\0';
......@@ -164,11 +167,13 @@ void do_homsearch() {
int homgroup;
for (int idx=0; idx<lastmols; idx++) {
agroup = mols[idx].rgroup;
if (mols[idx].group == 0) {
newhomgroup += 1;
mols[idx].group = newhomgroup;
}
homgroup = mols[idx].group;
for (int bidx=idx+1; bidx<lastmols && mols[bidx].rgroup == agroup; bidx++) {
// CH2
if (homcheck(&(mols[idx]), &(mols[bidx]))) {
......@@ -179,13 +184,40 @@ void do_homsearch() {
}
}
}
}
}
void main(int argc, char* *argv) {
char homfilename[128];
if (argc>1) {
strcpy(homfilename, argv[1]);
char c;
while ((c = getopt (argc, argv, "hd12345")) != -1) {
switch (c) {
case 'd':
DO_DEBUG = 1;
break;
case '1':
hom_ch2 = 1;
break;
case '2':
hom_o = 1;
break;
case '3':
hom_h2 = 1;
break;
case '4':
hom_co2 = 1;
break;
case '5':
hom_h2o = 1;
break;
}
}
fprintf(stderr, "DO Ch2 %d, O %d, H2 %d, Co2 %d, h2o %d\n", hom_ch2, hom_o, hom_h2, hom_co2, hom_h2o);
if (optind < argc) {
strcpy(homfilename, argv[optind]);
} else {
strcpy(homfilename, "homsearch.csv");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment