Example #1
0
void DBConnection::init()
{
	optionInit();
	//分配环境句柄
	result = SQLAllocHandle(SQL_HANDLE_ENV,NULL,&env);
	//设置环境句柄属性
	result = SQLSetEnvAttr(env,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,SQL_IS_INTEGER);
	//使用ODBC连接池,每个驱动一个SQL_CP_ONE_PER_DRIVER  或者每个环境一个SQL_CP_ONE_PER_HENV   SQL_CP_OFF关闭
	//result = SQLSetEnvAttr(env,SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER)SQL_CP_ONE_PER_HENV,SQL_IS_INTEGER);
	//分配链接句柄
	result = SQLAllocHandle(SQL_HANDLE_DBC,env,&dbc);
	 //StringLength参数,如果参数类型是整形设置为SQL_IS_INTEGER,是字符串长度或者SQL_NTS
	result = SQLSetConnectAttr(dbc,SQL_LOGIN_TIMEOUT,(void*)this->connSet.login_timeout, SQL_IS_INTEGER);
	result = SQLSetConnectAttr(dbc,SQL_ATTR_CONNECTION_TIMEOUT,(void*)this->connSet.connection_timeout, SQL_IS_INTEGER);
	result = SQLSetConnectAttr(dbc,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)this->connSet.connection_autocommt, SQL_IS_INTEGER);
    SQLSMALLINT outputlength;
	result = SQLDriverConnect(dbc,NULL,m_connStr,SQL_NTS,m_connStrOut,255,&outputlength,SQL_DRIVER_NOPROMPT);
	//result = SQLConnect(dbc,L"mysql1",SQL_NTS,L"root",SQL_NTS,L"root",SQL_NTS);
	LogUtil* log = LogUtil::getlog();
	std::wstring woutput_info = m_connStrOut;
	std::wstring& _woutput_info = woutput_info;
	std::string output_info = ws2s(_woutput_info);
	log->log(LogUtil::L_INFO,output_info.c_str(),DEBUG_TRACE_FILE_LINE_INFO);
    //result = SQLAllocHandle(SQL_HANDLE_STMT,this->dbc,&stmt);
	//result = SQLExecDirect(stmt,(SQLWCHAR*)L"select * from t1",SQL_NTS);
  
	if (SQL_ERROR == result)
	{
		showDBCError(dbc);
	}else{
		_idle = true;
	    enable = true;
	}
	


}
Example #2
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
if (argc != 3)
    usage();
encodeList = optionExists("encodeList");
tabList = optionExists("tabList");
useTarget = optionExists("useTarget");
cellLetter = optionVal("cellLetter", cellLetter);
scoreCol = optionInt("scoreCol", scoreCol);
noLetter = optionExists("noLetter");
noLetterOk = optionExists("noLetterOk");
noNormalize = optionExists("noNormalize");
if (noNormalize)
    // standard score column index added to config file
    scoreCol = 5;
else
    {
    verbose(2, "Normalizing score using column %d\n", scoreCol);
    }
regClusterBedExpCfg(argv[1], argv[2]);
return 0;
}
Example #3
0
int main( int argc, char *argv[] )
{
optionInit(&argc, argv, optionSpecs);

obsolete = optionExists("obsolete");
if (! obsolete)
    {
    verbose(1,"ERROR: This loader is obsolete.  Please use: 'wigEncode'\n");
    verbose(1,"\t(use -obsolete flag to run this encoder despite it being obsolete)\n");
    errAbort("ERROR: wigZoom is obsolete, use 'wigEncode' instead");
    }

if (argc < 2)
    usage();

dataSpan = optionLongLong("dataSpan", 1024);

verbose(2, "options: -verbose, dataSpan= %llu\n", dataSpan);
if (dataSpan < 2)
    errAbort("ERROR: data span: %llu ! must be greater than one\n");

wigZoom(argc, argv);
exit(0);
}
Example #4
0
int main(int argc, char *argv[])
/* Process command line. */
{
char *type;
optionInit(&argc, argv, optionSpecs);
if (argc < 4)
    usage();
abbr = optionVal("abbr", abbr);
suffix = optionVal("suffix", abbr);
type = argv[2];
if (sameWord(type, "ensembl"))
    ensPepPred(argv[1], argc-3, argv+3);
else if (sameWord(type, "genie"))
    geniePepPred(argv[1], argc-3, argv+3);
else if (sameWord(type, "softberry"))
    softberryPepPred(argv[1], argc-3, argv+3);
else if (sameWord(type, "generic"))
    genericPepPred(argv[1], argc-4, argv+4, argv[3]);
else if (sameWord(type, "tab"))
    tabPepPred(argv[1], argc-4, argv+4, argv[3]);
else
    usage();
return 0;
}
Example #5
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, optionSpecs);
saveId = optionExists("saveId");
inputList = optionVal("inputList",inputList);
tempDir = optionVal("tempDir",tempDir);
if ((argc < 2 && !inputList) || (argc > 1 && inputList))
    usage();
if (tempDir[0]!=0 && lastChar(tempDir) != '/')
    tempDir = addSuffix(tempDir,"/");
if (argc-1 <= MAXFILES && !inputList)
    {
    chainMergeSort(argc-1, argv+1, stdout, 0);
    }
else 
    {
    char inp0[PATH_LEN];
    safecpy(inp0, sizeof(inp0), rTempName(tempDir, "inputList0-", ".tmp"));
    if (!inputList)
	{
	FILE *f = mustOpen(inp0,"w");
	int i=0;
	for (i=1; i<argc; ++i)
	    {
	    fprintf(f, "%s\n", argv[i]);
	    }
	carefulClose(&f);
	inputList = inp0;
	}
    hierSort(inputList);
    if (sameString(inputList,inp0))
	remove(inp0);
    }
return 0;
}
Example #6
0
int main(int argc, char *argv[])
/* Process command line. */
{
pushCarefulMemHandler(500000000);
optionInit(&argc, argv, options);
if (argc != 3)
    usage();
clDb = optionVal("db", clDb);
clOrg = optionVal("org", clOrg);
clGroup = optionVal("group", clGroup);
clTrack = optionVal("track", clTrack);
clTable = optionVal("table", clTable);
clDbs = optionInt("dbs", clDbs);
clOrgs = optionInt("orgs", clOrgs);
clGroups = optionInt("groups", clGroups);
clTracks = optionInt("tracks", clTracks);
clTables = optionInt("tables", clTables);
appendLog = optionExists("appendLog");
if (clOrg != NULL)
   clOrgs = BIGNUM;
hgTablesTest(argv[1], argv[2]);
carefulCheckHeap();
return 0;
}
Example #7
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
if (argc != 4)
    usage();

char *lrgFile = argv[1];
char *chromSizes = argv[2];
char *pslFile = argv[3];

struct hash *chromHash = hChromSizeHashFromFile(chromSizes);
struct lrg *lrg, *lrgList = lrgLoadAllByTab(lrgFile);
FILE *f = mustOpen(pslFile, "w");
for (lrg = lrgList;  lrg != NULL;  lrg = lrg->next)
    {
    int chromSize = hashIntValDefault(chromHash, lrg->chrom, 0);
    if (chromSize == 0)
	errAbort("Can't find size of '%s' in chrom.sizes file %s.", lrg->chrom, chromSizes);
    struct psl *psl = lrgToPsl(lrg, chromSize);
    pslTabOut(psl, f);
    }
return 0;
}
Example #8
0
int main(int argc, char *argv[])
{
struct sqlConnection *conn, *conn3;
char query[256], query3[256];
struct sqlResult *sr, *sr3;
char **row, **row3;

FILE *o1, *o2;

char *locusID;	/* LocusLink ID */

char *kgTempDbName, *roDbName; 
char cond_str[200];
char *kgId;
char *mapID;
char *desc;
char *mRNA;

optionInit(&argc, argv, options);
if (argc != 3)  usage();
kgTempDbName    = argv[1];
roDbName 	= argv[2];

conn = hAllocConn(roDbName);
conn3= hAllocConn(roDbName);

o1 = fopen("j.dat",  "w");
o2 = fopen("jj.dat", "w");
    
table = optionVal("table", "knownGene");
sqlSafef(query, sizeof(query), "select name from %s.%s", roDbName, table);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
while (row != NULL)
    {
    kgId = row[0];
	
    sqlSafefFrag(cond_str, sizeof(cond_str), "kgId='%s'", kgId);
    mRNA = sqlGetField(roDbName, "kgXref", "mRNA", cond_str);
    
    sqlSafefFrag(cond_str, sizeof(cond_str), "mrna='%s'", mRNA);
    locusID = sqlGetField("entrez", "entrezMrna", "geneId", cond_str);
    
    /* look for RefSeq if not found in mRNAs */
    if (locusID == NULL)
    	{
    	sqlSafefFrag(cond_str, sizeof(cond_str), "refseq='%s'", mRNA);
    	locusID = sqlGetField("entrez", "entrezRefseq", "geneId", cond_str);
	}

    if (locusID != NULL)
	{
        sqlSafef(query3, sizeof(query3), "select * from %s.keggList where locusID = '%s'", kgTempDbName, locusID);
        sr3 = sqlGetResult(conn3, query3);
        while ((row3 = sqlNextRow(sr3)) != NULL)
            {
            mapID   = row3[1];
	    desc    = row3[2];
	    fprintf(o1, "%s\t%s\t%s\n", kgId, locusID, mapID);
	    fprintf(o2, "%s\t%s\n", mapID, desc);
	    row3 = sqlNextRow(sr3);
            }
        sqlFreeResult(&sr3);
	}
    else
        {
	/* printf("%s not found in Entrez.\n", kgId);fflush(stdout);*/
        if (differentString(table, "knownGene"))
            {
            sqlSafefFrag(cond_str, sizeof(cond_str), "name='%s'", kgId);
            locusID = sqlGetField(roDbName, table, "name2", cond_str);
            sqlSafef(query3, sizeof(query3), "select * from %s.keggList where locusID = '%s'", kgTempDbName, kgId);
            sr3 = sqlGetResult(conn3, query3);
            while ((row3 = sqlNextRow(sr3)) != NULL)
                {
                mapID   = row3[1];
                desc    = row3[2];
                fprintf(o1, "%s\t%s\t%s\n", kgId, locusID, mapID);
                fprintf(o2, "%s\t%s\n", mapID, desc);
                row3 = sqlNextRow(sr3);
                }
            sqlFreeResult(&sr3);
            }
        }
    row = sqlNextRow(sr);
    }

fclose(o1);
fclose(o2);
hFreeConn(&conn);

mustSystem("cat j.dat|sort|uniq >keggPathway.tab");
mustSystem("cat jj.dat|sort|uniq >keggMapDesc.tab");
mustSystem("rm j.dat");
mustSystem("rm jj.dat");
return(0);
}
int main(int argc, char *argv[])
/* Process command line. */
{
off_t estSize;
char *how = NULL;
char *inName = NULL;
int count;
char *outRoot;
int prefixLength = 0;
int extra = 0;

optionInit(&argc, argv, optionSpecs);
how = argv[1];
inName = argv[2];

if (argc < 4 )
    usage();
outDirDepth = optionInt("outDirDepth", 0);
prefixLength = optionInt("prefixLength", prefixLength);
extra = optionInt("extra", extra);

if (sameWord(how, "byname"))
    {
    if (argc != 4)
        usage();
    dnaUtilOpen();
    outRoot = argv[3];
    if (optionExists("prefixLength"))
        {
        /* no count argument.  Make as many as needed */
        splitByNamePrefix(inName, outRoot, prefixLength);
        }
    else
        {
        /* no count argument.  Make as many as needed */
        splitByName(inName, outRoot);
        }
    }
else
    {
    if (argc != 5 || !isdigit(argv[3][0]))
	usage();

    dnaUtilOpen();
    count = atoi(argv[3]);
    outRoot=argv[4];
    estSize = estimateFaSize(argv[2]);
    if (sameWord(how, "sequence"))
	splitByRecord(inName, count, outRoot, estSize);
    else if (sameWord(how, "base"))
	splitByBase(inName, count, outRoot, estSize);
    else if (sameWord(how, "size"))
	splitByCount(inName, count, outRoot, estSize, extra);
    else if (sameWord(how, "about"))
	splitAbout(inName, count, outRoot);
    else if (sameWord(how, "gap"))
	splitByGap(inName, count, outRoot, estSize);
    else
	usage();
    }
return 0;
}
Example #10
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
if (optionExists("help"))
    {
    printHelp();
    }
    
if (argc != 3) 
    {
    usage();
    }
outMdb = optionVal("outMdb", outMdb);
onlyCompTdb = optionExists("onlyCompTdb");
release = optionVal("release", release);
releaseNum = optionInt("releaseNum", releaseNum);

char *database = argv[1];
char *composite = argv[2];


char defaultMetaDb[1024];
char defaultDownloadDir[1024];
char tempDownloadDir[1024];
char *src = getSrcDir();
char *org = cloneString(hOrganism(database));
org[0] = tolower(org[0]);
/* If user doesn't provide a metaDB, assume the path using the database and composite  */
safef(defaultMetaDb, sizeof(defaultMetaDb), "%s/hg/makeDb/trackDb/%s/%s/metaDb/%s/%s.ra", src, org, database, release, composite);
/* If user doesn't provide a downloadDir, assume the path using the database and composite  */
safef(defaultDownloadDir, sizeof(defaultDownloadDir), "/usr/local/apache/htdocs-hgdownload/goldenPath/%s/encodeDCC/%s", database, composite);
safef(tempDownloadDir, sizeof(tempDownloadDir), "/usr/local/apache/htdocs-hgdownload/goldenPath/%s/encodeDCC/%s", database, composite);
if (releaseNum)
    safef(defaultDownloadDir, sizeof(defaultDownloadDir), "%s/release%d", tempDownloadDir, releaseNum);

/* If user doesn't provide a trackDB, assume the path using the database and composite  */
char defaultTrackDb[1024];
/* Load encode composite-includer trackDb.wgEncode.ra */
char trackDbIncluder[1024];
safef(trackDbIncluder, sizeof(trackDbIncluder), "%s/hg/makeDb/trackDb/%s/%s/%s", src, org, database, "trackDb.wgEncode.ra");
struct raFile *includerFile = raFileRead(trackDbIncluder);
/* Find the correct trackDb.ra for the composite */
int numTagsFound = -1;
char *compositeName = findCompositeRa(includerFile, composite, release, &numTagsFound);
if (!compositeName)
    errAbort("unable to find composite .ra for the track in trackDb.wgEncode.ra\n");
// if numTagsFound == 1 then a composite .ra with a single alpha tag exists already, 
//  so no further work required on trackDb.wgEncode.ra
safef(defaultTrackDb, sizeof(defaultTrackDb), "%s/hg/makeDb/trackDb/%s/%s/%s", src, org, database, compositeName);
    
verbose(1,"database: %s\ncomposite: %s\nrelease %s\ndefault trackDb: %s\ndefault metaDb: %s\ndefault downloadDir: %s\n",
    database, composite, release, defaultTrackDb, defaultMetaDb, defaultDownloadDir);

char *metaDb = optionVal("metaDb",defaultMetaDb);
replaceTildeWithHome(&metaDb);
if (!fileExists(metaDb))
    errAbort("metaDb %s does not exist.", metaDb);

char *trackDb = optionVal("trackDb",defaultTrackDb);
replaceTildeWithHome(&trackDb);
if (!fileExists(trackDb))
    errAbort("trackDb %s does not exist.", trackDb);

char *downloadDir = optionVal("downloadDir",defaultDownloadDir);
replaceTildeWithHome(&downloadDir);
if (!fileExists(downloadDir))
    errAbort("downloadDir %s does not exist.", downloadDir);


printf("metaDb = %s\n trackDb = %s\n downloadDir = %s\n",metaDb,trackDb,downloadDir);

metaCheck(database, composite, metaDb, trackDb, downloadDir);

return 0;
}
int main(int argc, char *argv[])
/* Process command line. */
{
struct sqlConnection *conn = NULL;
char *command = NULL;
optionInit(&argc, argv, options);
database = optionVal("database", database);
sqlPath = optionVal("sqlPath", sqlPath);
if (argc < 2)
    usage();
command = argv[1];
if (argc >= 3)
    setCurrentDir(argv[2]);
conn = sqlConnect(database);
if (sameWord(command,"INIT"))
    {
    if (argc != 2)
	usage();
    errAbort("INIT is probably too dangerous. DO NOT USE.");
    /*	    
    init(conn);	    
    */
    }
else if (sameWord(command,"POP"))
    {
    if (argc != 2)
	usage();
    /* populate vgPrb where missing */
    populateMissingVgPrb(conn);
    }
else if (sameWord(command,"SEQ"))
    {
    if (argc != 4)
	usage();
    /* make fake probe sequences */
    makeFakeProbeSeq(conn,argv[3]);
    }
else if (sameWord(command,"ALI"))
    {
    if (argc != 4)
	usage();
    /* blat anything left that is not aligned, 
      nor even attempted */
    doAlignments(conn,argv[3]);
    }
else if (sameWord(command,"EXT"))
    {
    if (argc != 4)
	usage();
    /* update seq and extfile as necessary */
    doSeqAndExtFile(conn,argv[3],"vgProbes");
    }
else if (sameWord(command,"PSLMAP"))
    {
    if (argc != 5)
	usage();
    /* pslMap anything left that is not aligned, 
      nor even attempted */
    doAlignmentsPslMap(conn,argv[3],argv[4]);
    }
else if (sameWord(command,"REMAP"))
    {
    if (argc != 7)
	usage();
    /* re-map anything in track specified that is not aligned, 
      nor even attempted yet, using specified fasta file. */
    doAlignmentsReMap(conn,argv[3],argv[4],argv[5],argv[6]);
    }
else if (sameWord(command,"SELFMAP"))
    {
    if (argc != 4)
	usage();
    /* re-map anything in track specified that is not aligned, 
      nor even attempted yet, using specified fasta file. */
    doAlignmentsSelfMap(conn,argv[3]);
    }
else if (sameWord(command,"EXTALL"))
    {
    if (argc != 4)
	usage();
    /* update seq and extfile as necessary */
    doSeqAndExtFile(conn,argv[3],"vgAllProbes");
    }
else
    usage();
sqlDisconnect(&conn);
return 0;
}
Example #12
0
int main(int argc, char *argv[])
{
  struct lineFile *sif, *dsf, *daf, *gbf;
  FILE *of, *opf, *oaf, *off, *asf, *dff;
  char filename[256], *gbName;
  int verb = 0;

verboseSetLevel(0);
optionInit(&argc, argv, optionSpecs);
if (argc < 3)
    {
      fprintf(stderr, "USAGE: updateStsInfo [-verbose=<level> -gb=<file>] <stsInfo file> <all.STS.fa> <dbSTS.sts> <dbSTS.aliases> <dbSTS.convert.fa> <outfile prefix>\n");
    return 1;
    }
verb = optionInt("verbose", 0);
verboseSetLevel(verb);

 gbName = optionVal("gb", NULL);
 if (gbName) 
   gbf = lineFileOpen(gbName, TRUE);
 sif = lineFileOpen(argv[1], TRUE);
 asf = mustOpen(argv[2], "r");
 dsf = lineFileOpen(argv[3], TRUE);
 daf = lineFileOpen(argv[4], TRUE);
 dff = mustOpen(argv[5], "r");

 safef(filename, ArraySize(filename), "%s.info", argv[6]);
 of = mustOpen(filename, "w");
 safef(filename, ArraySize(filename), "%s.primers", argv[6]);
 opf = mustOpen(filename, "w");
 safef(filename, ArraySize(filename), "%s.alias", argv[6]);
 oaf = mustOpen(filename, "w");
 safef(filename, ArraySize(filename), "%s.fa", argv[6]);
 off = mustOpen(filename, "w");

 /* Read in current stsInfo file */
 verbose(1, "Reading current stsInfo file: %s\n", argv[1]);
 readStsInfo(sif);

 /* Read in genbank accessions that have sequences */ 
 if (gbName)
   {
     verbose(1, "Reading genbank accession file: %s\n", gbName);
     readGbAcc(gbf);
   }

 /* Read in primer and organism information from dbSTS.sts */
 verbose(1, "Reading current dbSTS.sts file: %s\n", argv[3]);
 readDbstsPrimers(dsf);

 /* Read in names from dbSTS.alias and create new stsInfo records if needed */
 verbose(1, "Reading current dbSTS.aliases file: %s\n", argv[4]);
 readDbstsNames(daf);

 /* Read in current sequences for sts markers */
 verbose(1, "Reading current all.STS file: %s\n", argv[2]);
 readAllSts(asf);

 /* Read in new sequences from dbSTS.fa */
 verbose(1, "Reading dbSTS.fa file: %s\n", argv[5]);
 readDbstsFa(dff);

 /* Print out the new files */
 verbose(1, "Creating output files: %s .info .primers .alias .fa\n", argv[6]);
 writeOut(of, opf, oaf, off);

 fclose(asf);
 lineFileClose(&dsf);
 lineFileClose(&daf);
 fclose(dff);
 if (gbName)
   lineFileClose(&gbf);   
 fclose(of);
 fclose(opf);
 fclose(oaf);
 fclose(off);

 return(0);
}
/* entry */
int main(int argc, char** argv)
{
char *baseMask1, *baseMask2, *obama;
struct genomeRangeTreeFile *tf1, *tf2;
struct genomeRangeTree *t1, *t2;
unsigned size = 0;
int nodes, numChroms;
optionInit(&argc, argv, optionSpecs);
boolean and = optionExists("and");
boolean or = optionExists("or");
boolean quiet = optionExists("quiet");
boolean saveMem = optionExists("saveMem");
boolean orDirectToFile = optionExists("orDirectToFile");
--argc;
++argv;
if (argc==0)
    usage("");
if (argc > 3)
    usage("wrong # args\n");
if (argc == 1 && (and || or))
    usage("specify second file for options: -and or -or\n");
if (argc >= 2 && ((and && or) || (!and && !or)))
    usage("specify only one of the options: -and or -or\n");

baseMask1 = argv[0];
baseMask2 = (argc > 1 ? argv[1] : NULL);
obama = (argc > 2 ? argv[2] : NULL);

if (argc == 1)
    {
    if (!quiet)
	{
	genomeRangeTreeFileStats(baseMask1, &numChroms, &nodes, &size);
	fprintf(stderr, "%d bases in %d ranges in %d chroms in baseMask\n", size, nodes, numChroms);
	}
    }
else
    {
    tf1 = genomeRangeTreeFileReadHeader(baseMask1);
    tf2 = genomeRangeTreeFileReadHeader(baseMask2);
    if (and)
	{
	genomeRangeTreeFileIntersectionDetailed(tf1, tf2, obama, &numChroms, &nodes, 
	    (quiet ? NULL : &size), saveMem);
	if (!quiet)
	    fprintf(stderr, "%d bases in %d ranges in %d chroms in intersection\n", size, nodes, numChroms);
	}
    else if (or)
	{
	genomeRangeTreeFileUnionDetailed(tf1, tf2, obama, &numChroms, &nodes, 
	    (quiet ? NULL : &size), saveMem, orDirectToFile);
	if (!quiet)
	    fprintf(stderr, "%d bases in %d ranges in %d chroms in union\n", size, nodes, numChroms);
	}
    t1 = genomeRangeTreeFileFree(&tf1);
    genomeRangeTreeFree(&t1);
    t2 = genomeRangeTreeFileFree(&tf2);
    genomeRangeTreeFree(&t2);
    }
return 0;
}
Example #14
0
int main(int argc, char *argv[])
/* Process command line. */
{
    char *db, *cdsDb, *cdsFile, *pslSpec, *genePredFile;
    int optCnt;

    optionInit(&argc, argv, optionSpecs);
    if (argc != 3)
        usage();
    pslSpec = argv[1];
    genePredFile = argv[2];
    db = optionVal("db", NULL);
    cdsDb = optionVal("cdsDb", NULL);
    cdsFile = optionVal("cdsFile", NULL);
    gRequireUtr = optionExists("requireUtr");
    if (optionExists("cdsMergeMod3") && !optionExists("cdsMergeSize"))
        errAbort("must specify -cdsMergeSize with -cdsMergeMod3");
    if (optionExists("cdsMergeSize") || optionExists("utrMergeSize"))
    {
        gCdsMergeSize = optionInt("cdsMergeSize", -1);
        gUtrMergeSize = optionInt("utrMergeSize", -1);
        if (optionExists("cdsMergeMod3"))
            gPslOptions |= genePredPslCdsMod3;
        if (optionExists("smallInsertSize") || optionExists("insertMergeSize"))
            errAbort("can't specify -smallInsertSize or -insertMergeSize with -cdsMergeSize or -utrMergeSize");
    }
    else
    {
        int insertMergeSize = genePredStdInsertMergeSize;
        if (optionExists("smallInsertSize"))
            insertMergeSize = optionInt("smallInsertSize", genePredStdInsertMergeSize);
        insertMergeSize = optionInt("insertMergeSize", genePredStdInsertMergeSize);
        gCdsMergeSize = gUtrMergeSize = insertMergeSize;
    }
    gGenePredExt = optionExists("genePredExt");
    gKeepInvalid = optionExists("keepInvalid");
    gAllCds = optionExists("allCds");
    gNoCds = optionExists("noCds");
    gQuiet = optionExists("quiet");
    gIgnoreUniqSuffix = optionExists("ignoreUniqSuffix");

    if ((gAllCds || gNoCds) && ((cdsDb != NULL) || (cdsFile != NULL)))
        errAbort("can't specify -allCds or -noCds with -cdsDb or -cdsFile");
    if (gAllCds && gRequireUtr)
        errAbort("can't specify -allCds with -requireUtr");
    /* this is a bit of work to implement */
    if ((gAllCds || gNoCds) && (db != NULL))
        errAbort("can't specify -allCds or -noCds with -db");

    optCnt = 0;
    if (db != NULL)
        optCnt++;
    if (cdsDb == NULL)
        optCnt++;
    if (cdsFile != NULL)
        optCnt++;
    if (gAllCds)
        optCnt++;
    if (gNoCds)
        optCnt++;

    if (optCnt == 1)
        errAbort("must specify one and only one of -db, -cdsDb, -cdsFile, -allCds, or -noCds");

    mrnaToGene(db, cdsDb, cdsFile, pslSpec, genePredFile);
    return 0;
}
Example #15
0
int
main(int argc, const char **argv)
{
    int res = 0;
    int optCount = 0;

    dbgIn = stdin;
    conOut = stdout;
    (void)conIn;
    (void)dbgOut;

    memset(&cache, 0, sizeof(LIST));
    memset(&sources, 0, sizeof(LIST));
    stat_clear(&summ);
    memset(&revinfo, 0, sizeof(REVINFO));
    clearLastLine();

    optionInit(argc, argv);
    optCount = optionParse(argc, argv);
    if (optCount < 0)
    {
        return optCount;
    }

    argc -= optCount;

    if (opt_Revision && (strcmp(opt_Revision, "update") == 0))
    {
        res = updateSvnlog();
        return res;
    }

    if (check_directory(opt_force))
        return 3;

    create_cache(opt_force, 0);
    if (opt_exit)
        return 0;

    read_cache();
    l2l_dbg(4, "Cache read complete\n");

    if (set_LogFile(&logFile))
        return 2;
    l2l_dbg(4, "opt_logFile processed\n");

    if (opt_Pipe)
    {
        l2l_dbg(3, "Command line: \"%s\"\n",opt_Pipe);

        if (!(dbgIn = POPEN(opt_Pipe, "r")))
        {
            dbgIn = stdin; //restore
            l2l_dbg(0, "Could not popen '%s' (%s)\n", opt_Pipe, strerror(errno));
            free(opt_Pipe); opt_Pipe = NULL;
        }
    }
    l2l_dbg(4, "opt_Pipe processed\n");

    if (argc > 1)
    {   // translate {<exefile> <offset>}
        int i = 1;
        const char *exefile = NULL;
        const char *offset = NULL;
        char Line[LINESIZE + 1];

        while (i < argc)
        {
            Line[0] = '\0';
            offset = argv[optCount + i++];
            if (isOffset(offset))
            {
                if (exefile)
                {
                    l2l_dbg(2, "translating %s %s\n", exefile, offset);
                    translate_file(exefile, my_atoi(offset), Line);
                    printf("%s\n", Line);
                    report(conOut);
                }
                else
                {
                    l2l_dbg(0, "<exefile> expected\n");
                    res = 3;
                    break;
                }
            }
            else
            {
                // Not an offset so must be an exefile:
                exefile = offset;
            }
        }
    }
    else
    {   // translate logging from stdin
        translate_files(dbgIn, conOut);
    }

    if (logFile)
        fclose(logFile);

    if (opt_Pipe)
        PCLOSE(dbgIn);

    return res;
}
Example #16
0
int main(int argc, char *argv[])
{
optionInit(&argc, argv, optionSpecs);
if (argc < 2 || argc > 3)
    usage();
pushCarefulMemHandler(LIMIT_2or6GB);
char *db = argv[1];
char *test = NULL;
boolean doAllTests = (argc == 2);
if (!doAllTests)
    {
    if (sameString(argv[2], pgSnpDbToTabOut) ||
	sameString(argv[2], pgSnpKgDbToTabOutShort) ||
	sameString(argv[2], pgSnpKgDbToTabOutLong) ||
	sameString(argv[2], pgSnpKgDbToGpFx) ||
	sameString(argv[2], snpConsDbToTabOutShort) ||
	sameString(argv[2], snpConsDbToTabOutLong) ||
	sameString(argv[2], vcfEx1) ||
	sameString(argv[2], vcfEx2) ||
	sameString(argv[2], bigBedToTabOut) ||
	sameString(argv[2], snpBigWigToTabOut) ||
	sameString(argv[2], vepOut) ||
	sameString(argv[2], gpFx))
	test = cloneString(argv[2]);
    else
	{
	warn("Unrecognized test name '%s'\n", argv[2]);
	usage();
	}
    }

if (udcCacheTimeout() < 300)
    udcSetCacheTimeout(300);
udcSetDefaultDir("./udcCache");

struct annoAssembly *assembly = getAnnoAssembly(db);

// First test: some rows of a pgSnp table
struct streamerInfo pgSnpInfo = { NULL, assembly, db, "pgNA12878", arWords, pgSnpAsObj() };
if (doAllTests || sameString(test, pgSnpDbToTabOut))
    dbToTabOut(&pgSnpInfo, "stdout", "chr1", 705881, 752721, FALSE);

// Second test: some rows of a pgSnp table integrated with knownGene
struct streamerInfo kgInfo = { NULL, assembly, db, "knownGene", arWords,
			       asParseFile("../knownGene.as") };
pgSnpInfo.next = &kgInfo;
if (doAllTests || sameString(test, pgSnpKgDbToTabOutShort))
    dbToTabOut(&pgSnpInfo, "stdout", "chr1", 705881, 752721, FALSE);

// Third test: all rows of a pgSnp table integrated with knownGene
if (doAllTests || sameString(test, pgSnpKgDbToTabOutLong))
    dbToTabOut(&pgSnpInfo, "stdout", NULL, 0, 0, FALSE);

// Fourth test: some rows of snp135 integrated with phyloP scores
if (doAllTests || sameString(test, snpConsDbToTabOutShort) ||
    sameString(test, snpConsDbToTabOutLong))
    {
    struct streamerInfo snp135Info = { NULL, assembly, db, "snp135", arWords,
				       asParseFile("../snp132Ext.as") };
    struct streamerInfo phyloPInfo = { NULL, assembly, db, "phyloP46wayPlacental", arWig, NULL };
    snp135Info.next = &phyloPInfo;
    if (sameString(test, snpConsDbToTabOutShort))
	dbToTabOut(&snp135Info, "stdout", "chr1", 737224, 738475, FALSE);
    else
	dbToTabOut(&snp135Info, "stdout", NULL, 0, 0, FALSE);
    }

// Fifth test: VCF with genotypes
if (doAllTests || sameString(test, vcfEx1))
    {
#if (defined USE_TABIX && defined KNETFILE_HOOKS)
    knetUdcInstall();
#endif//def USE_TABIX && KNETFILE_HOOKS
    struct streamerInfo vcfEx1 = { NULL, assembly, NULL,
			   "http://genome.ucsc.edu/goldenPath/help/examples/vcfExample.vcf.gz",
				   arWords, vcfAsObj() };
    dbToTabOut(&vcfEx1, "stdout", NULL, 0, 0, FALSE);
    }

if (doAllTests || sameString(test, vcfEx2))
    {
    struct streamerInfo vcfEx2 = { NULL, assembly, NULL,
			   "http://genome.ucsc.edu/goldenPath/help/examples/vcfExampleTwo.vcf",
				   arWords, vcfAsObj() };
    dbToTabOut(&vcfEx2, "stdout", NULL, 0, 0, FALSE);
    }

if (doAllTests || sameString(test, pgSnpKgDbToGpFx))
    {
    struct streamerInfo pg2SnpInfo = { NULL, assembly, NULL,
				       "input/annoGrator/pgForTestingGpFx.pgSnp.tab",
				       arWords, pgSnpAsObj() };
    pg2SnpInfo.next = &kgInfo;

    dbToTabOut(&pg2SnpInfo, "stdout", NULL, 0, 0, TRUE);

    /*
    FIXME
    // 3base insertion CDS - chr3:124,646,699-124,646,718
    dbToTabOut(&pg2SnpInfo, "stdout", "chr3",124646699,124646718, TRUE);
    */
    }

if (doAllTests || sameString(test, bigBedToTabOut))
    {
    struct streamerInfo bigBedInfo = { NULL, assembly, NULL,
			   "http://genome.ucsc.edu/goldenPath/help/examples/bigBedExample.bb",
				       arWords, NULL };
    dbToTabOut(&bigBedInfo, "stdout", "chr21", 34716800, 34733700, FALSE);
    }

if (doAllTests || sameString(test, snpBigWigToTabOut))
    {
    struct streamerInfo snp135Info = { NULL, assembly, db, "snp135", arWords,
				       asParseFile("../snp132Ext.as") };
    struct streamerInfo bigWigInfo = { NULL, assembly, NULL,
			   "http://genome.ucsc.edu/goldenPath/help/examples/bigWigExample.bw",
				       arWig, NULL };
    snp135Info.next = &bigWigInfo;
    dbToTabOut(&snp135Info, "stdout", "chr21", 34716800, 34733700, FALSE);
    }

if (doAllTests || sameString(test, vepOut))
    {
    struct streamerInfo vepSamplePgSnp = { NULL, assembly, NULL,
					   "input/annoGrator/vepSample.pgSnp.tab",
					   arWords, asParseFile("../pgSnp.as") };
    struct streamerInfo kgInfo = { NULL, assembly, db, "ensGene", arWords,
				   asParseFile("../genePredExt.as") };
    struct streamerInfo snpInfo = { NULL, assembly, db, "snp135", arWords,
				    asParseFile("../snp132Ext.as") };
    vepSamplePgSnp.next = &kgInfo;
    kgInfo.next = &snpInfo;
    // Instead of dbToTabOut, we need to make a VEP config data structure and
    // use it to create an annoFormatVep.
    struct streamerInfo *primaryInfo = &vepSamplePgSnp;
    struct annoStreamer *primary = NULL;
    struct annoGrator *gratorList = NULL;
    sourcesFromInfoList(primaryInfo, TRUE, &primary, &gratorList);
    struct annoStreamer *gpVarSource = (struct annoStreamer *)gratorList;
    struct annoStreamer *snpSource = gpVarSource->next;
    struct annoFormatter *vepOut = annoFormatVepNew("stdout", FALSE, primary, "vepSamplePgSnp",
						    gpVarSource, "UCSC Genes ...",
						    snpSource, "just dbSNP 135");
    struct annoGratorQuery *query = annoGratorQueryNew(assembly, primary, gratorList, vepOut);
    annoGratorQuerySetRegion(query, "chr1", 876900, 886920);
    annoGratorQueryExecute(query);
    annoGratorQuerySetRegion(query, "chr5", 135530, 145535);
    annoGratorQueryExecute(query);
    annoGratorQueryFree(&query);
    }

if (doAllTests || sameString(test, gpFx))
    {
    struct streamerInfo variants = { NULL, assembly, NULL,
					   "input/annoGrator/moreVariants.pgSnp.tab",
					   arWords, asParseFile("../pgSnp.as") };
    struct streamerInfo kgInfo = { NULL, assembly, db, "knownGene", arWords,
				   asParseFile("../knownGene.as") };
    struct streamerInfo snpInfo = { NULL, assembly, db, "snp137", arWords,
				    asParseFile("../snp132Ext.as") };
    struct asObject *dbNsfpSeqChangeAs =
	bigBedAsFromFileName("/gbdb/hg19/dbNsfp/dbNsfpSeqChange.bb");
    struct streamerInfo dbNsfpSeqChange =
	{ NULL, assembly, NULL, "/gbdb/hg19/dbNsfp/dbNsfpSeqChange.bb",
	  arWords, dbNsfpSeqChangeAs };
    struct asObject *dbNsfpSiftAs = bigBedAsFromFileName("/gbdb/hg19/dbNsfp/dbNsfpSift.bb");
    struct streamerInfo dbNsfpSift = { NULL, assembly, NULL, "/gbdb/hg19/dbNsfp/dbNsfpSift.bb",
				       arWords, dbNsfpSiftAs };
    variants.next = &kgInfo;
    kgInfo.next = &snpInfo;
    snpInfo.next = &dbNsfpSeqChange;
    dbNsfpSeqChange.next = &dbNsfpSift;
    // Instead of dbToTabOut, we need to make a VEP config data structure and
    // use it to create an annoFormatVep.
    struct streamerInfo *primaryInfo = &variants;
    struct annoStreamer *primary = NULL;
    struct annoGrator *gratorList = NULL;
    sourcesFromInfoList(primaryInfo, TRUE, &primary, &gratorList);
    struct annoStreamer *gpVarSource = (struct annoStreamer *)gratorList;
    struct annoStreamer *snpSource = gpVarSource->next;
    struct annoStreamer *dbNsfpSource = snpSource->next->next;
    struct annoFormatter *vepOut = annoFormatVepNew("stdout", FALSE, primary, "some more variants",
						    gpVarSource, "UCSC Genes of course",
						    snpSource, "now snp137.");
    annoFormatVepAddExtraItem(vepOut, dbNsfpSource, "SIFT", "SIFT score from dbNSFP", "");
    struct annoGratorQuery *query = annoGratorQueryNew(assembly, primary, gratorList, vepOut);
    annoGratorQuerySetRegion(query, "chr19", 45405960, 45419476);
    annoGratorQueryExecute(query);
    annoGratorQueryFree(&query);
    }

return 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);
}
int main(int argc, char *argv[])
{
  struct lineFile *pf, *ef, *apf;
  FILE *of, *nf, *enf=NULL;
  char *efName=NULL, filename[256], notFound[256];
  int verb = 0;

verboseSetLevel(0);
optionInit(&argc, argv, optionSpecs);
if (argc < 3)
    {
      verbose(0, "usage: pslFilterPrimers [-epcr=<file> -verbose=<level>] <isPCR psl file> <all.primers> <outfile>\n");
    return 1;
    }
verb = optionInt("verbose", 0);
verboseSetLevel(verb);

 efName = optionVal("epcr", NULL);
 pf = pslFileOpen(argv[1]);
 apf = lineFileOpen(argv[2], TRUE);

 of = mustOpen(argv[3], "w");
 safef(notFound, sizeof(filename), "%s.notfound.primers", argv[3]);
 nf = mustOpen(notFound, "w");

 verbose(1, "Reading all primers file: '%s'\n", argv[2]);
 readPrimerInfo(apf);

 if (efName)
   {
     ef = lineFileOpen(efName, TRUE);
     verbose(1, "Reading epcr file: '%s'\n", efName);
     readEpcr(ef);
   }

 verbose(1, "Reading isPCR file: '%s' processing output to: '%s'\n", argv[1], argv[3]);
 processPrimers(pf, of);

 if (efName)
   {
     safef(filename, sizeof(filename), "epcr.not.found");
     verbose(1, "Writing %s file\n", filename);
     enf = mustOpen(filename, "w");
     writeEpcrNotFound(enf);
   }

 verbose(1, "Writing primers not found to file: '%s'\n", notFound);
 writePrimersNotFound(nf);

 if (efName)
   {
     lineFileClose(&ef);
     fclose(enf);
   }
 lineFileClose(&pf);
 lineFileClose(&apf);
 fclose(of);
 fclose(nf);

 return(0);
}
Example #19
0
/* entry */
int main(int argc, char** argv)
{
char *selectFile, *inFile, *outFile, *dropFile;
optionInit(&argc, argv, optionSpecs);
if (argc != 4)
    usage("wrong # args");
selectFile = argv[1];
inFile = argv[2];
outFile = argv[3];

/* select file options */
if (optionExists("selectFmt") && optionExists("selectCoordCols"))
    errAbort("can't specify both -selectFmt and -selectCoordCols");

if (optionExists("selectFmt"))
    selectFmt = parseFormatSpec(optionVal("selectFmt", NULL));
else if (optionExists("selectCoordCols"))
    {
    selectCoordCols = coordColsParseSpec("selectCoordCols",
                                         optionVal("selectCoordCols", NULL));
    selectFmt = COORD_COLS_FMT;
    }
else
    selectFmt = getFileFormat(selectFile);

if (optionExists("selectCds"))
    selectCaOpts |= chromAnnCds;
if (optionExists("selectRange"))
    selectCaOpts |= chromAnnRange;
if ((selectFmt == PSLQ_FMT) || (selectFmt == CHAINQ_FMT))
    selectCaOpts |= chromAnnUseQSide;

/* in file options */
if (optionExists("inFmt") && optionExists("inCoordCols"))
    errAbort("can't specify both -inFmt and -inCoordCols");
if (optionExists("inFmt"))
    inFmt = parseFormatSpec(optionVal("inFmt", NULL));
else if (optionExists("inCoordCols"))
    {
    inCoordCols = coordColsParseSpec("inCoordCols",
                                     optionVal("inCoordCols", NULL));
    inFmt = COORD_COLS_FMT;
    }
else
    inFmt = getFileFormat(inFile);

inCaOpts = chromAnnSaveLines; // need lines for output
if (optionExists("inCds"))
    inCaOpts |= chromAnnCds;
if (optionExists("inRange"))
    inCaOpts |= chromAnnRange;
if ((inFmt == PSLQ_FMT) || (inFmt == CHAINQ_FMT))
    inCaOpts |= chromAnnUseQSide;

/* select options */
useAggregate = optionExists("aggregate");
nonOverlapping = optionExists("nonOverlapping");
if (optionExists("strand") && optionExists("oppositeStrand"))
    errAbort("can only specify one of -strand and -oppositeStrand");
if (optionExists("strand"))
    selectOpts |= selStrand;
if (optionExists("oppositeStrand"))
    selectOpts |= selOppositeStrand;
if (optionExists("excludeSelf") && (optionExists("idMatch")))
    errAbort("can't specify both -excludeSelf and -idMatch");
if (optionExists("excludeSelf"))
    selectOpts |= selExcludeSelf;
if (optionExists("idMatch"))
    selectOpts |= selIdMatch;

criteria.threshold = optionFloat("overlapThreshold", 0.0);
criteria.thresholdCeil = optionFloat("overlapThresholdCeil", 1.1);
criteria.similarity = optionFloat("overlapSimilarity", 0.0);
criteria.similarityCeil = optionFloat("overlapSimilarityCeil", 1.1);
criteria.bases = optionInt("overlapBases", -1);

/* output options */
mergeOutput = optionExists("mergeOutput");
idOutput = optionExists("idOutput");
statsOutput = optionExists("statsOutput") || optionExists("statsOutputAll") || optionExists("statsOutputBoth");
if ((mergeOutput + idOutput + statsOutput) > 1)
    errAbort("can only specify one of -mergeOutput, -idOutput, -statsOutput, -statsOutputAll, or -statsOutputBoth");
outputAll = optionExists("statsOutputAll");
outputBoth = optionExists("statsOutputBoth");
if (outputBoth)
    outputAll = TRUE;
if (mergeOutput)
    {
    if (nonOverlapping)
        errAbort("can't use -mergeOutput with -nonOverlapping");
    if (useAggregate)
        errAbort("can't use -mergeOutput with -aggregate");
    if ((selectFmt == CHAIN_FMT) || (selectFmt == CHAINQ_FMT)
        || (inFmt == CHAIN_FMT) || (inFmt == CHAINQ_FMT))
    if (useAggregate)
        errAbort("can't use -mergeOutput with chains");
    selectCaOpts |= chromAnnSaveLines;
    }
dropFile = optionVal("dropped", NULL);

/* check for options incompatible with aggregate mode */
if (useAggregate)
    {
    int i;
    for (i = 0; aggIncompatible[i] != NULL; i++)
        {
        if (optionExists(aggIncompatible[i]))
            errAbort("-%s is not allowed -aggregate", aggIncompatible[i]);
        }
    }

overlapSelect(selectFile, inFile, outFile, dropFile);
return 0;
}
Example #20
0
int main(int argc, char *argv[])
/* Process command line. */
{
char * binSizeStr = (char *) NULL;

optionInit(&argc, argv, optionSpecs);
if (argc < 2)
    usage();

binSizeStr = optionVal("binSize", "1");
maxBinCount = optionInt("maxBinCount", 25);
minValStr = optionVal("minVal", "0");
doLog = optionExists("log");
noStar = optionExists("noStar");
probValues = optionExists("probValues");
col = optionInt("col", 1) - 1;
aveCol = optionInt("aveCol", 0) - 1;
real = optionExists("real");
autoscale = optionInt("autoscale", 0);
if (autoscale == 0)
    autoscale = optionInt("autoScale", 0);
freq = optionExists("freq") && !probValues;  /* freq and probValues don't currently work right together */
skip = optionInt("skip", 0);

/*	probValues turns on noStar too	*/
if (probValues) noStar = TRUE;

if (real)
    {
    char *valEnd;
    char *val = binSizeStr;
    binSizeR = strtod(val, &valEnd);
    if ((*val == '\0') || (*valEnd != '\0'))
	errAbort("Not a valid float for -binSize=%s\n", binSizeStr);
    if (binSizeR <= 0.0)
	errAbort("invalid binSize, must be greater than zero: %g\n", binSizeR);
    val = minValStr;
    minValR = strtod(val, &valEnd);
    if ((*val == '\0') || (*valEnd != '\0'))
	errAbort("Not a valid float for -minVal=%s\n", binSizeStr);
    }
else
    {
    binSize = atoi(binSizeStr);
    if (binSize < 1)
	errAbort("invalid binSize, must be >= one: %d\n", binSize);
    minVal = atoi(minValStr);
    }

verbose(2,"#\tbinSize: ");
if (real) verbose(2, "%f\n", binSizeR);
    else verbose(2, "%d\n", binSize);
verbose(2,"#\tmaxBinCount: %d\n", maxBinCount);
verbose(2,"#\tminVal: ");
if (real) verbose(2, "%f\n", minValR);
    else verbose(2, "%d\n", minVal);
verbose(2,"#\tlog function: %s\n", doLog ? "ON" : "OFF" );
verbose(2,"#\tdraw asterisks: %s\n", noStar ? "NO" : "YES" );
verbose(2,"#\thistogram on data input column: %d\n", col+1);
if (aveCol >= 0)
    verbose(2, "#\taveCol: %d\n", aveCol);
else
    verbose(2, "#\taveCol: not selected\n");
verbose(2,"#\treal valued data: %s\n", real ? "YES" : "NO" );
if (autoscale > 0)
    verbose(2, "#\tautoscaling to %d bins\n", autoscale);
else
    verbose(2, "#\tautoscale: not selected\n");
verbose(2, "#\tshow prob-Values: %s\n", probValues ? "YES" : "NO" );

/*	to autoscale stdin we would need to keep all the data read in
 *	during the min,max scan and reuse that data for the histogram
 *	calculation.  Not implemented yet.
 */
if (autoscale > 0)
    {
    if (startsWith("stdin", argv[1]))
	{
	errAbort("Sorry, can not autoscale stdin at this time.  Outstanding feature request.");
	}
    autoScale(argv[1]);
    }

textHistogram(argv[1]);
return 0;
}
int main(int argc, char *argv[])
/* Process command line into global variables and call blat. */
{
boolean tIsProtLike, qIsProtLike;

#ifdef DEBUG
{
char *cmd = "blat hCrea.geno hCrea.mrna foo.psl -t=dnax -q=rnax";
char *words[16];

printf("Debugging parameters\n");
cmd = cloneString(cmd);
argc = chopLine(cmd, words);
argv = words;
}
#endif /* DEBUG */

optionInit(&argc, argv, options);
if (argc != 4)
    usage();

/* Get database and query sequence types and make sure they are
 * legal and compatable. */
if (optionExists("prot"))
    qType = tType = gftProt;
if (optionExists("t"))
    tType = gfTypeFromName(optionVal("t", NULL));
trimA = optionExists("trimA") || optionExists("trima");
trimT = optionExists("trimT") || optionExists("trimt");
trimHardA = optionExists("trimHardA");
switch (tType)
    {
    case gftProt:
    case gftDnaX:
        tIsProtLike = TRUE;
	break;
    case gftDna:
        tIsProtLike = FALSE;
	break;
    default:
	tIsProtLike = FALSE;
        errAbort("Illegal value for 't' parameter");
	break;
    }
if (optionExists("q"))
    qType = gfTypeFromName(optionVal("q", NULL));
if (qType == gftRnaX || qType == gftRna)
    trimA = TRUE;
if (optionExists("noTrimA"))
    trimA = FALSE;
switch (qType)
    {
    case gftProt:
    case gftDnaX:
    case gftRnaX:
	minIdentity = 25;
        qIsProtLike = TRUE;
	break;
    default:
        qIsProtLike = FALSE;
	break;
    }
if ((tIsProtLike ^ qIsProtLike) != 0)
    errAbort("t and q must both be either protein or dna");

/* Set default tile size for protein-based comparisons. */
if (tIsProtLike)
    {
    tileSize = 5;
    minMatch = 1;
    oneOff = FALSE;
    maxGap = 0;
    }

/* Get tile size and related parameters from user and make sure
 * they are within range. */
tileSize = optionInt("tileSize", tileSize);
stepSize = optionInt("stepSize", tileSize);
minMatch = optionInt("minMatch", minMatch);
oneOff = optionExists("oneOff");
fastMap = optionExists("fastMap");
minScore = optionInt("minScore", minScore);
maxGap = optionInt("maxGap", maxGap);
minRepDivergence = optionFloat("minRepDivergence", minRepDivergence);
minIdentity = optionFloat("minIdentity", minIdentity);
gfCheckTileSize(tileSize, tIsProtLike);
if (minMatch < 0)
    errAbort("minMatch must be at least 1");
if (maxGap > 100)
    errAbort("maxGap must be less than 100");



/* Set repMatch parameter from command line, or
 * to reasonable value that depends on tile size. */
if (optionExists("repMatch"))
    repMatch = optionInt("repMatch", repMatch);
else
    repMatch = gfDefaultRepMatch(tileSize, stepSize, tIsProtLike);

/* Gather last few command line options. */
noHead = optionExists("noHead");
ooc = optionVal("ooc", NULL);
makeOoc = optionVal("makeOoc", NULL);
mask = optionVal("mask", NULL);
qMask = optionVal("qMask", NULL);
repeats = optionVal("repeats", NULL);
if (repeats != NULL && mask != NULL && differentString(repeats, mask))
    errAbort("The -mask and -repeat settings disagree.  "
             "You can just omit -repeat if -mask is on");
if (mask != NULL)	/* Mask setting will also set repeats. */
    repeats = mask;
outputFormat = optionVal("out", outputFormat);
dotEvery = optionInt("dots", 0);
/* set global for fuzzy find functions */
setFfIntronMax(optionInt("maxIntron", ffIntronMaxDefault));
setFfExtendThroughN(optionExists("extendThroughN"));


/* Call routine that does the work. */
blat(argv[1], argv[2], argv[3]);
return 0;
}
Example #22
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
blockSize = optionInt("blockSize", blockSize);
itemsPerSlot = optionInt("itemsPerSlot", itemsPerSlot);
asFile = optionVal("as", asFile);
doCompress = !optionExists("unc");
sizesIs2Bit = optionExists("sizesIs2Bit");
extraIndex = optionVal("extraIndex", NULL);
tabSep = optionExists("tab");
udcDir = optionVal("udcDir", udcDefaultDir());
if (argc != 4)
    usage();
udcSetDefaultDir(udcDir);

if (optionExists("type"))
    {
    // parse type
    char *btype = cloneString(optionVal("type", ""));
    char *plus = strchr(btype, '+');
    if (plus)
	{
	*plus++ = 0;
	if (isdigit(*plus))
	    bedP = sqlUnsigned(plus);
	}
    if (!startsWith("bed", btype))
	errAbort("type must begin with \"bed\"");
    btype +=3;
    bedN = sqlUnsigned(btype);
    if (bedN < 3)
	errAbort("Bed must be 3 or higher, found %d\n", bedN);
    if (bedN > 15)
	errAbort("Bed must be 15 or lower, found %d\n", bedN);
    }
else
    {
    if (asText)
	errAbort("If you specify the .as file, you must specify the -type as well so that\n"
	         "the number of standard BED columns is known.");
    }

/* If the haven't set bedN and bedP from the type var in the command line, then we sniff it
 * out from file. */
char *bedFileName = argv[1];
if (bedN == 0)
    {
    /* Just read in single line and count fields. */
    struct lineFile *lf = lineFileOpen(bedFileName, TRUE);
    char *line;
    if (!lineFileNextReal(lf, &line))
        errAbort("%s is empty", lf->fileName);
    int fieldCount;
    if (tabSep)
	fieldCount = chopByChar(line, '\t', NULL, 0); // Do not use chopString, see GOTCHA
    else
	fieldCount = chopByWhite(line, NULL, 0);
    if (fieldCount > 256)
        errAbort("Too many columns in %s, you sure it's a bed file?", lf->fileName);
    lineFileClose(&lf);

    /* Set up so that it looks like we are straight up bed for that many fields,
     * or if more than or maximum defined fields, then for bed15+ */
    bedN = fieldCount;
    if (bedN > bedKnownFields)
        {
	bedP = bedN - bedKnownFields;
	bedN = bedKnownFields;
	}
    }
   
/* Make sure that fields are defined, from bed spec if nowhere else. */
if (asFile)
    readInGulp(asFile, &asText, NULL);
else
    asText = bedAsDef(bedN,  bedN + bedP);

bedToBigBed(bedFileName, argv[2], argv[3]);
optionFree();
if (verboseLevel() > 1)
    printVmPeak();
return 0;
}
Example #23
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);

if (argc != 2 && !optionExists("settings"))
    usage();

struct trackHubCheckOptions *checkOptions = NULL;
AllocVar(checkOptions);

checkOptions->specHost = (optionExists("test") ? "genome-test.soe.ucsc.edu" : "genome.ucsc.edu");
checkOptions->specHost = optionVal("specHost", checkOptions->specHost);

checkOptions->printMeta = optionExists("printMeta");
checkOptions->checkFiles = !optionExists("noTracks");
checkOptions->checkSettings = optionExists("checkSettings");

struct trackHubSettingSpec *setting = NULL;
AllocVar(setting);
setting->level = optionVal("level", "all");
if (trackHubSettingLevel(setting) < 0)
    {
    fprintf(stderr, "ERROR: Unrecognized support level %s\n\n", setting->level);
    usage();
    }
checkOptions->level = setting->level;

char *version = NULL;
if (optionExists("version"))
    version = optionVal("version", NULL);
checkOptions->version = version;

char *extraFile = optionVal("extra", NULL);
if (extraFile != NULL)
    addExtras(extraFile, checkOptions);

cacheTime = optionInt("cacheTime", cacheTime);
udcSetCacheTimeout(cacheTime);
// UDC cache dir: first check for hg.conf setting, then override with command line option if given.
setUdcCacheDir();
udcSetDefaultDir(optionVal("udcDir", udcDefaultDir()));

knetUdcInstall();  // make the htslib library use udc

if (optionExists("settings"))
    {
    showSettings(checkOptions);
    return 0;
    }

struct dyString *errors = newDyString(1024);
if (trackHubCheck(argv[1], checkOptions, errors))
    {
    // uniquify and count errors
    struct slName *errs = slNameListFromString(errors->string, '\n');
    slUniqify(&errs, slNameCmp, slNameFree);
    int errCount = slCount(errs);
    printf("Found %d problem%s:\n", errCount, errCount == 1 ? "" : "s");
    printf("%s\n", slNameListToString(errs, '\n'));
    return 1;
    }
return 0;
}
int main(int argc, char *argv[])
{
struct lineFile *stf,*zmf, *gzf, *uaf, *zaf;
FILE *sto; 
char filename[256];
int verb = 0;

verboseSetLevel(0);
optionInit(&argc, argv, optionSpecs);
if (argc < 7)
    {
fprintf(stdout, "USAGE: formatZfishSts [-verbose=<level>] <UniSTS file> <genbank.txt> <UniSTS aliases> <ZFIN aliases> <ZFIN mappings.txt> <dbSTS map panels>\n");
    return 1;
    }
verb = optionInt("verbose", 0);
verboseSetLevel(verb);

stf = lineFileOpen(argv[1], TRUE);
zmf = lineFileOpen(argv[2], TRUE);
gzf = lineFileOpen(argv[3], TRUE);
uaf = lineFileOpen(argv[4], TRUE);
zaf = lineFileOpen(argv[5], TRUE);

stderr = mustOpen("/cluster/bluearc/danRer1/stsMarkers/formatOut/error.log", "w");
sprintf(filename, "%s.format", argv[6]);
sto = mustOpen(filename, "w");

/* Read in STS markers file */
verbose(1, "Reading STS markers file\n");
readStsMarkers(stf);

/* Read in ZFIN Ids, maps and marker names from mapping.txt */
verbose(1, "Reading mapping.txt file\n");
readZfinMapping(zmf);

/* Read in genbank accessions that have ZFIN IDs */
verbose(1, "Reading genbank accession and ZFIN ID file\n");
readGbZfin(gzf);

/* Read in UniSTS alias information */
verbose(1, "Reading UniSTS aliases file\n");
readUnistsAliases(uaf);
/* Read in ZFIN marker IDs with old names */
verbose(1, "Reading ZFIN marker IDs and old names - aliases from a file\n");
readZfinAliases(zaf);

/* Print out the STS marker information to a file */
verbose(1, "Creating output file\n");
writeOut(sto);

lineFileClose(&stf);
lineFileClose(&zmf);
lineFileClose(&gzf);
lineFileClose(&uaf);
lineFileClose(&zaf);
fclose(sto);
fclose(stderr);

freeHash(&stsHash);
freeHash(&stsIdHash);
freeHash(&zfinMarkerHash);
freeHash(&zfinIdHash);
freeHash(&aliasByNameHash);
freeHash(&aliasHash);
return(0);
}
Example #25
0
int main(int argc, char *argv[])
{
  struct lineFile *pf, *ef, *apf;
  FILE *of, *nf, *enf=NULL;
  char *efName=NULL, filename[256];
  int verb = 0;

verboseSetLevel(0);
optionInit(&argc, argv, optionSpecs);
if (argc < 3)
    {
      fprintf(stderr, "USAGE: pslAnal [-epcr=<file> -verbose=<level>] <isPCR psl file> <all.primers> <outfile>\n");
    return 1;
    }
verb = optionInt("verbose", 0);
verboseSetLevel(verb);

 efName = optionVal("epcr", NULL);
 pf = pslFileOpen(argv[1]);
 apf = lineFileOpen(argv[2], TRUE);

 of = mustOpen(argv[3], "w");
 sprintf(filename, "%s.notfound.primers", argv[3]);
 nf = mustOpen(filename, "w");

 verbose(1, "Reading all.primers file\n");
 readPrimerInfo(apf);

 if (efName)
   {
     ef = lineFileOpen(efName, TRUE);
     verbose(1, "Reading epcr file\n");
     readEpcr(ef);
   }

 verbose(1, "Reading and processing isPCR file\n");
 processPrimers(pf, of);

 if (efName)
   {
     verbose(1, "Writing epcr.not.found file\n");
     sprintf(filename, "epcr.not.found");
     enf = mustOpen(filename, "w");
     writeEpcrNotFound(enf);
   }

 verbose(1, "Writing out primers not found\n");
 writePrimersNotFound(nf);

 if (efName)
   {
     lineFileClose(&ef);
     fclose(enf);
   }
 lineFileClose(&pf);
 lineFileClose(&apf);
 fclose(of);
 fclose(nf);

 return(0);
}
Example #26
0
int main(int argc, char *argv[])
/* Process command line. */
{
char *chromInfo;
optionInit(&argc, argv, optionSpecs);
if (argc < 4)
    usage();
noBin = optionExists("noBin") || optionExists("nobin");
noSort = optionExists("noSort");
strictTab = optionExists("tab");
oldTable = optionExists("oldTable");
sqlTable = optionVal("sqlTable", sqlTable);
renameSqlTable = optionExists("renameSqlTable");
trimSqlTable = optionExists("trimSqlTable");
as = optionVal("as", as);
type = optionVal("type", type);
hasBin = optionExists("hasBin");
noLoad = optionExists("noLoad");
noHistory = optionExists("noHistory");
bedGraph = optionInt("bedGraph",0);
bedDetail = optionExists("bedDetail");
minScore = optionInt("minScore",100);
if (minScore<0 || minScore>1000)
    errAbort("minScore must be between 0-1000\n");
notItemRgb = optionExists("notItemRgb");
if (notItemRgb) itemRgb = FALSE;
maxChromNameLength = optionInt("maxChromNameLength",0);
dotIsNull = optionInt("dotIsNull",dotIsNull);
noStrict = optionExists("noStrict") || optionExists("nostrict");
allowStartEqualEnd = optionExists("allowStartEqualEnd");
tmpDir = optionVal("tmpDir", tmpDir);
nameIx = ! optionExists("noNameIx");
ignoreEmpty = optionExists("ignoreEmpty");
allowNegativeScores = optionExists("allowNegativeScores");
customTrackLoader = optionExists("customTrackLoader");
parseType();
/* turns on: noNameIx, ignoreEmpty, allowStartEqualEnd, allowNegativeScores
 * -verbose=0 */
if (customTrackLoader)
    {
    type = NULL;   /* because customTrack/Factory has already validated the input */
    ignoreEmpty = TRUE;
    noHistory = TRUE;
    nameIx = FALSE;
    allowStartEqualEnd = TRUE;
    allowNegativeScores = TRUE;
    verboseSetLevel(0);
    expireSeconds = 1200;	/* 20 minutes */
    (void) signal(SIGALRM, selfApoptosis);
    (void) alarm(expireSeconds);	/* CGI timeout */
    }
fillInScoreColumn = optionVal("fillInScore", NULL);

chromInfo=optionVal("chromInfo", NULL);
if (chromInfo)
    {
    if (!type)
	errAbort("Only use chromInfo with type for validate");
    // Get chromInfo from file
    chrHash = chromHashFromFile(chromInfo); 
    }
else if (type)
    {
    // Get chromInfo from DB
    chrHash = chromHashFromDatabase(argv[1]); 
    }

hgLoadBed(argv[1], argv[2], argc-3, argv+3);
return 0;
}
Example #27
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);

if ((argc != 1) || optionExists("-help"))
    usage();

char *hgdbConf = getenv("HGDB_CONF");
if (hgdbConf)
    printf("\nHGDB_CONF = %s\n\n", hgdbConf);

// go through the list of cfgNames found to assemble a list of configs
struct slName *cfgName = NULL, *cfgNameList = NULL, *configList = NULL, *config = NULL;
cfgNameList = cfgNames();
slNameSort(&cfgNameList);
for (cfgName = cfgNameList; cfgName; cfgName = cfgName->next)
    {
    //printf("%s\n", cfgName->name);
    if (endsWith(cfgName->name, ".user"))
	{
	char *base = cloneString(cfgName->name);
	base[strlen(base)-5] = 0;
	/* get connection info */
	//char *database = getCfgOption(base, "db"      );  apparently this can be optional on customtracks?
	char *host     = getCfgOption(base, "host"    );
	char *user     = getCfgOption(base, "user"    );
	char *password = getCfgOption(base, "password");
	if (/*database &&*/ host && user && password)
	    {
    	    //printf("%s\n", base);
	    slAddHead(&configList, slNameNew(base));
	    }
	}
    }
slReverse(&configList);
printf("Configs found:\n\n");
int problemsFound = 0;
for (config = configList; config; config = config->next)
    {
    printf("Config %s\n", config->name);
    printf("%s.host=%s\n", config->name, getCfgOption(config->name, "host"));
    printf("%s.user=%s\n", config->name, getCfgOption(config->name, "user"));
    boolean problemFound = mysqlCheckSecurityOfConfig(config->name);
    if (problemFound)
	{
	++problemsFound;
	printf("!!! Problem found in config %s !!!\n", config->name);
	}
    else
	{
	printf("Config %s is protected from mysql database access.\n", config->name);
	}
    printf("\n");
    }
printf("\nProblems Found in %d out of %d Configs\n\n", problemsFound, slCount(configList));

if (problemsFound > 1)
    return 1;

return 0;  
}
int main(int argc, char *argv[])
/* Process command line. */
{
int i;
char *cp;
unsigned long long reversed;
size_t maxAlloc;
char asciiAlloc[32];

optionInit(&argc, argv, options);

if (argc < 2)
    usage();

maxAlloc = 2100000000 *
	 (((sizeof(size_t)/4)*(sizeof(size_t)/4)*(sizeof(size_t)/4)));
sprintLongWithCommas(asciiAlloc, (long long) maxAlloc);
verbose(4, "#\tmaxAlloc: %s\n", asciiAlloc);
setMaxAlloc(maxAlloc);
/* produces: size_t is 4 == 2100000000 ~= 2^31 = 2Gb
 *      size_t is 8 = 16800000000 ~= 2^34 = 16 Gb
 */

dnaUtilOpen();

motif = optionVal("motif", NULL);
chr = optionVal("chr", NULL);
strand = optionVal("strand", NULL);
bedOutput = optionExists("bedOutput");
wigOutput = optionExists("wigOutput");

if (wigOutput)
    bedOutput = FALSE;
else
    bedOutput = TRUE;

if (chr)
    verbose(2, "#\tprocessing chr: %s\n", chr);
if (strand)
    verbose(2, "#\tprocessing strand: '%s'\n", strand);
if (motif)
    verbose(2, "#\tsearching for motif: %s\n", motif);
else {
    warn("ERROR: -motif string empty, please specify a motif\n");
    usage();
}
verbose(2, "#\ttype output: %s\n", wigOutput ? "wiggle data" : "bed format");
verbose(2, "#\tspecified sequence: %s\n", argv[1]);
verbose(2, "#\tsizeof(motifVal): %d\n", (int)sizeof(motifVal));
if (strand)
    {
    if (! (sameString(strand,"+") | sameString(strand,"-")))
	{
	warn("ERROR: -strand specified ('%s') is not + or - ?\n", strand);
	usage();
	}
    /*	They are both on by default, turn off the one not specified */
    if (sameString(strand,"-"))
	doPlusStrand = FALSE;
    if (sameString(strand,"+"))
	doMinusStrand = FALSE;
    }
motifLen = strlen(motif);
/*	at two bits per character, size limit of motif is
 *	number of bits in motifVal / 2
 */
if (motifLen > (4*sizeof(motifVal))/2 )
    {
    warn("ERROR: motif string too long, limit %d\n", (4*(int)sizeof(motifVal))/2 );
    usage();
    }
cp = motif;
motifVal = 0;
complementVal = 0;
for (i = 0; i < motifLen; ++i)
    {
	switch (*cp)
	{
	case 'a':
	case 'A':
	    motifVal = (motifVal << 2) | A_BASE_VAL;
	    complementVal = (complementVal << 2) | T_BASE_VAL;
	    break;
	case 'c':
	case 'C':
	    motifVal = (motifVal << 2) | C_BASE_VAL;
	    complementVal = (complementVal << 2) | G_BASE_VAL;
	    break;
	case 'g':
	case 'G':
	    motifVal = (motifVal << 2) | G_BASE_VAL;
	    complementVal = (complementVal << 2) | C_BASE_VAL;
	    break;
	case 't':
	case 'T':
	    motifVal = (motifVal << 2) | T_BASE_VAL;
	    complementVal = (complementVal << 2) | A_BASE_VAL;
	    break;
	default:
	    warn(
		"ERROR: character in motif: '%c' is not one of ACGT\n", *cp);
	    usage();
	}
	++cp;
    }
reversed = 0;
for (i = 0; i < motifLen; ++i)
    {
    int base;
    base = complementVal & 3;
    reversed = (reversed << 2) | base;
    complementVal >>= 2;
    }
complementVal = reversed;
verbose(2, "#\tmotif numerical value: %llu (%#llx)\n", motifVal, motifVal);
verbose(2, "#\tcomplement numerical value: %llu (%#llx)\n", complementVal, complementVal);
if (motifLen < 5)
    {
    warn("ERROR: motif string must be more than 4 characters\n");
    usage();
    }

findMotif(argv[1]);
return 0;
}
Example #29
0
int main(int argc, char *argv[])
{
struct dyString *dy = NULL;
int startPos = 1;
char *chrom = "chr1";
int chromSize = 0;
int windowSize = 100000;
struct machine *machinePos;
time_t now;
char testTime[100];
char testDate[100];
long elapsedTime = 0;

optionInit(&argc, argv, optionSpecs);

expireSeconds = 300;	/* 5 minutes */
(void) signal(SIGALRM, selfApoptosis);
(void) alarm(expireSeconds);	/* CGI timeout */

quiet = optionExists("quiet");
now = time(NULL);
strftime(testTime, 100, "%H:%M", localtime(&now));
strftime(testDate, 100, "%B %d, %Y", localtime(&now));
if (!quiet)
    printf("%s %s\n", testDate, testTime);

if (argc != 2)
    usage();

srand( (unsigned) time(NULL) );

database = hDefaultDbForGenome(NULL); // default human db

chromHash = loadAllChromInfo();
chromSize = getChromSize(chrom);
startPos = getStartPos(chromSize, windowSize);
if (! quiet)
    printf("%s %s:%d-%d\n\n", database, chrom, startPos, startPos + windowSize);

getMachines(argv[1]);

for (machinePos = machineList; machinePos != NULL; machinePos = machinePos->next)
    {
    dy = newDyString(256);
    dyStringPrintf(dy, "%s/cgi-bin/hgTracks?db=%s&position=%s:%d-%d", machinePos->name, 
                   database, chrom, startPos, startPos + windowSize);
    elapsedTime = hgTracksRandom(dy->string);
    if (quiet)
	{
	printf("%ld\n", elapsedTime);
	}
    else
	{
	if (elapsedTime > 5000)
	    printf("%s %ld <---\n", machinePos->name, elapsedTime);
	else
	    printf("%s %ld\n", machinePos->name, elapsedTime);
	}
    }
if (! quiet)
    printf("----------------------------------\n");

/* free machine list */
return 0;
}
Example #30
0
int main(int argc, char *argv[])
{
  struct lineFile *pf, *prf;
  char filename[64], *pslTable;

  optionInit(&argc, argv, optionSpecs);
  if (argc < 4)
    usage();

  VERBOSE = optionExists("verbose");
  SLOP = optionExists("slop");
  SHORT = optionExists("short");
  LONG = optionExists("long");
  MISMATCH = optionExists("mismatch");
  ORPHAN = optionExists("orphan");
  NORANDOM = optionExists("noRandom");
  NOBIN = optionExists("noBin");
  MIN = optionInt("min",MIN);
  MAX = optionInt("max",MAX);
  TINSERT = optionInt("tInsert",TINSERT);
  HARDMAX = optionInt("hardMax",HARDMAX);
  if (SLOP)
      SLOPVAL = optionInt("slopval",SLOPVAL);
  else
      SLOPVAL = 0;
  NEARTOP = optionFloat("nearTop",NEARTOP);
  NEARTOP = 1 - NEARTOP;
  MIN_ID = optionFloat("minId",MIN_ID);
  MIN_ORPHAN_ID = optionFloat("minOrphanId",MIN_ORPHAN_ID);

  pf = pslFileOpen(argv[1]);
  prf = lineFileOpen(argv[2],TRUE);
  pslTable = cloneString(argv[3]);

  sprintf(filename, "%s.pairs", argv[4]);
  of = mustOpen(filename, "w");
  if (SLOP)
    {
      sprintf(filename, "%s.slop", argv[4]);
      sf = mustOpen(filename, "w");
    }
  if (ORPHAN)
    {
      sprintf(filename, "%s.orphan", argv[4]);
      orf = mustOpen(filename, "w");
    }
  if (MISMATCH)
    {
      sprintf(filename, "%s.mismatch", argv[4]);
      mf = mustOpen(filename, "w");
    }
  if (SHORT)
    {
      sprintf(filename, "%s.short", argv[4]);
      esf = mustOpen(filename, "w");
    }
  if (LONG)
    {
      sprintf(filename, "%s.long", argv[4]);
      elf = mustOpen(filename, "w");
    }
      
  if (VERBOSE)
    printf("Reading pair file\n");
  clones = newHash(23);
  leftNames = newHash(23);
  rightNames = newHash(23);
  readPairFile(prf);
  if (VERBOSE)
    printf("Reading psl file\n");
  readPslFile(pf);
  if (VERBOSE)
    printf("Creating Pairs\n");
  pslPairs();
  if (VERBOSE) 
    printf("Writing to files\n");
  printOut(pslTable);
  
  lineFileClose(&pf);
  lineFileClose(&prf);
  fclose(of);
  if (ORPHAN)
    fclose(orf);
  if (SLOP)
    fclose(sf);
  if (MISMATCH)
    fclose(mf);
  if (SHORT)
    fclose(esf);
  if (LONG)
    fclose(elf);
 
  return 0;
}