in reply to how can I combine into one method
diff -u a b --- a 2009-05-05 19:55:21.000000000 +0200 +++ b 2009-05-05 19:54:44.000000000 +0200 @@ -1,7 +1,7 @@ -sub blast_parse{ +sub blast_hd_parse{ my($maid,$maid_dir) = @_; - my $url_hu = "http://hu_seq/"; - my $hu = get($url_hu.$maid); + my $url_hd = "http://hd_seq/"; + my $hd = get($url_hd.$maid); my $ltvec_small = $maid_dir.$maid."Ltvec_small.fa"; open ($hu); my $seq=<$in>; @@ -9,7 +9,8 @@ open ($hu, ">".$maid.".fa"); print $hu_fa ">$maid\n$seq"; close($hu_fa); - my $command = "bl2seq -p blastn -i $ltvec_small -j $hu_fa -F F -D + 1"; + + my $command = "bl2seq -p blastn -i $ltvec_small -j $hd_fa -F F -D + 1"; print $command,"\n"; open OUTPUT, '>', "$maid_dir\\".$maid."_bl2seq.out" ; STDOUT->fdopen( \*OUTPUT, 'w');
(A graphical diff utility like gvimdiff is also very helpful).
The first difference is the sub name, which we'll ignore for now. The second difference is a differently named variable, and a different constant value. Let's just name the variables $url in both subs, and assume that $hd is actually a typo (it's not used anywhere below in the code).
Then you can clean up your code a bit (do you use strict;? you know you should!) and you'll find that the subs are identical, except for the different URL, which can be provided as another parameter.
|
|---|