Exemplo n.º 1
0
std::wstring OverwriteDialog::execute(ToonzScene *scene, const TFilePath &srcLevelPath, bool multiload)
{
	TFilePath levelPath = srcLevelPath;
	TFilePath actualLevelPath = scene->decodeFilePath(levelPath);
	if (!TSystem::doesExistFileOrLevel(actualLevelPath))
		return levelPath.getWideName();

	if (m_applyToAll && m_choice == RENAME) {
		levelPath = addSuffix(levelPath);
		actualLevelPath = scene->decodeFilePath(levelPath);
	}
	if (m_applyToAll) {
		if (m_choice != RENAME || !TSystem::doesExistFileOrLevel(actualLevelPath))
			return levelPath.getWideName();
	}

	m_label->setText(tr("File %1 already exists.\nWhat do you want to do?").arg(toQString(levelPath)));
	// find a compatible suffix
	if (TSystem::doesExistFileOrLevel(actualLevelPath)) {
		int i = 0;
		while (TSystem::doesExistFileOrLevel(scene->decodeFilePath(addSuffix(srcLevelPath)))) {
			m_suffix->setText("_" + QString::number(++i));
		}
	}

	if (multiload)
		m_okToAllBtn->show();
	else
		m_okToAllBtn->hide();

	// there could be a WaitCursor cursor
	QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
	raise();
	exec();
	QApplication::restoreOverrideCursor();

	if (m_rename->isChecked()) {
		if (m_suffix->text() == "") {
			MsgBox(WARNING, tr("The suffix field is empty. Please specify a suffix."));
			return execute(scene, srcLevelPath, multiload);
		}
		levelPath = addSuffix(srcLevelPath);
		actualLevelPath = scene->decodeFilePath(levelPath);
		if (TSystem::doesExistFileOrLevel(actualLevelPath)) {
			MsgBox(WARNING, tr("File %1 exists as well; please choose a different suffix.").arg(toQString(levelPath)));
			return execute(scene, srcLevelPath, multiload);
		}
		m_choice = RENAME;
	} else if (m_overwrite->isChecked())
		m_choice = OVERWRITE;
	else {
		assert(m_keep->isChecked());
		m_choice = KEEP_OLD;
	}

	return levelPath.getWideName();
}
Exemplo n.º 2
0
int main(int argc, char* argv[])
{
    /* Start the timer */
    uglyTime(NULL);
    printf("\nQUBIC %.1f: greedy biclustering (compiled "__DATE__" "__TIME__")\n\n", VER);
    rows = cols = 0;

    /* get the program options defined in get_options.c */
    get_options(argc, argv);

    /*get the size of input expression matrix*/
    get_matrix_size(po->FP);
    progress("File %s contains %d genes by %d conditions", po -> FN, rows, cols);
    if (rows < 3 || cols < 3)
    {
        /*neither rows number nor cols number can be too small*/
        errAbort("Not enough genes or conditions to make inference");
    }
    genes = alloc2c(rows, LABEL_LEN);
    conds = alloc2c(cols, LABEL_LEN);

    /* Read in the gene names and condition names */
    read_labels(po -> FP);

    /* Read in the expression data */
    if (po->IS_DISCRETE)
        read_discrete(po -> FP);
    else
    {
        read_continuous(po -> FP);

        /* formatting rules */
        discretize(addSuffix(po->FN, ".rules"));
    }
    fclose(po->FP);

    /*we can do expansion by activate po->IS_SWITCH*/
    if (po->IS_SWITCH)
    {
        read_and_solve_blocks(po->FB, addSuffix(po->BN, ".expansion"));
    }
    else
    {
        /* formatted file */
        write_imported(addSuffix(po->FN, ".chars"));

        /* the file that stores all blocks */
        make_graph(addSuffix(po->FN, ".blocks"));
    }/* end of main else */
    free(po);
    return 0;
}
void addSuffix(struct node *root,char input[],int label,int start,int end,int *ResultBeg,int *ResultEnd,int *ResultLen,int path)
{
	int index,found=0,incrementStart,i;
	for(index=0;index<root->ChildrenNumber;index++)
	{
		if(input[root->Children[index].start]==input[start])
		{
			found=1;
			break;
		}
	}
	if(found==1)
	{
		incrementStart=root->Children[index].start;
		while(input[incrementStart]==input[start]&&incrementStart<root->Children[index].end)
		{
			incrementStart++;
			start++;
			label++;
		}
		if(incrementStart<root->Children[index].end)
		{
			addSuffix(&root->Children[index],input,label,incrementStart,root->Children[index].end,ResultBeg,ResultEnd,ResultLen,1);
			root->Children[index].end=incrementStart;
			for(i=0;i<root->Children[index].ChildrenNumber;i++)
				root->Children[index].Children[i].start=incrementStart;
		}
		if(start<end)
			addSuffix(&root->Children[index],input,label,start,end,ResultBeg,ResultEnd,ResultLen,path);
		if(path==2&&root->Children[index].path==1)
		{
			if(*ResultLen<label)
			{
				*ResultBeg=incrementStart-label;
				*ResultEnd=incrementStart;
				*ResultLen=label;
			}
		}
	}
	else
	{
		root->ChildrenNumber++;
		root->Children=(struct node *)realloc(root->Children,(root->ChildrenNumber)*sizeof(struct node));
		root->Children[root->ChildrenNumber-1].Children=NULL;
		root->Children[root->ChildrenNumber-1].ChildrenNumber=0;
		root->Children[root->ChildrenNumber-1].start=start;
		root->Children[root->ChildrenNumber-1].end=end;
		root->Children[root->ChildrenNumber-1].path=path;
	}
}
char *getResult(char input[],int length1,int length2)
{
	struct node root={NULL,0,0,0};
	int i,ResultBeg=0,ResultEnd=0,ResultLen=0;
	char *output;
	for(i=0;i<length1;i++)
		addSuffix(&root,input,0,i,length1,&ResultBeg,&ResultEnd,&ResultLen,1);
	for(i=length1;i<length1+length2;i++)
		addSuffix(&root,input,0,i,length1+length2,&ResultBeg,&ResultEnd,&ResultLen,2);
	output=(char *)malloc((ResultLen+1)*sizeof(char));
	for(i=ResultBeg;i<ResultEnd;i++)
		output[i-ResultBeg]=input[i];
	output[i-ResultBeg]='\0';
	return output;
}
const String NameManager::makeResourceName(bool isOrganic) {
	int nameLength = 4 + System::random(6);
	String name;

	do {
		name = "";

		if (nameLength > 5 && System::random(2) == 1) {
			addPrefix(name, isOrganic);
		}

		if(name.length() < 2) {
			name += chooseNextLetter(' ', ' ');
			name += chooseNextLetter(name[0], ' ');
		}

		assert(name.length() != 0);

		while (name.length() < nameLength)
				name += chooseNextLetter(name[name.length() - 1], name[name.length() - 2]);

		if (!isVowel(name[name.length() - 1]) && name[name.length() - 1] != 'q' && System::random(1) == 1 )
			addSuffix(name, isOrganic);

		name[0] = Character::toUpperCase(name[0]);

	} while (validateName(name, -1) != NameManagerResult::ACCEPTED);

	return name;
}
void readGbZfin (struct lineFile *gzf)
/* Read in Genbank IDs and ZFIN IDs */
{
char *words[24], *acc = NULL, addAcc[20], *name = NULL, *newAcc = NULL;
struct zfin *gz = NULL;

while (lineFileChopTab(gzf, words) )
    {
    /* copy name and change to upper case */
    name = cloneString(words[1]);
    touppers(name);
    if ((gz = hashFindVal(zfinMarkerHash, name) ) != NULL)
        {
        acc = gz->acc;
        /* add new accession */
        if (acc != NULL)
            {
            safef(addAcc, sizeof(addAcc), ",%s", words[2]);
            newAcc = addSuffix(acc, addAcc);
            gz->acc = cloneString(newAcc);
            }
        else
            gz->acc = cloneString(words[2]);
        /* add structure back to hash */
        addHashElUnique(zfinMarkerHash, name, gz);
        }
    else 
        fprintf(stderr, "The marker, %s, with ZFIN ID, %s, is not found in the mapping panels \n", words[1], words[0]);
    }
}
Exemplo n.º 7
0
    virtual bool processRecord( PreProcData* pre_proc_data,
            const Record* record ) {

        	transWord(pre_proc_data->m_raw_bracket_vec, resource_->transWord);

        	vector<string>::iterator it = pre_proc_data->m_raw_bracket_vec.begin();
        	vector<string> temp;
        	for (; it != pre_proc_data->m_raw_bracket_vec.end(); ++it) {
        		if (len(*it) > 3) {
        			tools_->m_wordsplit->split(*it, temp);
        		} else {
        			temp.push_back(*it);
        		}
        		pre_proc_data->m_bracket_vec.insert(pre_proc_data->m_bracket_vec.end(),
        				temp.begin(), temp.end());
        	}

        	if (len(pre_proc_data->m_accurate_keyword) > 3) {
        		tools_->m_wordsplit->split(pre_proc_data->m_accurate_keyword,
        				pre_proc_data->m_accurate_kw_vec);
        	} else {
        		pre_proc_data->m_accurate_kw_vec.push_back(
        				pre_proc_data->m_accurate_keyword);
        	}

        	// 增加前缀
        	addPrefix(pre_proc_data->m_name_vec, resource_->needPrefix);
        	addPrefix(pre_proc_data->m_bracket_vec, resource_->needPrefix);

        	// 增加量词
        	// 处理空港科技大厦a 中的a,扩展为a座
        	addSuffix(pre_proc_data);

        	// 处理容易引起同义词歧义的词
        	transSpecWord(pre_proc_data);

        	// 处理结尾的店
        	if (pre_proc_data->m_name_vec.size() > 2) {
        		it = pre_proc_data->m_name_vec.end() - 1;
        		if (*it == "店") {
        			pre_proc_data->m_name_vec.erase(it);
        		}
        	}

        	if (pre_proc_data->m_bracket_vec.size() > 1) {
        		it = pre_proc_data->m_bracket_vec.end() - 1;
        		if (*it == "店") {
        			pre_proc_data->m_bracket_vec.erase(it);
        		}
        	}

        
        return true;
    };
Exemplo n.º 8
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 = addSuffix(tempDir,"inputList0-");
    makeTempName(&tempName, inp0, ".tmp");
    freez(&inp0);
    inp0 = cloneString(tempName.forCgi);
    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);
    freez(&inp0);	    
    }
return 0;
}
void *addExtensionAndSearch(char *name, struct hash *hash, boolean alias)
{
char *addName = NULL, *newName = NULL, *nameLower = NULL;
void *result = NULL;
boolean found = FALSE;
int i;

addName = cloneString(name);
if (alias)
    {
    nameLower = cloneString(name);
    touppers(addName);
    }

for (i = 0; (i < NUMEXT) && (!found); i++)
    {
    newName = NULL;
    newName = addSuffix(addName, extensions[i]);
    /* for alias, check the lower case name */
    if (alias && ((result = hashFindVal(hash, newName)) != NULL) )
        found = TRUE;
    /* change name to upper case and check in hash */
    touppers(newName);
    if (!found && (result = hashFindVal(hash, newName)) != NULL)
       found = TRUE;
    else if (!found)
        {
        /* remove the suffix after the last '.' and compare */
        chopSuffix(addName);
        if (alias)
            chopSuffix(nameLower);
        if (!sameString(name, addName) && 
              (result = hashFindVal(hash, addName)) != NULL)
            found = TRUE; 
        else if (alias)  /* check also lower case name */
            {
            if (!sameString(name, nameLower) &&
                (result = hashFindVal(hash, nameLower)) != NULL)
                found = TRUE; 
            }
        }
    }
    if (found)
        return result;
    else
        return NULL;
}
Exemplo n.º 10
0
void checkBbiOrphans(char *database, char *composite, struct hash *allBbiNames)
/* check for orphans in the download directory. */
{
verbose(1, "-----------------------------------------------------------------\n");
verbose(1, "Checking that <composite>* files in the bbi dir exist in metaDb\n");
verbose(1, "-----------------------------------------------------------------\n");
char buffer[10 * 1024];
char fullPath[10 * 1024];
safef(buffer, sizeof buffer, "/gbdb/%s/bbi", database);
struct slName *list = listDir(buffer, addSuffix(composite,"*")), *el;
for(el=list;el;el=el->next)
    {
    safef(fullPath, sizeof fullPath, "%s/%s", buffer, el->name);
    if (!hashLookup(allBbiNames, fullPath))
	{
	warn("orphan bbi file %s/%s not found in metaDb\n", buffer, el->name);
	}
    }
}
void readZfinAliases(struct lineFile *zaf)
/* read in ZFIN IDs and old marker names (aliases), there can be */
/* more than one alias per ID. add to zfin aliases in zfinMarkerHash */
/* and to the list of aliases in the aliasHash */
{
char *words[4], *name = NULL, *zfId = NULL, *alias = NULL, *al = NULL, addAlias[64], *newAlias = NULL;
struct zfin *zf = NULL;
char **aliasArray;

while (lineFileChopTab(zaf, words))
    {
    /* need to add to a hash keyed by ZFIN ID */
    if (words[0] != NULL)
        {
        /* find current name by searching on ZFIN ID in zfinIdHash */
        zfId = cloneString(words[0]);
        al = cloneString(words[1]);
        name = hashFindVal(zfinIdHash, zfId);
        if (name != NULL)
            {
            /* names are in lower case so change to upper to use as hash key */
            touppers(name); 
            zf = hashFindVal(zfinMarkerHash, name);
            if (zf != NULL)
                {
                if (zf->zfAlias != NULL)
                    {
                    alias = cloneString(zf->zfAlias);      
                    safef(addAlias, sizeof(addAlias), ",%s", al);
                    newAlias = addSuffix(alias, addAlias);
                    zf->zfAlias = cloneString(newAlias);
                    }
                else
                    zf->zfAlias = cloneString(al);
                /* add back to zfinMarkerHash using current name as key */
                addHashElUnique(zfinMarkerHash, name, zf);
                }
            }
        }
    }
}
Exemplo n.º 12
0
char * convertEpsToPdf(char *epsFile) 
/* Convert EPS to PDF and return filename, or NULL if failure. */
{
char *pdfTmpName = NULL, *pdfName=NULL;
char cmdBuffer[2048];
int sysVal = 0;
struct lineFile *lf = NULL;
char *line;
int lineSize=0;
float width=0, height=0;
pdfTmpName = cloneString(epsFile);

/* Get the dimensions of bounding box. */
lf = lineFileOpen(epsFile, TRUE);
while(lineFileNext(lf, &line, &lineSize)) 
    {
    if(strstr( line, "BoundingBox:")) 
	{
	char *words[5];
	chopLine(line, words);
	width = atof(words[3]);
	height = atof(words[4]);
	break;
	}
    }
lineFileClose(&lf);
	
/* Do conversion. */
chopSuffix(pdfTmpName);
pdfName = addSuffix(pdfTmpName, ".pdf");
safef(cmdBuffer, sizeof(cmdBuffer), "ps2pdf -dDEVICEWIDTHPOINTS=%d -dDEVICEHEIGHTPOINTS=%d %s %s", 
      round(width), round(height), epsFile, pdfName);
sysVal = system(cmdBuffer);
if(sysVal != 0)
    freez(&pdfName);
freez(&pdfTmpName);
return pdfName;
}
Exemplo n.º 13
0
static void handleCID(char **html, char *ctMain)
/* Handle CID replacements if needed */
{
if (optionExists("cid") && ctMain && sameWord(ctMain,"text/html"))
    {
    struct hashEl *el, *list = hashElListHash(cidHash);
    for(el=list;el;el=el->next)
	{
	char *cid=addSuffix("cid:",el->name);
	if (stringIn(cid,*html))
	    {
	    char *new = replaceChars(*html, cid, el->val);
	    freez(html);
	    *html = new;
	    }
	freez(&cid);
	// support for content-location
	if (stringIn(el->name,*html))
	    {
	    char *new = replaceChars(*html, el->name, el->val);
	    freez(html);
	    *html = new;
	    }
	}
void wigAsciiToBinary( int argc, char *argv[] )
{
int i = 0;				/* general purpose int counter	*/
struct lineFile *lf;			/* for line file utilities	*/
char * fileName;			/* the basename of the input file */
char *line = (char *) NULL;		/* to receive data input line	*/
char *words[4];				/* to split data input line	*/
int wordCount = 0;			/* result of split	*/
int validLines = 0;			/* counting only lines with data */
unsigned long long previousOffset = 0;	/* for data missing detection */
double dataValue = 0.0;				/* from data input	*/
char *wigfile = (char *) NULL;	/*	file name of wiggle database file */
boolean firstInChrom;		/* Is this the first line in chromosome? */

/*	for each input data file	*/
for (i = 1; i < argc; ++i)
    {
    verbose(2, "translating file: %s\n", argv[i]);

    fileName = basename(argv[i]);
    if (name)		/*	Is the name of this feature specified ?	*/
	{
	safef( featureName, sizeof(featureName) - 1, "%s", name);
	}
    if (chrom)		/*	Is the chrom name specified ? */
	{
	chromName = cloneString(chrom);
	if (! name)	/*	that names the feature too if not already */
	    safef( featureName, sizeof(featureName) - 1, "%s", chrom);
	}
    /*	Name mangling to determine output file name */
    if (wibFile)	/*	when specified, simply use it	*/
	{
	binfile = addSuffix(wibFile, ".wib");
	wigfile = addSuffix(wibFile, ".wig");
	} else {	/*	not specified, construct from input names */
	if (startsWith("chr",fileName))
	    {
	    char *tmpString;
	    tmpString = cloneString(fileName);
	    chopSuffix(tmpString);
	    binfile = addSuffix(tmpString, ".wib");
	    wigfile = addSuffix(tmpString, ".wig");
	    if (! chrom)	/*	if not already taken care of	*/
		chromName = cloneString(tmpString);
	    if (! name && ! chrom)	/*	if not already done	*/
		safef(featureName, sizeof(featureName) - 1, "%s", tmpString);
	    freeMem(tmpString);
	    } else {
	    errAbort("Can not determine output file name, no -wibFile specified\n");
	    }
	}

    verbose(2, "output files: %s, %s\n", binfile, wigfile);
    validLines = 0;	/* to count only lines with data */
    rowCount = 0;	/* to count rows output */
    bincount = 0;	/* to count up to binsize	*/
    fileOffset = 0;	/* current location within binary data file	*/
    fileOffsetBegin = 0;/* location in binary data file where this bin starts*/
    firstInChrom = TRUE;
    freeMem(data_values);
    freeMem(validData);
    data_values =  needMem( (size_t) (binsize * sizeof(double)));
    validData = needMem( (size_t) (binsize * sizeof(unsigned char)));
    overallLowerLimit = 1.0e+300;	/* for the complete set of data */
    overallUpperLimit = -1.0e+300;	/* for the complete set of data */
    binout = mustOpen(binfile,"w");	/*	binary data file	*/
    wigout = mustOpen(wigfile,"w");	/*	table row definition file */
    lf = lineFileOpen(argv[i], TRUE);	/*	input file	*/
    while (lineFileNextReal(lf, &line))
	{
	boolean readingFrameSlipped;
	char *valEnd;
	char *val;
	++validLines;
	wordCount = chopByWhite(line, words, ArraySize(words));
	if (wordCount == 1)
	    {
	    Offset += 1;
	    val = words[0];
	    }
	else if (wordCount == 2)
	    {
	    Offset = atoll(words[0]) - 1;
	    val = words[1];
	    }
	else if (wordCount == 3)
	    {
	    char *newChrom = words[0];
	    boolean sameChrom = (chromName == NULL || sameString(chromName, newChrom));
	    Offset = atoll(words[1]) - 1;
	    val = words[2];
	    if (!sameChrom)
		{
		output_row();
		firstInChrom = TRUE;
		freez(&chromName);
		}
	    if (chromName == NULL)
		chromName = cloneString(newChrom);
	    }
	else
	    {
	    val = NULL;
	    badFormat(lf);
	    }
	if (Offset < 0)
	    errAbort("Illegal offset %llu at line %d of %s", Offset+1, lf->lineIx,
	    	lf->fileName);
	dataValue = strtod(val, &valEnd);
	if(trimVals)
	    {
	    dataValue = max(minVal, dataValue);
	    dataValue = min(maxVal, dataValue);
	    }
	if ((*val == '\0') || (*valEnd != '\0'))
	    errAbort("Not a valid float at line %d: %s\n", lf->lineIx, val);
	/* see if this is the first time through, establish chromStart 	*/
	if (firstInChrom) {
	    chromStart = Offset;
	    verbose(2, "first offset: %llu\n", chromStart);
	}
	else if (!firstInChrom && (Offset <= previousOffset))
	    errAbort("ERROR: chrom positions not in order. line %d of %s\n"
	             "previous: %llu >= %llu <-current", 
		     lf->lineIx, lf->fileName, previousOffset+1, Offset+1);
	/* if we are working on a zoom level and the data is not exactly
	 * spaced according to the span, then we need to put each value
	 * in its own row in order to keep positioning correct for these
	 * data values.  The number of skipped bases has to be an even
	 * multiple of dataSpan
	 */
	readingFrameSlipped = FALSE;
	if (!firstInChrom && (dataSpan > 1))
	    {
	    int skippedBases;
	    int spansSkipped;
	    skippedBases = Offset - previousOffset;
	    spansSkipped = skippedBases / dataSpan;
	    if ((spansSkipped * dataSpan) != skippedBases)
		readingFrameSlipped = TRUE;
	    }
	if (readingFrameSlipped)
	    {
	    verbose(2, "data not spanning %llu bases, prev: %llu, this: %llu, at line: %d\n", dataSpan, previousOffset, Offset, lf->lineIx);
	    output_row();
	    chromStart = Offset;	/*	a full reset here	*/
	    }
	/*	Check to see if data is being skipped	*/
	else if ( (!firstInChrom) && (Offset > (previousOffset + dataSpan)) )
	    {
	    unsigned long long off;
	    unsigned long long fillSize;	/* number of bytes */
	    verbose(2, "missing data offsets: %llu - %llu\n",
		    previousOffset+1,Offset-1);
	    /*	If we are just going to fill the rest of this bin with
	     *  no data, then may as well stop here.  No need to fill
	     *  it with nothing.
	     */
	    fillSize = (Offset - (previousOffset + dataSpan)) / dataSpan;
	    verbose(2, "filling NO_DATA for %llu bytes at bincount: %llu\n", fillSize, bincount);
	    if (fillSize + bincount >= binsize)
		{
		verbose(2, "completing a bin due to  NO_DATA for %llu bytes, only %llu - %llu = %llu to go\n", fillSize, binsize, bincount, binsize - bincount);
		verbose(2, "Offset: %llu, previousOffset: %llu\n",
			Offset, previousOffset);
		output_row();
		chromStart = Offset;	/*	a full reset here	*/
	    } else {
		fillSize = 0;
		/*	fill missing data with NO_DATA indication	*/
		for (off = previousOffset + dataSpan; off < Offset;
			off += dataSpan)
		    {
		    ++fillSize;
		    ++fileOffset;
		    ++bincount;	/*	count scores in this bin */
		    if (bincount >= binsize) break;
		    }
		verbose(2, "filled NO_DATA for %llu bytes at bincount: %llu\n", fillSize, bincount);
		/*	If that finished off this bin, output it
		 *	This most likely should not happen here.  The
		 *	check above: if (fillSize + bincount >= binsize) 
		 *	should have caught this case already.
		 */
		    if (bincount >= binsize)
			{
			output_row();
			chromStart = Offset;	/* a full reset here */
			}
	        }
	    }
	/*	With perhaps the missing data taken care of, back to the
	 *	real data.
	 */
	data_values[bincount] = dataValue;
	validData[bincount] = TRUE;
	++fileOffset;
	++bincount;	/*	count scores in this bin */
	/*	Is it time to output a row definition ? */
	if (bincount >= binsize)
	    {
	    output_row();
	    }
	previousOffset = Offset;
	firstInChrom = FALSE;
        }	/*	reading file input loop end	*/
    /*	Done with input file, any data points left in this bin ?	*/
    if (bincount)
	{
	output_row();
	}
    verbose(2, "fini: %s, read %d lines, table rows: %llu, data bytes: %lld\n",
	    argv[i], lf->lineIx, rowCount, fileOffset);
    verbose(1, "data limits: [%g:%g], range: %g\n", 
	overallLowerLimit, overallUpperLimit,
	overallUpperLimit - overallLowerLimit);
    lineFileClose(&lf);
    fclose(binout);
    fclose(wigout);
    freeMem(binfile);
    freeMem(wigfile);
    freeMem(chromName);
    binfile = (char *) NULL;
    wigfile = (char *) NULL;
    chromName = (char *) NULL;
    }
return;
}
Exemplo n.º 15
0
OverwriteDialog::Resolution OverwriteDialog::execute(TFilePath &filePath,
                                                     const ExistsFunc &exists,
                                                     Resolution acceptedRes,
                                                     Flags flags) {
  typedef QRadioButton *OverwriteDialog::*RadioRes;
  static const RadioRes radios[3] = {&OverwriteDialog::m_keep,
                                     &OverwriteDialog::m_overwrite,
                                     &OverwriteDialog::m_rename};

  struct locals {
    static inline int idx(Resolution res) {
      int r = 0;
      while (r < 3 && !(res & (1 << r))) ++r;
      return r;
    }
  };

  TFilePath writePath = filePath;

  // Deal with the case where "Apply To All" was already clicked
  if (m_applyToAll && (m_choice & acceptedRes)) {
    if (m_choice == RENAME) writePath = addSuffix(writePath);

    if (m_choice != RENAME || !exists(writePath))
      return filePath = writePath, m_choice;
  }

  reset();

  // Find a compatible suffix to be displayed
  if (acceptedRes & RENAME)
    for (int i = 1; exists(addSuffix(filePath)); ++i)
      m_suffix->setText("_" + QString::number(i));

  // Show the various dialog components as specified
  m_overwrite->setVisible(acceptedRes & OVERWRITE);
  m_keep->setVisible(acceptedRes & KEEP_OLD);
  m_rename->setVisible(acceptedRes & RENAME);
  m_suffix->setVisible(acceptedRes & RENAME);
  m_okToAllBtn->setVisible(flags & APPLY_TO_ALL_FLAG);

  // Ensure that there is a checked button among the accepted resolutions
  for (int r = 0; r < 3; ++r)
    if ((this->*radios[r])->isChecked()) {
      if (!(acceptedRes & (1 << r)))
        (this->*radios[locals::idx(acceptedRes)])->setChecked(true);
      break;
    }

  // Prompt the dialog to let the user decide resolution
  while (true) {
    // Build text to be displayed
    m_label->setText(exists.conflictString(writePath));

    // Execute dialog
    int retCode = exec();

    m_choice = (retCode == QDialog::Rejected)
                   ? CANCELED
                   : m_overwrite->isChecked()
                         ? OVERWRITE
                         : m_rename->isChecked() ? RENAME : KEEP_OLD;

    if (m_choice == RENAME) {
      if (exists(writePath = addSuffix(filePath))) continue;
    }

    break;
  }

  return filePath = writePath, m_choice;
}
Exemplo n.º 16
0
void checkMetaFiles(struct mdbObj *mdbObj, char *downDir, struct hash *allNames)
{
verbose(1, "----------------------------------------------\n");
verbose(1, "Checking that files specified in metaDb exist in download dir\n");
verbose(1, "----------------------------------------------\n");
for(; mdbObj != NULL; mdbObj=mdbObj->next)
    {
    struct mdbVar *mdbVar = hashFindVal(mdbObj->varHash, "objType");
    if (mdbVar == NULL)
        {
        warn("objType not found in object %s", mdbObj->obj);
        continue;
        }
    if (sameString(mdbVar->val, "composite"))  // skip objType composite
        continue;

    mdbObj->deleteThis = FALSE;
    mdbVar = hashFindVal(mdbObj->varHash, "composite");

    if (mdbVar == NULL)
        {
        warn("composite not found in object %s", mdbObj->obj);
        continue;
        }
    // char *composite = mdbVar->val;

    mdbVar = hashFindVal(mdbObj->varHash, "fileName");

    if (mdbVar == NULL)
        {
        mdbObj->deleteThis = TRUE;
        warn("fileName not found in object %s", mdbObj->obj);
        continue;
        }

    char *fileName = mdbVar->val;
    char buffer[10 * 1024];

    struct hash *bamNames = hashNew(8);
    struct slName *list = slNameListFromString(fileName, ','), *el;
    for(el=list; el; el=el->next)
	{
	if (hashLookup(allNames, el->name))
	    {
	    warn("duplicate fileName entry: %s", el->name);
	    }
	else
	    {
	    hashAdd(allNames, el->name, NULL);
	    }
        if (endsWith(el->name,".bam"))
	    {
	    hashAdd(bamNames, el->name, NULL);
	    }
        if (endsWith(el->name,".bam.bai"))
	    {
	    el->name[strlen(el->name)-4] = 0;
	    struct hashEl *hel = hashLookup(bamNames, el->name);
	    el->name[strlen(el->name)] = '.';
	    if (hel == NULL)
		{
		warn(".bam.bai without corresponding .bam: %s", el->name);
		}
	    else
		{
		hel->val = (void *)1;
		}
	    }
	}


    // see if we have to add any .bam.bai to the list 
    for(el=list; el; el=el->next)
	{
        if (endsWith(el->name,".bam"))
	    {
	    struct hashEl *hel = hashLookup(bamNames, el->name);
	    if (hel->val == NULL)
		{  // we have to add a .bam.bai to the list 
		char *bambai = addSuffix(el->name, ".bai");
		warn(".bam.bai not found for corresponding .bam in meta.fileName: %s", el->name);
		slNameAddTail(&list, bambai);		
		if (hashLookup(allNames, bambai))
		    {
		    warn("duplicate fileName entry: %s", bambai);
		    }
		else
		    hashAdd(allNames, bambai, NULL);		
		}
	    }
	}

    // make sure the files are there
    for(el=list; el; el=el->next)
	{
	if (!startsWith(mdbObj->obj, el->name))
	    {
	    warn("fileName %s does not start with object name %s", el->name, mdbObj->obj);
	    }

	safef(buffer, sizeof buffer, "%s/%s", downDir, el->name);

	verbose(2, "checking for fileExists %s\n", buffer);
	if (!fileExists(buffer))
	    {
	    mdbObj->deleteThis = TRUE;
	    warn("metaDb file %s not found in download dir %s",buffer, downDir);
	    }
	}
    }
}
Exemplo n.º 17
0
QString QgsMeshCalculatorDialog::outputFile() const
{
  QString ret = mOutputDatasetFileWidget->filePath();
  return addSuffix( ret );
}
Exemplo n.º 18
0
void gsSendToDM()
/* upload the generated file to DM */
{
// This is now run via fork/exec as a separate background process.

char *trashFileName = cartUsualString(cart, "gsTemp", "");
char *fileName = cartUsualString(cart, hgtaOutFileName, "");

// adjust upload name based on compression and existing extension
char *compressType = cartUsualString(cart, hgtaCompressType, textOutCompressNone);

if (!(isEmpty(compressType) || sameWord(compressType, textOutCompressNone)))
    {
    char *suffix = getCompressSuffix(compressType);
    if (!endsWith(fileName, suffix))
	fileName = addSuffix(fileName, suffix);
    }


off_t fSize = fileSize(trashFileName);


char *gsToken = cartUsualString(cart, "gsToken", NULL);

char *contentType = "text/plain";  // some examples show applicaton/octet-stream

char *persDir = getGsPersonalDirectory(gsToken);
char *user = strrchr(persDir,'/');
++user;

char nicenumber[1024]="";
sprintWithGreekByte(nicenumber, sizeof(nicenumber), fSize);

htmlOpen("Uploading Output to GenomeSpace");

printf("Name: %s<br>\n", fileName);
printf("Size: %s<br>\n", nicenumber);
printf("Progress: 0%%<br>\n");
printf("You can remain on this page and monitor upload progress.<br>\n");
printf("Otherwise, feel free to continue working, and your output will appear in GenomeSpace when the upload is complete.<br>\n");
printf("<br>\n");
printf("<FORM ACTION=\"/cgi-bin/hgTables\" METHOD=GET>\n"
        "<INPUT TYPE=SUBMIT NAME=\"%s\" VALUE=\"Back\" >\n"
	"<INPUT TYPE=SUBMIT NAME=\"Refresh\" VALUE=\"Refresh\" onclick='window.location=window.location;return false;' >"
	"</FORM>\n"
	, hgtaDoMainPage);
puts("<script type=\"text/JavaScript\">");
puts("<!--");
puts("setTimeout(\"location = location;\",5000);");
puts("-->");
puts("</script>");

htmlClose();
fflush(stdout);

// MD5 COMPUTE
unsigned char md5[16];       /* Keep the md5 checksum here. */
md5ForFile(trashFileName,md5);
char *hexMd5 = md5ToHex(md5);
char *base64Md5 = base64Encode((char*)md5, 16);


char *s3UploadUrl = gsUploadUrl(gsToken, user, fileName, fSize, base64Md5, contentType);

char *s3Response = gsS3Upload(s3UploadUrl, trashFileName, fSize, base64Md5, hexMd5, contentType, TRUE, fileName);
    
if (sameString(s3Response,""))
    {
    // Reset global flags before drawing brand new page
    webHeadAlreadyOutputed = FALSE;
    webInTextMode = FALSE;
    includedResourceFiles = NULL;
    htmlWarnBoxSetUpAlready=FALSE;
    htmlOpen("Uploaded Output to GenomeSpace");

    printf("Name: %s<br>\n", fileName);
    printf("Size: %s<br>\n", nicenumber);
    printf("Output has been successfully uploaded.<br>\n");
    printf("<br>");
    printf("<FORM ACTION=\"/cgi-bin/hgTables\" METHOD=GET>\n"
        "<INPUT TYPE=SUBMIT NAME=\"%s\" VALUE=\"Back\" ></FORM>\n"
	, hgtaDoMainPage);
    htmlClose();
    fflush(stdout);
    }

//printf("s3UploadUrl [%s]", s3UploadUrl);
//printf("<br>");
//printf("s3Response [%s]", s3Response);
//printf("<br>");

exit(0);  // CANNOT RETURN

}