Esempio n. 1
2
void MudGameView::onSelectProfile()
{
    Profile current(m_manager.getProfile());
    SelectProfileDlg dlg(current);
    if (dlg.DoModal() != IDOK)
        return;
    const ProfileData& profile = dlg.getProfile();
    if (!profile.create_new)
    {
        // load profile
        if (loadProfile(profile.profile) && profile.create_link)
            createLink(profile.profile);
        return;
    }
    if (!profile.copy_from_src)
    {
        if (!profile.create_empty)
        {
            // new profile from resources
            Profile src; src.group = profile.profile.group; src.name = L"player";
            if (copyProfile(true, profile.profile, src) && profile.create_link)
                createLink(profile.profile);
            return;
        }
        // new empty profile
        if (newProfile(profile.profile) && profile.create_link)
            createLink(profile.profile);
        return;
    }
    // new profile and copy from src profile
    if (copyProfile(false, profile.profile, profile.src) && profile.create_link)
        createLink(profile.profile);
}
Esempio n. 2
0
static
void printCountmatAndSites(Profile *countmat, int *sites, double *scorePerSite, Dataset *data)
{
	updateCountmatFromSites(countmat, sites, data);
	Profile *profile = initProfile(countmat->span, countmat->maxspan);
	copyProfile(profile, countmat);

	//normalize "profile"
	for(int x = 0; x < countmat->span; x++) {
		if( !profile->isgap[x]) {
			double sum = 0.0;
			for(int y = 0; y < NUMALPHAS; y++) {
				sum += profile->mat[x][y];
			}
			for(int y = 0; y < NUMALPHAS; y++) {
				profile->mat[x][y] /= sum;
			}
		}
	}

	/* print profile */
	printf("Motif profile generated from sites:\n"); 
	printProfile(stdout, profile);

	printf("Flanking regions:\n"); 
	printFlankingRegionProfile(stdout, sites, countmat->span, data);


	/* NOW, PRINT CONSENSUS MOTIF */
	printf("Motif span: %d\n", profile->span);
	printf("Motif weight/width: %d\n", profile->cols);
	printf("Consensus motif: ");
	for(int x=0; x< profile->span; x++) {
		if(!profile->isgap[x]) {
			if(profile->mat[x][0] > 0.5) 
				printf("A");
			else if(profile->mat[x][1] > 0.5) 
				printf("C");
			else if(profile->mat[x][2] > 0.5) 
				printf("G");
			else if(profile->mat[x][3] > 0.5) 
				printf("T");
			else 
				printf("N");
		}
		else {
			printf("_");
		}
	}
	printf("\n");

	int numsites = getNumSites(sites, data->numseqs);
	printf("Number of predicted sites: %d (%.2lf%%)\n", numsites, (numsites * 100.0) / data->numseqs);
	printf("\n");

	if(profile->span != profile->cols) {
		printGapPos(stdout, profile);
		printf("\n");
	}

	printf("Sequence range is from 0 to (number of sequences - 1).\n");
	printf("Motif sites are in range 1 to length or -1 to -length.\n");
	for(int i=0; i< data->numseqs; i++) {
		if(sites[i] >= 0) {
			int pos = getConcat2DoubleStrandPos(data,i,sites[i]);
			int revcomplPos = getConcat2DoubleStrandPos(data, i, getConcatPosOfOppStrand(data, i, sites[i], profile->span));
			printf("Sequence %3d: motif site %6d  (%6d)\n",i, pos, revcomplPos);
		}
		else {
			printf("Sequence %3d: motif site %6s  (%6s)\n",i, "none", "none");
		}
	}
	

	printf("\n");
	printf("Alignments and FASTA-headers:\n");
	printAlignment(stdout, sites, profile->span, scorePerSite, data);
	printf("\n");
	if(numsites < data->numseqs) {
		printf("FASTA-header of sequences with zero occurrences:\n");
		printZeroOccurrencesSeqHeaders(stdout, sites, data);
		printf("\n");
	}
	nilProfile(profile);
}