bel_parser 1.0.0.alpha.27-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gemspec-java +32 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE +191 -0
- data/README.md +20 -0
- data/VERSION +1 -0
- data/bin/bel2_validator +62 -0
- data/bin/bel_script_reader +132 -0
- data/lib/bel/translator/plugins/bel_script.rb +38 -0
- data/lib/bel/translator/plugins/bel_script/bel_citation_serialization.rb +125 -0
- data/lib/bel/translator/plugins/bel_script/bel_discrete_serialization.rb +109 -0
- data/lib/bel/translator/plugins/bel_script/bel_top_down_serialization.rb +100 -0
- data/lib/bel/translator/plugins/bel_script/nanopub_serialization.rb +79 -0
- data/lib/bel/translator/plugins/bel_script/reader.rb +39 -0
- data/lib/bel/translator/plugins/bel_script/translator.rb +37 -0
- data/lib/bel/translator/plugins/bel_script/writer.rb +180 -0
- data/lib/bel_parser.rb +23 -0
- data/lib/bel_parser/ast_filter.rb +44 -0
- data/lib/bel_parser/ast_generator.rb +83 -0
- data/lib/bel_parser/expression.rb +3 -0
- data/lib/bel_parser/expression/filter.rb +31 -0
- data/lib/bel_parser/expression/parser.rb +72 -0
- data/lib/bel_parser/expression/validator.rb +79 -0
- data/lib/bel_parser/language.rb +114 -0
- data/lib/bel_parser/language/amino_acid.rb +68 -0
- data/lib/bel_parser/language/apply_namespace_encoding.rb +98 -0
- data/lib/bel_parser/language/base_specification.rb +82 -0
- data/lib/bel_parser/language/covalent_protein_modification.rb +56 -0
- data/lib/bel_parser/language/expression_validator.rb +68 -0
- data/lib/bel_parser/language/function.rb +67 -0
- data/lib/bel_parser/language/relationship.rb +102 -0
- data/lib/bel_parser/language/semantics.rb +40 -0
- data/lib/bel_parser/language/semantics/deeply_nested_statement.rb +65 -0
- data/lib/bel_parser/language/semantics/function_deprecation.rb +43 -0
- data/lib/bel_parser/language/semantics/list_function_subject.rb +45 -0
- data/lib/bel_parser/language/semantics/multiple_subject_object.rb +55 -0
- data/lib/bel_parser/language/semantics/non_causal_nested_statement.rb +50 -0
- data/lib/bel_parser/language/semantics/non_object_list.rb +56 -0
- data/lib/bel_parser/language/semantics/relationship_deprecation.rb +44 -0
- data/lib/bel_parser/language/semantics/relationship_not_listable.rb +60 -0
- data/lib/bel_parser/language/semantics/signature_mapping.rb +83 -0
- data/lib/bel_parser/language/semantics_ast.rb +784 -0
- data/lib/bel_parser/language/semantics_ast_warnings.rb +180 -0
- data/lib/bel_parser/language/semantics_function.rb +16 -0
- data/lib/bel_parser/language/semantics_match.rb +28 -0
- data/lib/bel_parser/language/semantics_result.rb +33 -0
- data/lib/bel_parser/language/semantics_type_warning.rb +22 -0
- data/lib/bel_parser/language/semantics_warning.rb +27 -0
- data/lib/bel_parser/language/signature.rb +39 -0
- data/lib/bel_parser/language/specification.rb +118 -0
- data/lib/bel_parser/language/syntax.rb +38 -0
- data/lib/bel_parser/language/syntax/invalid_function.rb +39 -0
- data/lib/bel_parser/language/syntax/invalid_relationship.rb +42 -0
- data/lib/bel_parser/language/syntax/undefined_namespace.rb +49 -0
- data/lib/bel_parser/language/syntax/undefined_namespace_value.rb +44 -0
- data/lib/bel_parser/language/syntax_error.rb +32 -0
- data/lib/bel_parser/language/syntax_function.rb +16 -0
- data/lib/bel_parser/language/syntax_result.rb +32 -0
- data/lib/bel_parser/language/syntax_warning.rb +27 -0
- data/lib/bel_parser/language/version1_0.rb +20 -0
- data/lib/bel_parser/language/version1_0/functions/abundance.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/biological_process.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/catalytic_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/cell_secretion.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/cell_surface_expression.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/chaperone_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/complex_abundance.rb +115 -0
- data/lib/bel_parser/language/version1_0/functions/composite_abundance.rb +81 -0
- data/lib/bel_parser/language/version1_0/functions/degradation.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/fusion.rb +287 -0
- data/lib/bel_parser/language/version1_0/functions/gene_abundance.rb +122 -0
- data/lib/bel_parser/language/version1_0/functions/gtp_bound_activity.rb +113 -0
- data/lib/bel_parser/language/version1_0/functions/kinase_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/list.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/micro_rna_abundance.rb +85 -0
- data/lib/bel_parser/language/version1_0/functions/molecular_activity.rb +82 -0
- data/lib/bel_parser/language/version1_0/functions/pathology.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/peptidase_activity.rb +112 -0
- data/lib/bel_parser/language/version1_0/functions/phosphatase_activity.rb +112 -0
- data/lib/bel_parser/language/version1_0/functions/products.rb +79 -0
- data/lib/bel_parser/language/version1_0/functions/protein_abundance.rb +234 -0
- data/lib/bel_parser/language/version1_0/functions/protein_modification.rb +179 -0
- data/lib/bel_parser/language/version1_0/functions/reactants.rb +79 -0
- data/lib/bel_parser/language/version1_0/functions/reaction.rb +86 -0
- data/lib/bel_parser/language/version1_0/functions/ribosylation_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/rna_abundance.rb +122 -0
- data/lib/bel_parser/language/version1_0/functions/substitution.rb +93 -0
- data/lib/bel_parser/language/version1_0/functions/transcriptional_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/translocation.rb +98 -0
- data/lib/bel_parser/language/version1_0/functions/transport_activity.rb +115 -0
- data/lib/bel_parser/language/version1_0/functions/truncation.rb +81 -0
- data/lib/bel_parser/language/version1_0/relationships/acts_in.rb +61 -0
- data/lib/bel_parser/language/version1_0/relationships/analogous.rb +41 -0
- data/lib/bel_parser/language/version1_0/relationships/association.rb +42 -0
- data/lib/bel_parser/language/version1_0/relationships/biomarker_for.rb +42 -0
- data/lib/bel_parser/language/version1_0/relationships/causes_no_change.rb +50 -0
- data/lib/bel_parser/language/version1_0/relationships/decreases.rb +63 -0
- data/lib/bel_parser/language/version1_0/relationships/directly_decreases.rb +56 -0
- data/lib/bel_parser/language/version1_0/relationships/directly_increases.rb +56 -0
- data/lib/bel_parser/language/version1_0/relationships/has_component.rb +62 -0
- data/lib/bel_parser/language/version1_0/relationships/has_components.rb +61 -0
- data/lib/bel_parser/language/version1_0/relationships/has_member.rb +48 -0
- data/lib/bel_parser/language/version1_0/relationships/has_members.rb +57 -0
- data/lib/bel_parser/language/version1_0/relationships/has_modification.rb +54 -0
- data/lib/bel_parser/language/version1_0/relationships/has_product.rb +60 -0
- data/lib/bel_parser/language/version1_0/relationships/has_variant.rb +54 -0
- data/lib/bel_parser/language/version1_0/relationships/includes.rb +59 -0
- data/lib/bel_parser/language/version1_0/relationships/increases.rb +63 -0
- data/lib/bel_parser/language/version1_0/relationships/is_a.rb +48 -0
- data/lib/bel_parser/language/version1_0/relationships/negative_correlation.rb +50 -0
- data/lib/bel_parser/language/version1_0/relationships/orthologous.rb +48 -0
- data/lib/bel_parser/language/version1_0/relationships/positive_correlation.rb +46 -0
- data/lib/bel_parser/language/version1_0/relationships/prognostic_biomarker_for.rb +44 -0
- data/lib/bel_parser/language/version1_0/relationships/rate_limiting_step_of.rb +53 -0
- data/lib/bel_parser/language/version1_0/relationships/reactant_in.rb +60 -0
- data/lib/bel_parser/language/version1_0/relationships/sub_process_of.rb +55 -0
- data/lib/bel_parser/language/version1_0/relationships/transcribed_to.rb +53 -0
- data/lib/bel_parser/language/version1_0/relationships/translated_to.rb +54 -0
- data/lib/bel_parser/language/version1_0/relationships/translocates.rb +57 -0
- data/lib/bel_parser/language/version1_0/return_types/abundance.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/any.rb +74 -0
- data/lib/bel_parser/language/version1_0/return_types/biological_process.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/catalytic_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/chaperone_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/complex_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/fusion.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/gene_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/gtp_bound_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/kinase_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/list.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/micro_rna_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/molecular_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/pathology.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/peptidase_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/phosphatase_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/products.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/protein_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/protein_modification.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/reactants.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/ribosylation_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/rna_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/substitution.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/transcriptional_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/transport_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/truncation.rb +17 -0
- data/lib/bel_parser/language/version1_0/value_encodings/abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/any.rb +74 -0
- data/lib/bel_parser/language/version1_0/value_encodings/biological_process.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/complex_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/gene_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/micro_rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/pathology.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/protein_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0.rb +20 -0
- data/lib/bel_parser/language/version2_0/functions/abundance.rb +161 -0
- data/lib/bel_parser/language/version2_0/functions/activity.rb +118 -0
- data/lib/bel_parser/language/version2_0/functions/biological_process.rb +84 -0
- data/lib/bel_parser/language/version2_0/functions/cell_secretion.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/cell_surface_expression.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/complex_abundance.rb +190 -0
- data/lib/bel_parser/language/version2_0/functions/composite_abundance.rb +81 -0
- data/lib/bel_parser/language/version2_0/functions/degradation.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/fragment.rb +116 -0
- data/lib/bel_parser/language/version2_0/functions/from_location.rb +85 -0
- data/lib/bel_parser/language/version2_0/functions/fusion.rb +203 -0
- data/lib/bel_parser/language/version2_0/functions/gene_abundance.rb +192 -0
- data/lib/bel_parser/language/version2_0/functions/list.rb +114 -0
- data/lib/bel_parser/language/version2_0/functions/location.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/micro_rna_abundance.rb +163 -0
- data/lib/bel_parser/language/version2_0/functions/molecular_activity.rb +86 -0
- data/lib/bel_parser/language/version2_0/functions/pathology.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/products.rb +79 -0
- data/lib/bel_parser/language/version2_0/functions/protein_abundance.rb +270 -0
- data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +172 -0
- data/lib/bel_parser/language/version2_0/functions/reactants.rb +79 -0
- data/lib/bel_parser/language/version2_0/functions/reaction.rb +86 -0
- data/lib/bel_parser/language/version2_0/functions/rna_abundance.rb +192 -0
- data/lib/bel_parser/language/version2_0/functions/to_location.rb +84 -0
- data/lib/bel_parser/language/version2_0/functions/translocation.rb +91 -0
- data/lib/bel_parser/language/version2_0/functions/variant.rb +80 -0
- data/lib/bel_parser/language/version2_0/relationships/acts_in.rb +61 -0
- data/lib/bel_parser/language/version2_0/relationships/analogous.rb +45 -0
- data/lib/bel_parser/language/version2_0/relationships/association.rb +42 -0
- data/lib/bel_parser/language/version2_0/relationships/biomarker_for.rb +46 -0
- data/lib/bel_parser/language/version2_0/relationships/causes_no_change.rb +50 -0
- data/lib/bel_parser/language/version2_0/relationships/decreases.rb +63 -0
- data/lib/bel_parser/language/version2_0/relationships/directly_decreases.rb +56 -0
- data/lib/bel_parser/language/version2_0/relationships/directly_increases.rb +56 -0
- data/lib/bel_parser/language/version2_0/relationships/has_component.rb +62 -0
- data/lib/bel_parser/language/version2_0/relationships/has_components.rb +61 -0
- data/lib/bel_parser/language/version2_0/relationships/has_member.rb +48 -0
- data/lib/bel_parser/language/version2_0/relationships/has_members.rb +57 -0
- data/lib/bel_parser/language/version2_0/relationships/has_modification.rb +54 -0
- data/lib/bel_parser/language/version2_0/relationships/has_product.rb +60 -0
- data/lib/bel_parser/language/version2_0/relationships/has_variant.rb +54 -0
- data/lib/bel_parser/language/version2_0/relationships/includes.rb +59 -0
- data/lib/bel_parser/language/version2_0/relationships/increases.rb +63 -0
- data/lib/bel_parser/language/version2_0/relationships/is_a.rb +48 -0
- data/lib/bel_parser/language/version2_0/relationships/negative_correlation.rb +50 -0
- data/lib/bel_parser/language/version2_0/relationships/orthologous.rb +48 -0
- data/lib/bel_parser/language/version2_0/relationships/positive_correlation.rb +46 -0
- data/lib/bel_parser/language/version2_0/relationships/prognostic_biomarker_for.rb +48 -0
- data/lib/bel_parser/language/version2_0/relationships/rate_limiting_step_of.rb +53 -0
- data/lib/bel_parser/language/version2_0/relationships/reactant_in.rb +60 -0
- data/lib/bel_parser/language/version2_0/relationships/regulates.rb +51 -0
- data/lib/bel_parser/language/version2_0/relationships/sub_process_of.rb +55 -0
- data/lib/bel_parser/language/version2_0/relationships/transcribed_to.rb +53 -0
- data/lib/bel_parser/language/version2_0/relationships/translated_to.rb +54 -0
- data/lib/bel_parser/language/version2_0/relationships/translocates.rb +57 -0
- data/lib/bel_parser/language/version2_0/return_types/abundance.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/activity.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/any.rb +74 -0
- data/lib/bel_parser/language/version2_0/return_types/biological_process.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/complex_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/fragment.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/from_location.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/fusion.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/gene_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/list.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/location.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/micro_rna_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/molecular_activity.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/pathology.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/products.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/protein_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/protein_modification.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/reactants.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/rna_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/to_location.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/variant.rb +20 -0
- data/lib/bel_parser/language/version2_0/value_encodings/abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/activity.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/any.rb +74 -0
- data/lib/bel_parser/language/version2_0/value_encodings/biological_process.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/complex_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/gene_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/location.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/micro_rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/pathology.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/protein_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/protein_modification.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/rna_abundance.rb +21 -0
- data/lib/bel_parser/mixin/line_continuator.rb +15 -0
- data/lib/bel_parser/mixin/line_mapping.rb +14 -0
- data/lib/bel_parser/parsers/ast/node.rb +987 -0
- data/lib/bel_parser/parsers/ast/sexp.rb +8 -0
- data/lib/bel_parser/parsers/bel_script.rb +5 -0
- data/lib/bel_parser/parsers/bel_script/define_annotation.rb +5920 -0
- data/lib/bel_parser/parsers/bel_script/define_annotation.rl +141 -0
- data/lib/bel_parser/parsers/bel_script/define_namespace.rb +1780 -0
- data/lib/bel_parser/parsers/bel_script/define_namespace.rl +121 -0
- data/lib/bel_parser/parsers/bel_script/set.rb +5008 -0
- data/lib/bel_parser/parsers/bel_script/set.rl +116 -0
- data/lib/bel_parser/parsers/bel_script/set_document.rb +7722 -0
- data/lib/bel_parser/parsers/bel_script/set_document.rl +97 -0
- data/lib/bel_parser/parsers/bel_script/unset.rb +706 -0
- data/lib/bel_parser/parsers/bel_script/unset.rl +95 -0
- data/lib/bel_parser/parsers/common.rb +5 -0
- data/lib/bel_parser/parsers/common/blank_line.rb +211 -0
- data/lib/bel_parser/parsers/common/blank_line.rl +81 -0
- data/lib/bel_parser/parsers/common/comment_line.rb +245 -0
- data/lib/bel_parser/parsers/common/comment_line.rl +97 -0
- data/lib/bel_parser/parsers/common/common.rb +7 -0
- data/lib/bel_parser/parsers/common/common.rl +13 -0
- data/lib/bel_parser/parsers/common/identifier.rb +289 -0
- data/lib/bel_parser/parsers/common/identifier.rl +106 -0
- data/lib/bel_parser/parsers/common/list.rb +2388 -0
- data/lib/bel_parser/parsers/common/list.rl +146 -0
- data/lib/bel_parser/parsers/common/string.rb +271 -0
- data/lib/bel_parser/parsers/common/string.rl +107 -0
- data/lib/bel_parser/parsers/expression.rb +7 -0
- data/lib/bel_parser/parsers/expression/comment.rb +239 -0
- data/lib/bel_parser/parsers/expression/comment.rl +97 -0
- data/lib/bel_parser/parsers/expression/nested_statement.rb +17802 -0
- data/lib/bel_parser/parsers/expression/nested_statement.rl +141 -0
- data/lib/bel_parser/parsers/expression/observed_term.rb +7291 -0
- data/lib/bel_parser/parsers/expression/observed_term.rl +92 -0
- data/lib/bel_parser/parsers/expression/parameter.rb +1506 -0
- data/lib/bel_parser/parsers/expression/parameter.rl +97 -0
- data/lib/bel_parser/parsers/expression/relationship.rb +254 -0
- data/lib/bel_parser/parsers/expression/relationship.rl +98 -0
- data/lib/bel_parser/parsers/expression/simple_statement.rb +10475 -0
- data/lib/bel_parser/parsers/expression/simple_statement.rl +112 -0
- data/lib/bel_parser/parsers/expression/term.rb +3989 -0
- data/lib/bel_parser/parsers/expression/term.rl +157 -0
- data/lib/bel_parser/parsers/line_parser.rb +92 -0
- data/lib/bel_parser/parsers/mixin/buffer.rb +10 -0
- data/lib/bel_parser/parsers/nonblocking_io_wrapper.rb +50 -0
- data/lib/bel_parser/parsers/serializer.rb +205 -0
- data/lib/bel_parser/quoting.rb +177 -0
- data/lib/bel_parser/resource/concept.rb +56 -0
- data/lib/bel_parser/resource/concept_scheme.rb +35 -0
- data/lib/bel_parser/resource/dataset.rb +34 -0
- data/lib/bel_parser/resource/eager_reader.rb +89 -0
- data/lib/bel_parser/resource/eager_sparql_reader.rb +51 -0
- data/lib/bel_parser/resource/file_resource.rb +21 -0
- data/lib/bel_parser/resource/file_resource_value.rb +24 -0
- data/lib/bel_parser/resource/jena_tdb_reader.rb +246 -0
- data/lib/bel_parser/resource/lru_cache.rb +111 -0
- data/lib/bel_parser/resource/lru_reader.rb +34 -0
- data/lib/bel_parser/resource/reader.rb +18 -0
- data/lib/bel_parser/resource/resource_url_reader.rb +181 -0
- data/lib/bel_parser/resource/sparql_reader.rb +179 -0
- data/lib/bel_parser/resource/value.rb +31 -0
- data/lib/bel_parser/script.rb +8 -0
- data/lib/bel_parser/script/filter.rb +35 -0
- data/lib/bel_parser/script/first_node.rb +21 -0
- data/lib/bel_parser/script/keywords.rb +32 -0
- data/lib/bel_parser/script/nanopub_mapper.rb +182 -0
- data/lib/bel_parser/script/parser.rb +51 -0
- data/lib/bel_parser/script/state/annotation_definition.rb +62 -0
- data/lib/bel_parser/script/state/bel_version.rb +36 -0
- data/lib/bel_parser/script/state/document_property.rb +29 -0
- data/lib/bel_parser/script/state/namespace_definition.rb +32 -0
- data/lib/bel_parser/script/state/set.rb +82 -0
- data/lib/bel_parser/script/state/unset.rb +46 -0
- data/lib/bel_parser/script/state_aggregator.rb +49 -0
- data/lib/bel_parser/script/state_function.rb +10 -0
- data/lib/bel_parser/script/syntax/expression_validation.rb +46 -0
- data/lib/bel_parser/script/syntax/invalid_regex_pattern.rb +49 -0
- data/lib/bel_parser/script/syntax/undefined_annotation.rb +61 -0
- data/lib/bel_parser/script/syntax/undefined_annotation_value.rb +84 -0
- data/lib/bel_parser/script/syntax/unresolvable_namespace.rb +54 -0
- data/lib/bel_parser/script/syntax/unsupported_bel_version.rb +59 -0
- data/lib/bel_parser/script/validator.rb +65 -0
- data/lib/bel_parser/vendor/ast.rb +17 -0
- data/lib/bel_parser/vendor/ast/node.rb +254 -0
- data/lib/bel_parser/vendor/ast/processor.rb +12 -0
- data/lib/bel_parser/vendor/ast/processor/mixin.rb +282 -0
- data/lib/bel_parser/vendor/ast/sexp.rb +30 -0
- metadata +390 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative '../ast_generator'
|
2
|
+
require_relative '../parsers/common'
|
3
|
+
require_relative '../parsers/expression'
|
4
|
+
|
5
|
+
module BELParser
|
6
|
+
module Expression
|
7
|
+
# Parser for BEL Expression.
|
8
|
+
class Parser
|
9
|
+
def parse(input, &block)
|
10
|
+
case input
|
11
|
+
when String
|
12
|
+
parse_string(input, &block)
|
13
|
+
when Array
|
14
|
+
parse_array(input, &block)
|
15
|
+
when IO, StringIO
|
16
|
+
parse_io(input, &block)
|
17
|
+
else
|
18
|
+
raise ArgumentError,
|
19
|
+
%(expected "input" to be one of String, Array, IO: #{input.class})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def parse_string(string)
|
26
|
+
filter = Filter.new(
|
27
|
+
BELParser::ASTGenerator.new(StringIO.new(string)))
|
28
|
+
num, line, results = filter.each.first
|
29
|
+
if block_given?
|
30
|
+
yield results
|
31
|
+
nil
|
32
|
+
else
|
33
|
+
results
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse_array(array)
|
38
|
+
if block_given?
|
39
|
+
array.each do |expression|
|
40
|
+
yield parse_string(expression.to_s)
|
41
|
+
end
|
42
|
+
nil
|
43
|
+
else
|
44
|
+
array.map do |expression|
|
45
|
+
parse_string(expression.to_s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def parse_io(io)
|
51
|
+
if block_given?
|
52
|
+
filter = Filter.new(BELParser::ASTGenerator.new(io))
|
53
|
+
filter.each do |(num, line, results)|
|
54
|
+
yield results
|
55
|
+
end
|
56
|
+
nil
|
57
|
+
else
|
58
|
+
enum_for(:parse_io, io)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
if __FILE__ == $PROGRAM_NAME
|
66
|
+
BELParser::Expression::Parser.new.each($stdin) do |(line_number, line, res)|
|
67
|
+
puts "#{line_number}: #{line}"
|
68
|
+
res.each do |ast|
|
69
|
+
puts ast.to_s(1)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative '../ast_filter'
|
2
|
+
require_relative '../ast_generator'
|
3
|
+
require_relative '../parsers/expression'
|
4
|
+
require_relative '../language'
|
5
|
+
require_relative '../language/expression_validator'
|
6
|
+
|
7
|
+
module BELParser
|
8
|
+
module Expression
|
9
|
+
# Parser for BEL Expression.
|
10
|
+
class Validator
|
11
|
+
include BELParser::Parsers::Common
|
12
|
+
include BELParser::Parsers::Expression
|
13
|
+
|
14
|
+
TYPES = [
|
15
|
+
:parameter,
|
16
|
+
:term,
|
17
|
+
:simple_statement,
|
18
|
+
:observed_term,
|
19
|
+
:nested_statement
|
20
|
+
]
|
21
|
+
|
22
|
+
def initialize(specification_version, namespaces, resource_reader)
|
23
|
+
@spec = BELParser::Language.specification(specification_version)
|
24
|
+
@validator = BELParser::Language::ExpressionValidator.new(
|
25
|
+
@spec, namespaces, resource_reader)
|
26
|
+
end
|
27
|
+
|
28
|
+
def each(io)
|
29
|
+
if block_given?
|
30
|
+
filter = BELParser::ASTFilter.new(
|
31
|
+
BELParser::ASTGenerator.new(io),
|
32
|
+
*TYPES)
|
33
|
+
filter.each do |(num, line, results)|
|
34
|
+
results.each do |ast|
|
35
|
+
yield [num, line, ast, @validator.validate(ast)]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
enum_for(:each, io)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if __FILE__ == $PROGRAM_NAME
|
47
|
+
unless ARGV.first
|
48
|
+
program = File.basename($PROGRAM_NAME)
|
49
|
+
$stderr.puts <<-USAGE.gsub(/ {6}/, '')
|
50
|
+
usage: #{program} [BEL specification version] [PREFIX=URI]...
|
51
|
+
USAGE
|
52
|
+
exit 1
|
53
|
+
end
|
54
|
+
|
55
|
+
require 'bel_parser/resource/resource_url_reader'
|
56
|
+
|
57
|
+
resource_reader = BELParser::Resource::ResourceURLReader.new
|
58
|
+
namespaces =
|
59
|
+
Hash[
|
60
|
+
ARGV[1..-1]
|
61
|
+
.map do |ns|
|
62
|
+
prefix, identifier = ns.split('=')
|
63
|
+
[prefix, resource_reader.retrieve_resource(identifier)]
|
64
|
+
end
|
65
|
+
]
|
66
|
+
BELParser::Expression::Validator
|
67
|
+
.new(ARGV.first, namespaces, resource_reader)
|
68
|
+
.each($stdin) do |(line_number, line, ast, results)|
|
69
|
+
results.select { |res| res.is_a? BELParser::Language::Syntax::SyntaxError }
|
70
|
+
puts "#{line_number}: #{line}"
|
71
|
+
puts " AST Type: #{ast.type}"
|
72
|
+
puts results
|
73
|
+
.map { |r| "#{r}\n" }
|
74
|
+
.join
|
75
|
+
.each_line
|
76
|
+
.map { |l| " #{l}" }
|
77
|
+
.join
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require_relative 'language/amino_acid'
|
2
|
+
require_relative 'language/function'
|
3
|
+
require_relative 'language/syntax'
|
4
|
+
require_relative 'language/semantics'
|
5
|
+
require_relative 'language/signature'
|
6
|
+
require_relative 'language/specification'
|
7
|
+
require_relative 'language/expression_validator'
|
8
|
+
|
9
|
+
module BELParser
|
10
|
+
# Language defines the concepts needed to define, represent, and
|
11
|
+
# validate a BEL specification. This includes:
|
12
|
+
#
|
13
|
+
# - {BELParser::Language::Specification BEL specifications}
|
14
|
+
# - Functions
|
15
|
+
# - ReturnTypes
|
16
|
+
# - Signatures
|
17
|
+
# - Relationships
|
18
|
+
# - Encodings
|
19
|
+
# - Syntax validations
|
20
|
+
# - Semantic validations
|
21
|
+
# - Generic Syntax validations
|
22
|
+
# - Generic signature validation
|
23
|
+
module Language
|
24
|
+
# Mutex to synchronize creation of BEL specifications.
|
25
|
+
LOCK = Mutex.new
|
26
|
+
private_constant :LOCK
|
27
|
+
|
28
|
+
# Indicates if +version+ is a defined BEL specification.
|
29
|
+
#
|
30
|
+
# @param [#to_s] version the BEL version string (e.g. +"2.0"+)
|
31
|
+
# @return [Boolean] +true+ if +version+ is defined; +false+ if not
|
32
|
+
def self.defines_version?(version)
|
33
|
+
specification(version)
|
34
|
+
true
|
35
|
+
rescue ArgumentError, LoadError
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns all version strings that are defined and supported by this
|
40
|
+
# project.
|
41
|
+
#
|
42
|
+
# @return [Array<String>] BEL language versions
|
43
|
+
def self.versions
|
44
|
+
Dir[
|
45
|
+
File.join(
|
46
|
+
File.expand_path('..', __FILE__),
|
47
|
+
'language',
|
48
|
+
'version*.rb'
|
49
|
+
)
|
50
|
+
].map do |path|
|
51
|
+
file_name = File.basename(path)
|
52
|
+
file_name.scan(/[0-9]+_[0-9]+/).first.sub('_', '.')
|
53
|
+
end.sort
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the latest supported version string according to the
|
57
|
+
# _MAJOR.MINOR_ pattern.
|
58
|
+
#
|
59
|
+
# @return [String] latest supported version
|
60
|
+
def self.latest_supported_version
|
61
|
+
versions.max_by { |version| version.to_f }
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns all language {Specification specifications}.
|
65
|
+
#
|
66
|
+
# @return [Array<Specification>] BEL specifications
|
67
|
+
def self.specifications
|
68
|
+
versions.map { |version| specification(version) }
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns the {Specification} for a BEL specification +version+.
|
72
|
+
#
|
73
|
+
# @param [#to_s] version the BEL version string (e.g. +"2.0"+)
|
74
|
+
# @return [Specification] the BEL specification
|
75
|
+
# @raise [ArgumentError] if the version string is malformed or is not
|
76
|
+
# supported
|
77
|
+
# @see {.defines?}
|
78
|
+
def self.specification(version)
|
79
|
+
version_string = version.to_s
|
80
|
+
unless version_string =~ /^[0-9]+\.[0-9]+/
|
81
|
+
raise ArgumentError, 'Version format incorrect; expecting MAJOR.MINOR'
|
82
|
+
end
|
83
|
+
|
84
|
+
LOCK.synchronize do
|
85
|
+
version_sym = version_string.to_sym
|
86
|
+
@specs ||= {}
|
87
|
+
@specs[version_sym] ||= create_specification(version_string)
|
88
|
+
@specs[version_sym]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Create the {Specification} for a BEL +version+.
|
93
|
+
#
|
94
|
+
# @param [String] version the BEL version string (e.g. +"2.0"+)
|
95
|
+
# @return [Specification] the BEL specification
|
96
|
+
# @raise [ArgumentError] if the version string is malformed or is not
|
97
|
+
# supported
|
98
|
+
# @see {.defines?}
|
99
|
+
def self.create_specification(version)
|
100
|
+
major, minor = version.split('.')
|
101
|
+
version_file = "language/version#{major}_#{minor}"
|
102
|
+
|
103
|
+
begin
|
104
|
+
require_relative version_file
|
105
|
+
version_const = :"Version#{major}_#{minor}"
|
106
|
+
version_module = BELParser::Language.const_get(version_const)
|
107
|
+
version_module::Specification.new
|
108
|
+
rescue LoadError
|
109
|
+
raise ArgumentError, "Version #{version} is not supported."
|
110
|
+
end
|
111
|
+
end
|
112
|
+
private_class_method :create_specification
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module BELParser
|
2
|
+
module Language
|
3
|
+
# AminoAcid defines a controlled vocabulary of twenty Amino Acids that are
|
4
|
+
# encoded by the universal genetic code. It does not contain the additional
|
5
|
+
# Amino Acids incorporated into proteins by synthetic means.
|
6
|
+
#
|
7
|
+
# see https://en.wikipedia.org/wiki/Amino_acid
|
8
|
+
module AminoAcid
|
9
|
+
Alanine = [:Alanine, :A, :Ala].freeze
|
10
|
+
Arginine = [:Arginine, :R, :Arg].freeze
|
11
|
+
Asparagine = [:Asparagine, :N, :Asn].freeze
|
12
|
+
AsparticAcid = [:'Aspartic Acid', :D, :Asp].freeze
|
13
|
+
Cysteine = [:Cysteine, :C, :Cys].freeze
|
14
|
+
GlutamicAcid = [:'Glutamic Acid', :E, :Glu].freeze
|
15
|
+
Glutamine = [:Glutamine, :Q, :Gln].freeze
|
16
|
+
Glycine = [:Glycine, :G, :Gly].freeze
|
17
|
+
Histidine = [:Histidine, :H, :His].freeze
|
18
|
+
Isoleucine = [:Isoleucine, :I, :Ile].freeze
|
19
|
+
Leucine = [:Leucine, :L, :Leu].freeze
|
20
|
+
Lysine = [:Lysine, :K, :Lys].freeze
|
21
|
+
Methionine = [:Methionine, :M, :Met].freeze
|
22
|
+
Phenylalanine = [:Phenylalanine, :F, :Phe].freeze
|
23
|
+
Proline = [:Proline, :P, :Pro].freeze
|
24
|
+
Serine = [:Serine, :S, :Ser].freeze
|
25
|
+
Threonine = [:Threonine, :T, :Thr].freeze
|
26
|
+
Tryptophan = [:Tryptophan, :W, :Trp].freeze
|
27
|
+
Tyrosine = [:Tyrosine, :Y, :Tyr].freeze
|
28
|
+
Valine = [:Valine, :V, :Val].freeze
|
29
|
+
|
30
|
+
# Determines if +sym+ represents an amino acid code.
|
31
|
+
#
|
32
|
+
# @param [#to_sym] sym amino acid code
|
33
|
+
# @return [Boolean] +true+ if +sym+ amino acid code is included in
|
34
|
+
# supported amino acids; +false+ if not supported
|
35
|
+
def self.includes?(sym)
|
36
|
+
@hash.key?(sym.to_sym)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Gets all supported amino acid names.
|
40
|
+
def self.names
|
41
|
+
@names
|
42
|
+
end
|
43
|
+
|
44
|
+
# Gets all supported amino acid codes (i.e. name, 1-Letter, 3-Letter).
|
45
|
+
def self.values
|
46
|
+
@values
|
47
|
+
end
|
48
|
+
|
49
|
+
unless defined? @hash
|
50
|
+
@hash = {}
|
51
|
+
constants.map(&method(:const_get)).each do |values|
|
52
|
+
@hash.update(
|
53
|
+
Hash[values.map { |v| [v, values.first] }]
|
54
|
+
)
|
55
|
+
end
|
56
|
+
@hash.freeze
|
57
|
+
end
|
58
|
+
|
59
|
+
unless defined? @names
|
60
|
+
@names = constants.map(&method(:const_get)).map(&:first).sort.freeze
|
61
|
+
end
|
62
|
+
|
63
|
+
unless defined? @values
|
64
|
+
@values = constants.map(&method(:const_get)).map(&:to_a).flatten.freeze
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'bel_parser/quoting'
|
2
|
+
|
3
|
+
module BELParser
|
4
|
+
module Language
|
5
|
+
# ApplyNamespaceEncoding applies _namespace_ and _encoding_ properties to
|
6
|
+
# {BELParser::Parsers::AST::Parameter} child nodes.
|
7
|
+
class ApplyNamespaceEncoding
|
8
|
+
include AST::Processor::Mixin
|
9
|
+
include BELParser::Quoting
|
10
|
+
|
11
|
+
def initialize(language_spec, namespace_hash, resource_reader)
|
12
|
+
@language_spec = language_spec
|
13
|
+
@namespace_hash = namespace_hash
|
14
|
+
@resource_reader = resource_reader
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_observed_term(observed_term_node)
|
18
|
+
process(observed_term_node.statement)
|
19
|
+
end
|
20
|
+
|
21
|
+
def on_simple_statement(simple_statement_node)
|
22
|
+
process(simple_statement_node.statement)
|
23
|
+
end
|
24
|
+
|
25
|
+
def on_nested_statement(nested_statement_node)
|
26
|
+
process(nested_statement_node.statement)
|
27
|
+
end
|
28
|
+
|
29
|
+
def on_statement(statement_node)
|
30
|
+
process(statement_node.subject)
|
31
|
+
process(statement_node.object) if statement_node.object?
|
32
|
+
end
|
33
|
+
|
34
|
+
def on_subject(subject_node)
|
35
|
+
process(subject_node.term)
|
36
|
+
end
|
37
|
+
|
38
|
+
def on_object(object_node)
|
39
|
+
process(object_node.child)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Called when visiting nodes of type +term+.
|
43
|
+
def on_term(term_node)
|
44
|
+
term_node.arguments.each do |argument_node|
|
45
|
+
process(argument_node)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def on_argument(argument_node)
|
50
|
+
process(argument_node.child)
|
51
|
+
end
|
52
|
+
|
53
|
+
def on_parameter(parameter_node)
|
54
|
+
@resolved_dataset = nil
|
55
|
+
@prefix = nil
|
56
|
+
process(parameter_node.prefix)
|
57
|
+
process(parameter_node.value)
|
58
|
+
end
|
59
|
+
|
60
|
+
def on_prefix(prefix_node)
|
61
|
+
return prefix_node unless prefix_node.identifier
|
62
|
+
|
63
|
+
@prefix = prefix_node.identifier.string_literal
|
64
|
+
dataset = @namespace_hash[@prefix]
|
65
|
+
return prefix_node unless dataset
|
66
|
+
|
67
|
+
@resolved_dataset = dataset
|
68
|
+
prefix_node.namespace = dataset
|
69
|
+
|
70
|
+
prefix_node
|
71
|
+
end
|
72
|
+
|
73
|
+
def on_value(value_node)
|
74
|
+
return value_node unless @resolved_dataset
|
75
|
+
value_node.namespace = @resolved_dataset
|
76
|
+
identifier = @resolved_dataset.identifier
|
77
|
+
value_literal = unquote(value_node.children[0].string_literal)
|
78
|
+
|
79
|
+
value =
|
80
|
+
@resource_reader
|
81
|
+
.retrieve_value_from_resource(identifier, value_literal)
|
82
|
+
|
83
|
+
value_node.prefix = @prefix
|
84
|
+
if value
|
85
|
+
value_node.encoding =
|
86
|
+
value
|
87
|
+
.encodings
|
88
|
+
.map(&@language_spec.method(:value_encoding))
|
89
|
+
value_node.namespace_value = value
|
90
|
+
else
|
91
|
+
value_node.encoding = nil
|
92
|
+
value_node.namespace_value = nil
|
93
|
+
end
|
94
|
+
value_node
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require_relative 'specification'
|
2
|
+
|
3
|
+
module BELParser
|
4
|
+
module Language
|
5
|
+
# BaseSpecification defines behaviour for loading BEL version files.
|
6
|
+
class BaseSpecification
|
7
|
+
include Specification
|
8
|
+
|
9
|
+
def self.load_version_path(version_path)
|
10
|
+
base_path = File.expand_path(File.dirname(__FILE__)) + File::SEPARATOR
|
11
|
+
['return_types', 'value_encodings', 'functions', 'relationships']
|
12
|
+
.each do |set|
|
13
|
+
Dir[File.join(base_path, version_path, set, '*.rb')]
|
14
|
+
.each do |ruby_file|
|
15
|
+
ruby_file.sub!(/^#{Regexp.escape(base_path)}/, '')
|
16
|
+
require_relative ruby_file
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def load_language_constants(version_module)
|
24
|
+
load_return_types(version_module)
|
25
|
+
load_value_encodings(version_module)
|
26
|
+
load_functions(version_module)
|
27
|
+
load_relationships(version_module)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def load_return_types(version_module)
|
33
|
+
# Collect return types
|
34
|
+
ret_classes =
|
35
|
+
version_module::ReturnTypes.constants.collect do |symbol|
|
36
|
+
const = version_module::ReturnTypes.const_get(symbol)
|
37
|
+
const if const.respond_to?(:subtypes)
|
38
|
+
end
|
39
|
+
@return_types = ret_classes.compact
|
40
|
+
@indexed_return_types = index_sym(@return_types)
|
41
|
+
end
|
42
|
+
|
43
|
+
def load_value_encodings(version_module)
|
44
|
+
# Collect value encodings
|
45
|
+
enc_classes =
|
46
|
+
version_module::ValueEncodings.constants.collect do |symbol|
|
47
|
+
const = version_module::ValueEncodings.const_get(symbol)
|
48
|
+
const if const.respond_to?(:subtypes)
|
49
|
+
end
|
50
|
+
@value_encodings = enc_classes.compact
|
51
|
+
@indexed_value_encodings = index_sym(@value_encodings)
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_functions(version_module)
|
55
|
+
# Collect functions
|
56
|
+
function_classes =
|
57
|
+
version_module::Functions.constants.collect do |symbol|
|
58
|
+
const = version_module::Functions.const_get(symbol)
|
59
|
+
const if
|
60
|
+
const.respond_to?(:short) &&
|
61
|
+
const.respond_to?(:long)
|
62
|
+
end
|
63
|
+
@functions = function_classes.compact
|
64
|
+
@indexed_functions = index_long_short(@functions)
|
65
|
+
end
|
66
|
+
|
67
|
+
def load_relationships(version_module)
|
68
|
+
# Collect relationships
|
69
|
+
rel_classes =
|
70
|
+
version_module::Relationships.constants.collect do |symbol|
|
71
|
+
const = version_module::Relationships.const_get(symbol)
|
72
|
+
const if
|
73
|
+
const.respond_to?(:short) &&
|
74
|
+
const.respond_to?(:long)
|
75
|
+
end
|
76
|
+
@relationships = rel_classes.compact
|
77
|
+
@indexed_relationships = index_long_short(@relationships)
|
78
|
+
assign_relationship_categories(@relationships)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|