cse891

 

Analyze Command

Page history last edited by Charles Ofria 2 yrs ago

Adding a new Analyze Command

 

Adding an analyze command is relatively straightforward. We'll add a FIND_RANDOM command which will delete all of the genotypes in the population except a randomly chose individual.

 

Step 1: Declare the method associated with out new command.

 

Go to line 186 in source/analyze/cAnalyze.h and add:

 

void FindRandom(cString cur_string);

 

 

 

If our new method had arguments, they would be included in cur_string.

 

Step 2: Write the body.

 

Go to line 1125 in source/analyze/cAnalyze.cc and add:

 

void cAnalyze::FindRandom(cString cur_string)

{

  tList<cAnalyzeGenotype> & cur_list = batch[cur_batch].List();

  int gen_chosen = random.GetUInt(cur_list.GetSize());

  cAnalyzeGenotype * chosen = cur_list.GetPos(gen_chosen);

 

  // Remove genotypes deleting all except the randomly chosen one.

  while (cur_list.GetSize() > 0) {

     cAnalyzeGenotype * cur_gen = cur_list.Pop();

     if (cur_gen != chosen) delete cur_gen;

  }

 

  // Restore the randomly chosen one.

  cur_list.Push(chosen);

 

  // Adjust the flags on this batch

  batch[cur_batch].SetLineage(false);

  batch[cur_batch].SetAligned(false);

}

 

Step 3: Link this method to the command name.

 

Go to approximately line 7990 in the same file and add in:

 

AddLibraryDef("FIND_RANDOM", &cAnalyze::FindRandom);

 

This will call the command "FIND_RANDOM".

 

Step 4: Compile and test!

 

 

Consider using the analayze commands:

 

LOAD_SEQUENCE (sequence) - Load in a specific sequence.

STATUS - Give information on organisms in the current batch.

DETAIL cout sequence - print out the sequences of all current genotypes (to screen).

Comments (0)

You don't have permission to comment on this page.