Esempio n. 1
0
struct linkedFeatures *lfFromRetroGene(struct ucscRetroInfo *pg)
/* Return a linked feature from a retroGene. */
{
struct linkedFeatures *lf;
struct simpleFeature *sf, *sfList = NULL;
int grayIx = grayInRange(pg->score, 0, 1000);
int *starts = pg->chromStarts, start;
int *sizes = pg->blockSizes;
int blockCount = pg->blockCount, i;

assert(starts != NULL && sizes != NULL && blockCount > 0);

AllocVar(lf);
lf->grayIx = grayIx;
lf->name = cloneString(pg->name);
lf->orientation = orientFromChar(pg->strand[0]);
for (i=0; i<blockCount; ++i)
    {
    AllocVar(sf);
    start = starts[i] + pg->chromStart;
    sf->start = start;
    sf->end = start + sizes[i];
    sf->grayIx = grayIx;
    slAddHead(&sfList, sf);
    }
slReverse(&sfList);
lf->components = sfList;
linkedFeaturesBoundsAndGrays(lf);
lf->tallStart = pg->thickStart;
lf->tallEnd = pg->thickEnd;
lf->extra = pg;
return lf;
}
struct linkedFeatures *lfFromBed6(struct codeBlast *bed, int scoreMin, 
				  int scoreMax)
/* Return a linked feature from a (full) bed. */
{
struct linkedFeatures *lf;
struct simpleFeature *sf;
int grayIx = grayInRange(bed->score, scoreMin, scoreMax);
AllocVar(lf);
lf->grayIx = grayIx;
lf->name = cloneString(bed->name);
lf->orientation = orientFromChar(bed->strand[0]);
AllocVar(sf);
sf->start = bed->chromStart;
sf->end = bed->chromEnd;
sf->grayIx = grayIx;
lf->components = sf;
linkedFeaturesBoundsAndGrays(lf);
lf->tallStart = bed->chromStart;
lf->tallEnd = bed->chromEnd;
return lf;
}
struct linkedFeatures *lfFromSample(struct sample *sample)
	/* Return a linked feature from a full sample (wiggle) track. */
{
	struct linkedFeatures *lf;
	struct simpleFeature *sf, *sfList = NULL;
	int grayIx = grayInRange(sample->score, 0, 1000);
	int start, i;
	unsigned *X = sample->samplePosition;
	int *Y = sample->sampleHeight;
	unsigned sampleCount = sample->sampleCount;

	assert(X != NULL && Y != NULL && sampleCount > 0);
	AllocVar(lf);
	lf->grayIx = grayIx;
	lf->name = cloneString(sample->name);
	lf->orientation = orientFromChar(sample->strand[0]);

	for (i=0; i<sampleCount; ++i)
	{
		AllocVar(sf);
		start = X[i] + sample->chromStart;
		sf->start = start;

		if( Y[i] < 0 )      /*hack for negative values not loading correctly*/
			sf->end = start;
		else if( Y[i] == 0 )
			sf->end = start + 1;
		else
			sf->end = start + Y[i];

		sf->grayIx = grayIx;
		slAddHead(&sfList, sf);
	}
	slReverse(&sfList);
	lf->components = sfList;
	linkedFeaturesBoundsAndGrays(lf);
	lf->start = sample->chromStart;
	lf->end = sample->chromEnd;
	return lf;
}