Commit af4a6565 authored by Vesa Oikonen's avatar Vesa Oikonen
Browse files

added option to keep units or not to keep

parent b151be57
......@@ -43,6 +43,8 @@ static char *info[] = {
" -hdr=<Yes|no>",
" Extra information is (y, default) or is not stored (n) in lines",
" starting with '#' character; not effective with all formats.",
" -units=<Yes|no>",
" Keep (y, default) or remove (n) parameter units.",
" -stdoptions", // List standard options like --help, -v, etc
" ",
"Example: convert RES file into CSV format for exporting to Excel",
......@@ -75,6 +77,7 @@ int main(int argc, char **argv)
int ret;
int new_format=PAR_FORMAT_UNKNOWN;
int save_header=1;
int keep_units=1;
char *cptr, parfile1[FILENAME_MAX], parfile2[FILENAME_MAX];
PAR par;
......@@ -103,6 +106,10 @@ int main(int argc, char **argv)
cptr+=7;
if(strncasecmp(cptr, "YES", 1)==0) {save_header=1; continue;}
else if(strncasecmp(cptr, "NO", 1)==0) {save_header=0; continue;}
} else if(strncasecmp(cptr, "UNITS=", 6)==0) {
cptr+=6;
if(strncasecmp(cptr, "YES", 1)==0) {keep_units=1; continue;}
else if(strncasecmp(cptr, "NO", 1)==0) {keep_units=0; continue;}
}
fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
return(1);
......@@ -132,6 +139,7 @@ int main(int argc, char **argv)
if(verbose>1) {
printf("new_format := %s\n", parFormattxt(new_format));
printf("save_header := %d\n", save_header);
printf("keep_units := %d\n", keep_units);
printf("parfile1 := %s\n", parfile1);
if(parfile2[0]) printf("parfile2 := %s\n", parfile2);
}
......@@ -158,7 +166,12 @@ int main(int argc, char **argv)
return 0;
}
/* If output filename was not given by user, then make it here */
/* Remove units, if user does not want to keep those */
if(keep_units==0) {
for(int i=0; i<par.parNr; i++) par.n[i].unit=UNIT_UNKNOWN;
}
/* If output file name was not given by user, then make it here */
if(!parfile2[0]) {
strcpy(parfile2, parfile1);
filenameRmPath(parfile2); filenameRmExtension(parfile2);
......
#!/bin/bash
#: Title : test_parformat
#: Date : 2018-04-28
#: Date : 2020-06-19
#: Author : "Vesa Oikonen" <vesa.oikonen@utu.fi>
#: Options : None
......@@ -28,9 +28,15 @@ printf "creating test data for %s\n" $PROGRAM
printf "=====================================================================\n"
printf "\n verifying that required data exists \n"
if [ ! -f patlak.csv ]; then
printf "Parameters,Ki[mL/(mL*min)],Ic[mL/mL],r[unitless]\n" > patlak.csv
printf "LN_1,0.025626,0.1161,0.9965\n" >> patlak.csv
printf "LN_2,0.023099,0.1466,0.9991\n" >> patlak.csv
fi
printf "\n verifying that required data exists \n"
if [ ! -f mrglu.res ] || [ ! -f mrglu_csvint.csv ]; then
printf "Failed: required data does not exist.\n"
exit 1
......@@ -118,7 +124,7 @@ printf "\n passed. \n\n"
printf "\n 0.3.1 \n"
printf " Test case 1: Enter new format and filename. \n"
printf " Test case 1: Enter new format and file name. \n"
printf " Test case 2: Option to not save headers. \n"
printf " Expected result 1: Test print shows correct option setting. \n"
printf " Expected result 2: Output file is in intended file format. \n\n"
......@@ -396,7 +402,7 @@ iftmatch mrglu_csvuk.csv output.csv
if [ $? -eq 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n passed. \n\n"
printf "\n===================================================================\n"
printf "\n 1.3.0 \n"
printf " Test case: CSV-UK to XML.\n"
......@@ -410,6 +416,37 @@ if [ ! -f output.xml ]; then printf "Failed!\n" ; exit 1 ; fi
printf "\n passed. \n\n"
printf "\n===================================================================\n"
printf "\n 1.4.0 \n"
printf " Test case: Plain CSV-UK to CSV-UK without units.\n"
printf " Expected result: file saved without units. \n"
rm -f output.csv
$PROGRAM -f=CSV-UK -units=n patlak.csv output.csv
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n ok \n"
$PARMATCH -parunits=n -tacnames=y -sd=y -cl=y -wss=y -abs=1E-6 -rel=0.1 patlak.csv output.csv
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n ok \n"
$PARMATCH -parunits=y patlak.csv output.csv
if [ $? -eq 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n passed. \n\n"
printf "\n 1.4.1 \n"
printf " Test case: Plain CSV-UK to CSV-UK with units.\n"
printf " Expected result: file saved with units. \n"
rm -f output.csv
$PROGRAM -f=CSV-UK -units=y patlak.csv output.csv
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n ok \n"
$PARMATCH -parunits=y -tacnames=y -sd=y -cl=y -wss=y -abs=1E-6 -rel=0.1 patlak.csv output.csv
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n passed. \n\n"
printf "\n===================================================================\n"
printf " Old result format \n"
printf "===================================================================\n"
......
Supports Markdown
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