Welcome, Guest. Please Login
YaBB - Yet another Bulletin Board
 
  HomeHelpSearchLogin  
 
Codon counting? harvestFrequencies for codons (Read 2673 times)
Nathan Clark
Guest


Codon counting? harvestFrequencies for codons
Mar 13th, 2006 at 3:02pm
 
Hello,
   I'm am trying to create a codon model using batch commands. The transition matrix is fine, but I am having difficulties harvesting the frequencies. I can "harvestFrequencies(freq, df, 3, 3, 0)", and this returns a column of dimension 64.
The transition matrix is 61x61, the unallowed stop codons account for the difference. How can i harvest the freqs without counting stop codons?

Thank you,
-Nathan Clark
Swanson Lab
U of Washington
Back to top
 
 
IP Logged
 
Sergei
YaBB Administrator
*****
Offline


Datamonkeys are forever...

Posts: 1658
UCSD
Gender: male
Re: Codon counting? harvestFrequencies for codons
Reply #1 - Mar 13th, 2006 at 3:43pm
 
Dear Nathan,

In order to get rid of stop codons you'll need to post process the output of HarvestFrequencies - that function will always return 64 (4^3) counts if called with the (3,3,0) argument - HyPhy has no intrinsic knowledge of which codons are stop and which are not. The following example shows how to do this (assuming the use of a standard module to choose a genetic code). The example can also be downloaded from Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login Login

Code:
/*1. Get an example file from the web */

GetURL (theData,"http://www.hyphy.org/pubs/seqs/p51.nex");
DataSet ds = ReadFromString(theData);
fprintf (stdout, "Read these data:\n", ds,"\n");

/*2. Include a module to define a genetic code. This will define vector _Genetic_Code (see the comments in chooseGeneticCode.def for details)
	 All stop codons (in the chosen code) will have index 10, and all sense codons will have indices ranging from 0-9 and 11-20
*/

pathToModule = HYPHY_BASE_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "chooseGeneticCode.def";
ExecuteCommands ("#include \""+ pathToModule + "\";");


/*3. Filter and get codon frequencies */

DataSetFilter 			filteredData = CreateFilter (ds, 3, "", "", GeneticCodeExclusions);
HarvestFrequencies 		(efv, filteredData,3,3,1);

/* make a table of 0's and 1's: 1 for sense codons. See Examples/BatchLanguage/MatrixIndexing.bf for examples of matrix indexing tricks */

senseCodons     = Transpose(_Genetic_Code ["_MATRIX_ELEMENT_VALUE_ != 10"]);
senseCodonFreqs = Transpose(efv[senseCodons]); /* this vector will now hold the frequencies for all non-stop codons */

/*4. Print some diagnostic messages */
chars	= "ACGT";
allCodonIndex   = 0;
senseCodonIndex = 0;
fprintf (stdout, "\nGathered frequencies:\n");
for (p1=0;p1<4;p1=p1+1)
{
	for (p2=0;p2<4;p2=p2+1)
	{
		for (p3=0;p3<4;p3=p3+1)
		{
			fprintf (stdout, chars[p1], chars[p2], chars[p3], " : ");
			if (senseCodons[allCodonIndex] == 1)
			{
				fprintf (stdout, senseCodonFreqs[senseCodonIndex], "\n");
				senseCodonIndex = senseCodonIndex + 1;
			}
			else
			{
				fprintf (stdout, "stop codon\n");
			}
			allCodonIndex = allCodonIndex + 1;
		}
	}
}
 



Cheers,
Sergei

Back to top
 

Associate Professor
Division of Infectious Diseases
Division of Biomedical Informatics
School of Medicine
University of California San Diego
WWW WWW  
IP Logged
 
Nathan Clark
Guest


Re: Codon counting? harvestFrequencies for codons
Reply #2 - Mar 13th, 2006 at 6:32pm
 
Thanks!
It worked briliantly.
-Nathan
Smiley
Back to top
 
 
IP Logged