testOA - Config file for test OA configurations for test MOD.
In ontology_annotator.cgi :
In this oa perl module file :
ontology_annotator.cgi has the generic code for any kind of configuration. Some subroutines need data that is specific to a given datatype / configuration, and modules like this one can be custom-written to appropriately get and display this data. There are seven groups of subroutines that need to be written :
When creating a new MOD, must create &login<Mod> and optional curator_ip table.
When creating a new datatype, must create &init<Mod>Fields and corresponding postgres tables.
When creating a new dropdown / multidropdown, must set values in &setAnySimpleAutocompleteValues .
When creating a new ontology / multiontology, must set &getAnySpecificAutocomplete &getAnySpecificValidValue &getAnySpecificTermInfo &getAnySpecificIdToValue and create appropriate corresponding subroutine for each.
NOTE : If using this as a template for a new MOD OA configuration, you will not have pap_ postgres tables, so the &getAnySpecific... subroutines will not work because the tables will not exist. Look at the wormOA.pm for more examples.
&loginTest is the main subroutine called from the ontology_annotator.cgi and calls the appropriate login-related subroutine. The worm config stores the last IP used by any given curator, this is not necessary for other MODs.
&loginMod is called by ontology_annotator.cgi passing in a flag for which subroutine to call, an IP address, and optional curator_two. It is a generalized function to call &loginTest with the same parameters.
&loginTest is called by &loginMod passing in a flag for which subroutine to call, an IP address, and optional curator_two. It calls &showTestLogin or &updateTestCurator .
&showTestLogin is called from ontology_annotator.cgi's &showLogin passing in the IP of the user. Displays a selection of curators and datatypes for that MOD, and a Login button 'Login !'. A postgres table of curator IPs finds the last curator to use that IP and automatically select it ; this is optional and only necessary is tracking curators by IP.
&updateTestCurator is called from ontology_annotator.cgi's &showMain passing in the IP of the user and the curator_two to update. Update the postgres table two_curator_ip for this curator_two and IP. Optional subroutine, unnecessary if not tracking curators by IP.
&initTestFields is the main subroutine called from the ontology_annotator.cgi and calls the appropriate datatype-appropriate initialization subroutine to set field and datatype values.
&initModFields is called by ontology_annotator.cgi passing in $datatype and $curator_two and returning values of $fieldsRef and $datatypesRef . It is a generalized function to call &initTestFields with the same parameters.
&initTestFields is called by &initModFields passing in $datatype and $curator_two and returning values of $fieldsRef and $datatypesRef . A new datatype configuration calls &initTest<datatype>Fields passing $datatype and $curator_two and returning values of $fieldsRef and $datatypesRef .
&initTest<datatype>Fields exist for each specific datatype configuration. It defines the %fields and %datatypes and returns them to the ontology_annotator.cgi .
%datatypes stores options for each datatype configuration as a whole, in the format $datatypes{<datatype>}{<option>} . It can have these options :
%fields stores options for the datatype configuration's individual fields, in the format $fields{<datatype>}{<field_name>}{<option>} . It must have a field called 'id' used to store the dataTable's pgid / postgresTables's joinkey. It must also have a field called 'curator' (or equivalent, such as 'curator_evidence'). It can have these options :
&setAnySimpleAutocompleteValues is the only subroutine called from the ontology_annotator.cgi and sets the dropdown values for the appropriate datatype. Necessary when creating a new dropdown or multidropdown ontology type.
&setAnySimpleAutocompleteValues is called by ontology_annotator.cgi passing in the ontology_type and returning a pointer to %data. Creates a tied %data hash which has all dropdown values in order entered for the given ontology_type.
%data stores dropdown values for a given ontology_type, in the format ''$data{<ontology_type>}{name}{<name>} = <value_to_display>''. value_to_display can have two formats : ''<name_of_value> ( <id_of_value> ) '' or ''<value>'' depending on whether the ontology_type stores IDs or not, respectively.
&getAnySpecificAutocomplete is the main subroutine called from the ontology_annotator.cgi and calls the ontology_type-appropriate subroutine to get the matching Autocomplete values for that ontology_type. Used when a curator types full or partial terms into an ontology / multiontology field. Necessary when creating a new ontology or multiontology type.
&getAnySpecificAutocomplete is called by ontology_annotator.cgi passing in the ontology_type and words to autocomplete on, and returning the corresponding matches. Calls &getAny<ontology_type>Autocomplete passing in words to autocomplete on, and returning the corresponding matches.
&getAny<ontology_type>Autocomplete exists for each specific ontology_type. It queries the appropriate postgres tables to find corresponding values. Most of these subroutines return 20 ontology values, but if there are 5 or more characters to search the results expands to 500. Most also search for a case-insensitive match beginning with the search terms, then if there aren't yet max_results it appends results from a case-insensitive match of the search terms where the terms do not match at the beginning. If there are more than max_results values, the last results is replaced with 'more ...'. Results are joined by a newline and returned. Most tables searched are the appropriate name table for the ontology_type, but it could also be an ID field or synonym field or anything else. The format of each autocomplete value can be ''<value>'' if it can only match on a value, or ''<name_of_value> ( <id_of_value> ) '' if it can match on a name or an ID, or ''<name_of_match> ( <id_of_value> ) [name_of_id]'' if it can match on a synonym, ID, or name of term.
&getAnySpecificValidValue is the main subroutine called from the ontology_annotator.cgi and calls the ontology_type-appropriate subroutine to check that a value is valid for that ontology_type. Used when a curator selects a value in an ontology or multiontology field. Necessary when creating a new ontology or multiontology type.
&getAnySpecificValidValue is called by ontology_annotator.cgi passing in the ontology_type and userValue to check validity on, and returning 'true' or 'false' as appropriate. Calls &getAny<ontology_type>ValidValue passing in the userValue and returning 'true' or 'false'.
&getAny<ontology_type>ValidValue exists for each specific ontology_type. It queries the appropriate postgres tables to check if the userValue is a valid value for the ontology_type. If it is valid, returns 'true', otherwise returns 'false'.
&getAnySpecificTermInfo is the main subroutine called from the ontology_annotator.cgi and calls the ontology_type-appropriate subroutine to get the term information for the given ontology value, to display in the OA's obo frame. Used when a curator clicks, mouses over, or arrows to a value from an ontology / multiontology field. Necessary when creating a new ontology or multiontology type.
&getAnySpecificTermInfo is called by ontology_annotator.cgi passing in the ontology_type and userValue to get term info of, and returning a variable containing the term information to display in the OA's obo frame. Calls &getAny<ontology_type>TermInfo passing in the userValue, and returning the term information to display.
&getAny<ontology_type>TermInfo exists for each specific ontology_type. It queries the appropriate postgres tables (or flatfiles) to get the term information to display. Most information has a tag name and colon in a bold html span, followed by the information. As appropriate there might be html hr dividers. Any type of html links or embedded images or practically any html could be displayed here.
&getAnySpecificIdToValue is the main subroutine called from the ontology_annotator.cgi and calls the ontology_type-appropriate subroutine to add to the %fieldIdToValue hash, which converts ID into ''name<span style='display: none'>id</span>''. Used when displaying dataTable data from a postgres query of &jsonFieldQuery in the main CGI. Necessary when creating a new ontology or multiontology type.
&getAnySpecificIdToValue is called by ontology_annotator.cgi passing in the ontology_type, %fields's type, pointer to existing %fieldIdToValue, and IDs from postgres table data from which to get the id to value mappings ; and returning a variable containing the display values of each of the ontology_type's passed IDs, and a pointer to the updated %fieldIdToValue . Calls &getAny<ontology_type>IdToValue, passing in the ontology_type, %fields's type, pointer to %fieldIdToValue hash, IDs from postgres table data ; and returning a variable with the display values of the corresponding IDs, and a pointer to the updated %fieldIdToValue .
&getAny<ontology_type>IdToValue exists for each specific ontology_type. It splits the postgres data table's values into separate IDs, and for each ID, it checks against the %fieldIdToValue hash. If it already exists, it adds it to the %results hash. If it doesn't, it queries against the appropriate postgres tables and generates a new value to display, adding it to %results and to $fieldIdToValue{$ontology_type}. %results values are joined by commas into a $data variable to return. If the %fields's type is ontology, the leading and trailing doublequotes are stripped (doublequotes are necessary for multiontology). $data and a pointer to the updated %fieldIdToValue are returned. The format of %results is ''$results{<joinkey>} = "<display_value><span style='display: none'><id></span>"'' where <span> tags are html tags, and <display_value> and <id> are real values.