コード例 #1
0
int main(int argc, char *argv[])
{
struct lineFile *cgf, *clf, *mkf, *nmf, *acf, *usf;
FILE *bacAlias, *bacXRef; 
int verb = 0;
char *dir, errorFile[256], aliasFile[256], xRefFile[256];

verboseSetLevel(0);
optionInit(&argc, argv, optionSpecs);
if (argc != 8)
    {
fprintf(stdout, "USAGE: formatZfishSts [-verbose=<level>] <contig file> <clone file> <marker file> <list of BACs and chroms> <accessions> <UniSTS IDs file><output directory>\n");
    return 1;
    }
verb = optionInt("verbose", 0);
verboseSetLevel(verb);

fprintf(stdout, "Opening and reading files ...\n");
cgf = lineFileOpen(argv[1], TRUE );
clf = lineFileOpen(argv[2], TRUE);
mkf = lineFileOpen(argv[3], TRUE);
nmf = lineFileOpen(argv[4], TRUE);
acf = lineFileOpen(argv[5], TRUE);
usf = lineFileOpen(argv[6], TRUE);
dir = cloneString(argv[7]); 

sprintf(errorFile, "%s/error.log", dir);
sprintf(aliasFile, "%s/bacAlias.tab", dir);
sprintf(xRefFile, "%s/bacXRef.tab", dir);

fprintf(stdout, "files are error: %s, alias: %s and xRef: %s \n", errorFile, aliasFile, xRefFile);
stderr = mustOpen(errorFile, "w");
bacAlias = mustOpen(aliasFile, "w");
bacXRef = mustOpen(xRefFile, "w");

/* Read in contigs file with internal name, external name and FPC contig */
verbose(1, "Reading contig names file\n");
readContigs(cgf);

/* Read in internal BAC clone names and Sanger sts names  */
verbose(1, "Reading BAC clone names and Sanger sts names\n");
readCloneNames(clf);

/* Read in BAC clone information: Sanger name, UniSTS ID and aliases */
verbose(1, "Reading markers file\n");
readMarkers(mkf);

/* Read in file of BAC clones names and chroms mapped to by blat */
verbose(1, "Reading file of BAC clone external names\n");
readBacNames(nmf);

/* Read in internal names and corresponding GenBank accessions */
verbose(1, "Reading accessions file\n");
readAccessions(acf);

/*Read file of UniSTS IDs and BAC Clone IDs */
verbose(1, "Reading UniSTS IDs file\n");
readUniStsIds(usf);

/* Print out the STS marker information to a file */
verbose(1, "Creating output file\n");
fprintf(stdout, "Printing tab files for bacCloneAlias and bacCloneXRef tables ...\n");
writeAliasTable(bacAlias);
writeXRefTable(bacXRef);

lineFileClose(&nmf);
lineFileClose(&cgf);
lineFileClose(&clf);
lineFileClose(&mkf);
lineFileClose(&acf);
lineFileClose(&usf);
carefulClose(&bacXRef);
carefulClose(&bacAlias);
carefulClose(&stderr);

freeHashAndVals(&bacHash);
freeHashAndVals(&extNameHash);
freeHashAndVals(&aliasHash);
freeHashAndVals(&sangerByExtNameHash);

return(0);
}
コード例 #2
0
ファイル: gencnval.c プロジェクト: Cyril2004/proto-quic
extern int
main(int argc, char* argv[]) {
    int i, n;
    char pathBuf[512];
    FileStream *in;
    UNewDataMemory *out;
    UErrorCode errorCode=U_ZERO_ERROR;

    U_MAIN_INIT_ARGS(argc, argv);

    /* preset then read command line options */
    options[DESTDIR].value=options[SOURCEDIR].value=u_getDataDirectory();
    argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);

    /* error handling, printing usage message */
    if(argc<0) {
        fprintf(stderr,
            "error in command line argument \"%s\"\n",
            argv[-argc]);
    }
    if(argc<0 || options[HELP1].doesOccur || options[HELP2].doesOccur) {
        fprintf(stderr,
            "usage: %s [-options] [convrtrs.txt]\n"
            "\tread convrtrs.txt and create " U_ICUDATA_NAME "_" DATA_NAME "." DATA_TYPE "\n"
            "options:\n"
            "\t-h or -? or --help  this usage text\n"
            "\t-v or --verbose     prints out extra information about the alias table\n"
            "\t-q or --quiet       do not display warnings and progress\n"
            "\t-c or --copyright   include a copyright notice\n"
            "\t-d or --destdir     destination directory, followed by the path\n"
            "\t-s or --sourcedir   source directory, followed by the path\n",
            argv[0]);
        return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
    }

    if(options[VERBOSE].doesOccur) {
        verbose = TRUE;
    }

    if(options[QUIET].doesOccur) {
        quiet = TRUE;
    }

    if(argc>=2) {
        path=argv[1];
    } else {
        path=options[SOURCEDIR].value;
        if(path!=NULL && *path!=0) {
            char *end;

            uprv_strcpy(pathBuf, path);
            end = uprv_strchr(pathBuf, 0);
            if(*(end-1)!=U_FILE_SEP_CHAR) {
                *(end++)=U_FILE_SEP_CHAR;
            }
            uprv_strcpy(end, "convrtrs.txt");
            path=pathBuf;
        } else {
            path = "convrtrs.txt";
        }
    }

    uprv_memset(stringStore, 0, sizeof(stringStore));
    uprv_memset(tagStore, 0, sizeof(tagStore));
    uprv_memset(converters, 0, sizeof(converters));
    uprv_memset(tags, 0, sizeof(tags));
    uprv_memset(aliasLists, 0, sizeof(aliasLists));
    uprv_memset(knownAliases, 0, sizeof(aliasLists));


    in=T_FileStream_open(path, "r");
    if(in==NULL) {
        fprintf(stderr, "gencnval: unable to open input file %s\n", path);
        exit(U_FILE_ACCESS_ERROR);
    }
    parseFile(in);
    T_FileStream_close(in);

    /* create the output file */
    out=udata_create(options[DESTDIR].value, DATA_TYPE, DATA_NAME, &dataInfo,
                     options[COPYRIGHT].doesOccur ? U_COPYRIGHT_STRING : NULL, &errorCode);
    if(U_FAILURE(errorCode)) {
        fprintf(stderr, "gencnval: unable to open output file - error %s\n", u_errorName(errorCode));
        exit(errorCode);
    }

    /* write the table of aliases based on a tag/converter name combination */
    writeAliasTable(out);

    /* finish */
    udata_finish(out, &errorCode);
    if(U_FAILURE(errorCode)) {
        fprintf(stderr, "gencnval: error finishing output file - %s\n", u_errorName(errorCode));
        exit(errorCode);
    }

    /* clean up tags */
    for (i = 0; i < MAX_TAG_COUNT; i++) {
        for (n = 0; n < MAX_CONV_COUNT; n++) {
            if (tags[i].aliasList[n].aliases!=NULL) {
                uprv_free(tags[i].aliasList[n].aliases);
            }
        }
    }

    return 0;
}