1. use strict; 2. use SAPserver; 3. use Data::Dumper; 4. 5. # Example 1: ACH Data for a Protein 6. # 7. # This script takes a protein ID on the command line and 8. # finds all identifiers in the Sapling database that correspond 9. # to the identified protein (that is, they have the same amino 10. # acid sequence). For each identifier found, the following six 11. # columns will be output. 12. # 13. # 1. The identifier found. 14. # 2. The scientific name of the associated genome (if any). 15. # 3. 1 if we believe the identifier corresponds to the 16. # exact gene identified by the input identifier, else 17. # 0. If the input identifier does not specify a 18. # particular gene, this column will always be 0. 19. # 4. The functional assignment associated with the protein 20. # ID. 21. # 5. The source of the assignment. 22. # 6. 1 if the assignment is considered expert, else 0. 23. # 24. # The data in columns (1), (4), (5), and (6) are provided 25. # automatically by the Sapling Server method "equiv_sequence". 26. # The item in column (3) is extracted via a call to the Sapling 27. # Server method "genome_names". The tricky part is the value in 28. # column (3). To make this determination, we make an initial call 29. # to the "equiv_precise" method to get identifiers for precisely- 30. # equivalent genes and put them into a hash. The value of 31. # column (3) is then determined by whether or not an 32. # identifier is in the precise-equivalence hash. 33. 34. my $sapObject = SAPserver->new(); 35. my $id = $ARGV[0]; 36. if (! $id) { 37. die "No protein ID specified."; 38. } else { 39. my %preciseHash; 40. my $precise_assertions_list = $sapObject->equiv_precise_assertions(-ids => $id); 41. $precise_assertions_list = $precise_assertions_list->{$id}; 42. if (@$precise_assertions_list > 0) { 43. my $inputID = $id; 44. for my $precise_assertion (@$precise_assertions_list) { 45. my ($newID, $function, $source, $expert) = @$precise_assertion; 46. $preciseHash{$newID} = 1; 47. } 48. } 49. 50. my $assertions = $sapObject->equiv_sequence_assertions(-ids => $id); 51. $assertions = $assertions->{$id}; 52. if (@$assertions < 1) { 53. print STDERR "No results found.\n"; 54. } else { 55. for my $assertion (@$assertions) { 56. my ($newID, $function, $source, $expert, $genomeName) = @$assertion; 57. $genomeName = '' if ! defined $genomeName; 58. my $column3 = ($preciseHash{$newID} ? 1 : 0); 59. print join("\t", $newID, $genomeName, $column3, $function, $source, 60. $expert) . "\n"; 61. } 62. } 63. } 64.