Scr47h3
May 20 2005, 12:22 AM
Hey all,
I'm working on a project for Biology that is basically a PERL script. I'm using PERL to calculate genotypic ratios of dihybrid gene things (I don't remember the term - we covered this last semester). But, don't worry about the terminology. I need help with using the Math::Combinatorics module to make the gametes of the two parents. This basically involves taking the parent genetic sequence, and then making all of the combinations of 2 using each individual gene from the parent. Here is kind of what it would look like, in psuedo-code, using only one parent as an example:
@parent1 = qw ( A a B b ); # Each element of the array is a gene.
|
V
################################
################################
## Combine the elements of the genetic array ## This is what I need help with.
## and put it into @gametes ##
################################
################################
|
V
# So basically, @gametes now = qw ( AA Aa AB Ab aB ab Bb bb ), I think, and then I
# have to remove the gametes that consist of only one letter.
# So now I have @gametes = qw ( AB Ab aB ab ).
So basically, I have to combine the contents of an array (@parent1) and store that in a new array (@gametes). I have done some research, and have concluded that using the Math::Combinatorics's exported function 'combine()' would be the easiest way to do this, so I tried doing just that. I came up with this error:
Undefined subroutine &main::combine called at C:\PERL\genetics\COMBIN~1.PL line 5.
Here is the source code I am using (this is just test code):
#!perl -w
use math::combinatorics;
@letters = qw ( A a B b );
@combined = combine(2, @letters);
print "@combined";
Does anyone know either how to make this work, or how to do what I need in a different way?
Thanks, and sorry for the long post,
Evan
Scr47h3
May 23 2005, 09:01 PM
Well, never mind, everybody! I got it! I did a lot of research, and found that I needed this one line of code:
sub (combine);
Or, I could use:
use Math::Combinatorics (combine);
Either one of these will work. So, after a bit more work, I discovered that the combine function returns an array of arrays. So after implementing the proper code to iterate through the array of arrays, I got the gametes! Then it was just a simple matter of removing the impossible gametes (Bb, for examle) by using a simple regular expression. So now, this works, and the rest of the project will be done soon.
Evan