Module: Bioroebe

Included in:
Taxonomy::Interactive
Defined in:
lib/bioroebe/svg/page.rb,
lib/bioroebe/base/base.rb,
lib/bioroebe/cell/cell.rb,
lib/bioroebe/gene/gene.rb,
lib/bioroebe/ncbi/ncbi.rb,
lib/bioroebe/svg/glyph.rb,
lib/bioroebe/svg/svgee.rb,
lib/bioroebe/svg/track.rb,
lib/bioroebe/misc/ruler.rb,
lib/bioroebe/shell/menu.rb,
lib/bioroebe/ncbi/efetch.rb,
lib/bioroebe/parsers/gff.rb,
lib/bioroebe/shell/shell.rb,
lib/bioroebe/siRNA/siRNA.rb,
lib/bioroebe/virus/virus.rb,
lib/bioroebe/base/colours.rb,
lib/bioroebe/sequence/dna.rb,
lib/bioroebe/sequence/rna.rb,
lib/bioroebe/blosum/blosum.rb,
lib/bioroebe/codons/codons.rb,
lib/bioroebe/genome/genome.rb,
lib/bioroebe/svg/primitive.rb,
lib/bioroebe/taxonomy/edit.rb,
lib/bioroebe/taxonomy/menu.rb,
lib/bioroebe/taxonomy/node.rb,
lib/bioroebe/biomart/filter.rb,
lib/bioroebe/biomart/server.rb,
lib/bioroebe/constants/GUIs.rb,
lib/bioroebe/count/count_at.rb,
lib/bioroebe/count/count_gc.rb,
lib/bioroebe/shell/readline.rb,
lib/bioroebe/taxonomy/chart.rb,
lib/bioroebe/biomart/biomart.rb,
lib/bioroebe/biomart/dataset.rb,
lib/bioroebe/colours/colours.rb,
lib/bioroebe/project/project.rb,
lib/bioroebe/regexes/regexes.rb,
lib/bioroebe/taxonomy/shared.rb,
lib/bioroebe/version/version.rb,
lib/bioroebe/biomart/database.rb,
lib/bioroebe/dotplots/dotplot.rb,
lib/bioroebe/sequence/protein.rb,
lib/bioroebe/shell/help/class.rb,
lib/bioroebe/svg/mini_feature.rb,
lib/bioroebe/taxonomy/colours.rb,
lib/bioroebe/abstract/features.rb,
lib/bioroebe/biomart/attribute.rb,
lib/bioroebe/encoding/encoding.rb,
lib/bioroebe/readline/readline.rb,
lib/bioroebe/sequence/sequence.rb,
lib/bioroebe/taxonomy/taxonomy.rb,
lib/bioroebe/codons/codon_table.rb,
lib/bioroebe/parsers/parse_embl.rb,
lib/bioroebe/sequence/alignment.rb,
lib/bioroebe/taxonomy/constants.rb,
lib/bioroebe/taxonomy/help/help.rb,
lib/bioroebe/taxonomy/info/info.rb,
lib/bioroebe/codons/codon_tables.rb,
lib/bioroebe/codons/start_codons.rb,
lib/bioroebe/colours/use_colours.rb,
lib/bioroebe/constants/constants.rb,
lib/bioroebe/misc/useful_formulas.rb,
lib/bioroebe/patterns/rgg_scanner.rb,
lib/bioroebe/taxonomy/info/is_dna.rb,
lib/bioroebe/taxonomy/interactive.rb,
lib/bioroebe/taxonomy/parse_fasta.rb,
lib/bioroebe/exceptions/exceptions.rb,
lib/bioroebe/parsers/blosum_parser.rb,
lib/bioroebe/parsers/stride_parser.rb,
lib/bioroebe/requires/require_yaml.rb,
lib/bioroebe/genomes/genome_pattern.rb,
lib/bioroebe/parsers/biolang_parser.rb,
lib/bioroebe/parsers/genbank_parser.rb,
lib/bioroebe/taxonomy/class_methods.rb,
lib/bioroebe/taxonomy/help/helpline.rb,
lib/bioroebe/toplevel_methods/roebe.rb,
lib/bioroebe/codons/show_codon_usage.rb,
lib/bioroebe/configuration/constants.rb,
lib/bioroebe/sinatra/sinatra_wrapper.rb,
lib/bioroebe/base/prototype/prototype.rb,
lib/bioroebe/cleave_and_digest/cleave.rb,
lib/bioroebe/codons/show_codon_tables.rb,
lib/bioroebe/genomes/genome_retriever.rb,
lib/bioroebe/patterns/profile_pattern.rb,
lib/bioroebe/patterns/scan_for_repeat.rb,
lib/bioroebe/requires/require_colours.rb,
lib/bioroebe/www/embeddable_interface.rb,
lib/bioroebe/cleave_and_digest/trypsin.rb,
lib/bioroebe/dotplots/advanced_dotplot.rb,
lib/bioroebe/electron_microscopy/flipy.rb,
lib/bioroebe/raw_sequence/raw_sequence.rb,
lib/bioroebe/sinatra/sinatra_interface.rb,
lib/bioroebe/toplevel_methods/taxonomy.rb,
lib/bioroebe/utility_scripts/find_gene.rb,
lib/bioroebe/viennarna/rnafold_wrapper.rb,
lib/bioroebe/colours/colourize_sequence.rb,
lib/bioroebe/enzymes/restriction_enzyme.rb,
lib/bioroebe/aminoacids/codon_percentage.rb,
lib/bioroebe/cleave_and_digest/digestion.rb,
lib/bioroebe/codons/detect_minimal_codon.rb,
lib/bioroebe/configuration/configuration.rb,
lib/bioroebe/log_directory/log_directory.rb,
lib/bioroebe/sequence/reverse_complement.rb,
lib/bioroebe/string_matching/levensthein.rb,
lib/bioroebe/base/base_module/base_module.rb,
lib/bioroebe/codons/show_this_codon_table.rb,
lib/bioroebe/colours/colour_schemes/score.rb,
lib/bioroebe/fasta_and_fastq/fasta_parser.rb,
lib/bioroebe/cell/specialized_cells/B_cell.rb,
lib/bioroebe/cell/specialized_cells/T_cell.rb,
lib/bioroebe/colours/colour_schemes/simple.rb,
lib/bioroebe/ngs/phred_quality_score_table.rb,
lib/bioroebe/palindromes/palindrome_finder.rb,
lib/bioroebe/taxonomy/info/check_available.rb,
lib/bioroebe/utility_scripts/punnet/punnet.rb,
lib/bioroebe/aminoacids/show_hydrophobicity.rb,
lib/bioroebe/calculate/calculate_gc_content.rb,
lib/bioroebe/colours/colourize_related_code.rb,
lib/bioroebe/fasta_and_fastq/download_fasta.rb,
lib/bioroebe/requires/require_all_pdb_files.rb,
lib/bioroebe/string_matching/smith_waterman.rb,
lib/bioroebe/codons/determine_optimal_codons.rb,
lib/bioroebe/codons/sanitize_codon_frequency.rb,
lib/bioroebe/gui/universal_widgets/gene/gene.rb,
lib/bioroebe/matplotlib/matplotlib_generator.rb,
lib/bioroebe/utility_scripts/compseq/compseq.rb,
lib/bioroebe/utility_scripts/showorf/showorf.rb,
lib/bioroebe/aminoacids/aminoacids_mass_table.rb,
lib/bioroebe/calculate/calculate_blosum_score.rb,
lib/bioroebe/count/count_amount_of_aminoacids.rb,
lib/bioroebe/electron_microscopy/fix_pos_file.rb,
lib/bioroebe/enzymes/restriction_enzymes_file.rb,
lib/bioroebe/enzymes/show_restriction_enzymes.rb,
lib/bioroebe/palindromes/palindrome_generator.rb,
lib/bioroebe/requires/require_all_codon_files.rb,
lib/bioroebe/requires/require_all_count_files.rb,
lib/bioroebe/string_matching/hamming_distance.rb,
lib/bioroebe/toplevel_methods/fasta_and_fastq.rb,
lib/bioroebe/aminoacids/aminoacid_substitution.rb,
lib/bioroebe/cell/specialized_cells/Macrophage.rb,
lib/bioroebe/colours/colour_schemes/nucleotide.rb,
lib/bioroebe/count/count_amount_of_nucleotides.rb,
lib/bioroebe/electron_microscopy/read_file_xmd.rb,
lib/bioroebe/gui/universal_widgets/shell/shell.rb,
lib/bioroebe/requires/require_all_parser_files.rb,
lib/bioroebe/toplevel_methods/toplevel_methods.rb,
lib/bioroebe/utility_scripts/pathways/pathways.rb,
lib/bioroebe/aminoacids/display_aminoacid_table.rb,
lib/bioroebe/fasta_and_fastq/show_fasta_headers.rb,
lib/bioroebe/gui/experimental/snapgene/snapgene.rb,
lib/bioroebe/requires/require_all_dotplot_files.rb,
lib/bioroebe/requires/require_all_enzymes_files.rb,
lib/bioroebe/requires/require_all_pattern_files.rb,
lib/bioroebe/requires/require_cleave_and_digest.rb,
lib/bioroebe/aminoacids/create_random_aminoacids.rb,
lib/bioroebe/enzymes/has_this_restriction_enzyme.rb,
lib/bioroebe/misc/quiz/three_letter_to_aminoacid.rb,
lib/bioroebe/palindromes/palindrome_2D_structure.rb,
lib/bioroebe/requires/require_all_sequence_files.rb,
lib/bioroebe/requires/require_all_taxonomy_files.rb,
lib/bioroebe/utility_scripts/compacter/compacter.rb,
lib/bioroebe/aminoacids/deduce_aminoacid_sequence.rb,
lib/bioroebe/annotations/create_annotation_format.rb,
lib/bioroebe/colours/colour_schemes/colour_scheme.rb,
lib/bioroebe/conversions/convert_aminoacid_to_dna.rb,
lib/bioroebe/databases/download_taxonomy_database.rb,
lib/bioroebe/nucleotides/complementary_dna_strand.rb,
lib/bioroebe/requires/require_all_calculate_files.rb,
lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb,
lib/bioroebe/electron_microscopy/parse_coordinates.rb,
lib/bioroebe/fasta_and_fastq/show_fasta_statistics.rb,
lib/bioroebe/gui/universal_widgets/sizeseq/sizeseq.rb,
lib/bioroebe/pdb_and_protein_structure/alpha_helix.rb,
lib/bioroebe/requires/require_all_aminoacids_files.rb,
lib/bioroebe/requires/require_the_toplevel_methods.rb,
lib/bioroebe/utility_scripts/analyse_local_dataset.rb,
lib/bioroebe/base/colours_for_base/colours_for_base.rb,
lib/bioroebe/enzymes/restriction_enzymes/statistics.rb,
lib/bioroebe/fasta_and_fastq/fastq_format_explainer.rb,
lib/bioroebe/patterns/analyse_glycosylation_pattern.rb,
lib/bioroebe/requires/require_all_nucleotides_files.rb,
lib/bioroebe/requires/require_all_palindromes_files.rb,
lib/bioroebe/string_matching/find_longest_substring.rb,
lib/bioroebe/string_matching/simple_string_comparer.rb,
lib/bioroebe/calculate/calculate_melting_temperature.rb,
lib/bioroebe/electron_microscopy/coordinate_analyzer.rb,
lib/bioroebe/electron_microscopy/generate_em2em_file.rb,
lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb,
lib/bioroebe/fasta_and_fastq/parse_fastq/parse_fastq.rb,
lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb,
lib/bioroebe/calculate/calculate_levensthein_distance.rb,
lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb,
lib/bioroebe/patterns/is_this_sequence_a_EGF2_pattern.rb,
lib/bioroebe/pdb_and_protein_structure/parse_pdb_file.rb,
lib/bioroebe/requires/require_all_colour_scheme_files.rb,
lib/bioroebe/codons/possible_codons_for_this_aminoacid.rb,
lib/bioroebe/colours/colour_schemes/colour_scheme_demo.rb,
lib/bioroebe/gui/universal_widgets/alignment/alignment.rb,
lib/bioroebe/utility_scripts/align_open_reading_frames.rb,
lib/bioroebe/utility_scripts/permutations/permutations.rb,
lib/bioroebe/genbank/genbank_flat_file_format_generator.rb,
lib/bioroebe/pdb_and_protein_structure/parse_mmCIF_file.rb,
lib/bioroebe/requires/require_all_fasta_and_fastq_files.rb,
lib/bioroebe/requires/require_all_string_matching_files.rb,
lib/bioroebe/requires/require_all_utility_scripts_files.rb,
lib/bioroebe/codons/convert_this_codon_to_that_aminoacid.rb,
lib/bioroebe/fasta_and_fastq/fasta_defline/fasta_defline.rb,
lib/bioroebe/fasta_and_fastq/fasta_to_yaml/fasta_to_yaml.rb,
lib/bioroebe/gui/universal_widgets/controller/controller.rb,
lib/bioroebe/gui/universal_widgets/www_finder/www_finder.rb,
lib/bioroebe/nucleotides/molecular_weight_of_nucleotides.rb,
lib/bioroebe/pdb_and_protein_structure/download_this_pdb.rb,
lib/bioroebe/utility_scripts/dot_alignment/dot_alignment.rb,
lib/bioroebe/utility_scripts/mirror_repeat/mirror_repeat.rb,
lib/bioroebe/sequence/nucleotide_module/nucleotide_module.rb,
lib/bioroebe/utility_scripts/parse_taxonomy/parse_taxonomy.rb,
lib/bioroebe/virus/individual_viruses/tobacco_mosaic_virus.rb,
lib/bioroebe/base/internal_hash_module/internal_hash_module.rb,
lib/bioroebe/codon_tables/frequencies/parse_frequency_table.rb,
lib/bioroebe/electron_microscopy/electron_microscopy_module.rb,
lib/bioroebe/electron_microscopy/simple_star_file_generator.rb,
lib/bioroebe/requires/require_all_electron_microscopy_files.rb,
lib/bioroebe/fasta_and_fastq/length_modifier/length_modifier.rb,
lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb,
lib/bioroebe/utility_scripts/display_open_reading_frames/menu.rb,
lib/bioroebe/utility_scripts/display_open_reading_frames/misc.rb,
lib/bioroebe/utility_scripts/display_open_reading_frames/reset.rb,
lib/bioroebe/utility_scripts/move_file_to_its_correct_location.rb,
lib/bioroebe/base/commandline_application/commandline_arguments.rb,
lib/bioroebe/utility_scripts/display_open_reading_frames/report.rb,
lib/bioroebe/gui/universal_widgets/parse_pdb_file/parse_pdb_file.rb,
lib/bioroebe/gui/universal_widgets/protein_to_DNA/protein_to_DNA.rb,
lib/bioroebe/base/commandline_application/commandline_application.rb,
lib/bioroebe/fasta_and_fastq/return_fasta_subsection_of_this_file.rb,
lib/bioroebe/colours/colour_schemes/array_available_colour_schemes.rb,
lib/bioroebe/fasta_and_fastq/compact_fasta_file/compact_fasta_file.rb,
lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb,
lib/bioroebe/utility_scripts/consensus_sequence/consensus_sequence.rb,
lib/bioroebe/utility_scripts/display_open_reading_frames/determine.rb,
lib/bioroebe/utility_scripts/compare_these_two_sequences_via_blosum.rb,
lib/bioroebe/utility_scripts/display_open_reading_frames/initialize.rb,
lib/bioroebe/fasta_and_fastq/autocorrect_the_name_of_this_fasta_file.rb,
lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb,
lib/bioroebe/gui/universal_widgets/hamming_distance/hamming_distance.rb,
lib/bioroebe/gui/universal_widgets/show_codon_table/show_codon_table.rb,
lib/bioroebe/gui/universal_widgets/show_codon_usage/show_codon_usage.rb,
lib/bioroebe/pdb_and_protein_structure/fetch_fasta_sequence_from_pdb.rb,
lib/bioroebe/calculate/calculate_the_position_specific_scoring_matrix.rb,
lib/bioroebe/string_matching/find_longest_substring_via_LCS_algorithm.rb,
lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb,
lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb,
lib/bioroebe/base/infer_the_namespace_module/infer_the_namespace_module.rb,
lib/bioroebe/enzymes/return_sequence_that_is_cut_via_restriction_enzyme.rb,
lib/bioroebe/aminoacids/colourize_hydrophilic_and_hydrophobic_aminoacids.rb,
lib/bioroebe/enzymes/return_restriction_enzyme_sequence_and_cut_position.rb,
lib/bioroebe/fasta_and_fastq/simplify_fasta_header/simplify_fasta_header.rb,
lib/bioroebe/fasta_and_fastq/split_this_fasta_file_into_chromosomes/menu.rb,
lib/bioroebe/fasta_and_fastq/split_this_fasta_file_into_chromosomes/misc.rb,
lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb,
lib/bioroebe/fasta_and_fastq/split_this_fasta_file_into_chromosomes/reset.rb,
lib/bioroebe/gui/universal_widgets/aminoacid_composition/customized_dialog.rb,
lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb,
lib/bioroebe/gui/universal_widgets/restriction_enzymes/restriction_enzymes.rb,
lib/bioroebe/nucleotides/show_nucleotide_sequence/show_nucleotide_sequence.rb,
lib/bioroebe/utility_scripts/show_this_dna_sequence/show_this_dna_sequence.rb,
lib/bioroebe/gui/universal_widgets/blosum_matrix_viewer/blosum_matrix_viewer.rb,
lib/bioroebe/gui/universal_widgets/levensthein_distance/levensthein_distance.rb,
lib/bioroebe/gui/universal_widgets/primer_design_widget/primer_design_widget.rb,
lib/bioroebe/utility_scripts/fetch_data_from_uniprot/fetch_data_from_uniprot.rb,
lib/bioroebe/fasta_and_fastq/split_this_fasta_file_into_chromosomes/constants.rb,
lib/bioroebe/gui/universal_widgets/aminoacid_composition/aminoacid_composition.rb,
lib/bioroebe/utility_scripts/create_batch_entrez_file/create_batch_entrez_file.rb,
lib/bioroebe/utility_scripts/determine_antigenic_areas/determine_antigenic_areas.rb,
lib/bioroebe/fasta_and_fastq/display_how_many_fasta_entries_are_in_this_directory.rb,
lib/bioroebe/gui/universal_widgets/dna_to_aminoacid_widget/dna_to_aminoacid_widget.rb,
lib/bioroebe/utility_scripts/download_files_from_rebase/download_files_from_rebase.rb,
lib/bioroebe/nucleotides/most_likely_nucleotide_sequence_for_this_aminoacid_sequence.rb,
lib/bioroebe/utility_scripts/display_open_reading_frames/display_open_reading_frames.rb,
lib/bioroebe/pdb_and_protein_structure/report_secondary_structures_from_this_pdb_file.rb,
lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb,
lib/bioroebe/gui/universal_widgets/dna_to_reverse_complement_widget/dna_to_reverse_complement_widget.rb,
lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb,
lib/bioroebe/fasta_and_fastq/split_this_fasta_file_into_chromosomes/split_this_fasta_file_into_chromosomes.rb,
lib/bioroebe/utility_scripts/determine_missing_nucleotides_percentage/determine_missing_nucleotides_percentage.rb

Overview

#

require ‘bioroebe/fasta/split_this_fasta_file_into_chromosomes/constants.rb’

#

Defined Under Namespace

Modules: BaseModule, Biomart, Blosum, CodonTable, CodonTables, CodonTablesFrequencies, ColourScheme, Colourize, ColoursForBase, CommandlineArguments, Configuration, ElectronMicroscopy, EmbeddableInterface, Features, GUI, InferTheNamespaceModule, InternalHashModule, MolecularWeightOfNucleotides, NucleotideModule, Parser, Postgresql, Quiz, RestrictionEnzymes, SinatraInterface, Taxonomy, VerboseTruth Classes: AdvancedDotplot, AlignOpenReadingFrames, Alignment, AlphaHelix, AminoacidSubstitution, AminoacidsMassTable, AnalyseGlycosylationPattern, AnalyseLocalDataset, AutocorrectTheNameOfThisFastaFile, B_cell, Base, BiolangParser, BlosumParser, CalculateBlosumScore, CalculateGCContent, CalculateMeltingTemperature, CalculateMeltingTemperatureForMoreThanThirteenNucleotides, CalculateThePositionSpecificScoringMatrix, Cell, CheckForMismatches, CodonPercentage, ColourSchemeDemo, ColourizeHydrophilicAndHydrophobicAminoacids, ColourizeSequence, CommandlineApplication, CompactFastaFile, Compacter, CompareTheseTwoSequencesViaBlosum, ComplementaryDnaStrand, Compseq, ConsensusSequence, ConvertAminoacidToDNA, ConvertThisCodonToThatAminoacid, CountAmountOfAminoacids, CountAmountOfNucleotides, CreateAnnotationFormat, CreateBatchEntrezFile, CreateRandomAminoacids, DNA, DeduceAminoacidSequence, DetectMinimalCodon, DetermineAntigenicAreas, DetermineMissingNucleotidesPercentage, DetermineOptimalCodons, Digestion, DisplayAminoacidTable, DisplayHowManyFastaEntriesAreInThisDirectory, DisplayOpenReadingFrames, DnaToAminoacidSequence, DotAlignment, Dotplot, DownloadFasta, DownloadFilesFromRebase, DownloadTaxonomyDatabase, FastaDefline, FastaParser, FastaToYaml, FastqFormatExplainer, FetchDataFromUniprot, FetchFastaSequenceFromPdb, FindGene, FindLongestSubstring, FindLongestSubstringViaLCSalgorithm, GenbankFlatFileFormatGenerator, GenbankParser, Gene, Genome, GenomePattern, GenomeRetriever, HammingDistance, HelixWheel, InvalidAminoacid, LengthModifier, Levensthein, Macrophage, MatplotlibGenerator, Matrix, MirrorRepeat, MostLikelyNucleotideSequenceForThisAminoacidSequence, MoveFileToItsCorrectLocation, Ncbi, Palindrome2DStructure, PalindromeFinder, PalindromeGenerator, ParseEMBL, ParseFasta, ParseFastq, ParseFrequencyTable, ParsePdbFile, ParseTaxonomy, ParsemmCIFFile, Pathways, Permutations, PhredQualityScoreTable, PossibleCodonsForThisAminoacid, ProfilePattern, Protein, Punnet, RGG_Scanner, RNA, RNALfoldWrapper, RawSequence, ReportSecondaryStructuresFromThisPdbFile, RestrictionEnzyme, ReverseComplement, Ruler, SVG, SanitizeCodonFrequency, SanitizeNucleotideSequence, ScanForRepeat, Sequence, Shell, ShowCodonTables, ShowCodonUsage, ShowFastaHeaders, ShowFastaStatistics, ShowHydrophobicity, ShowNucleotideSequence, ShowOrf, ShowRestrictionEnzymes, ShowThisCodonTable, ShowThisDNASequence, SiRNA, SimpleStringComparer, SimplifyFastaHeader, SinatraWrapper, SmithWaterman, SplitThisFastaFileIntoChromosomes, StrideParser, T_cell, TobaccoMosaicVirus, Trypsin, UsefulFormulas, Virus

Constant Summary collapse

USE_THIS_COLOUR_FOR_DNA =
#

Bioroebe::USE_THIS_COLOUR_FOR_DNA

The following constant will denote which colour we will use for DNA sequences by default, in this case, the HTML colour called steelblue.

#
:steelblue
FILE_EXPAND_CD_ALIASES =
#

FILE_EXPAND_CD_ALIASES

#
"#{@project_base_directory}hash_expand_cd_aliases.rb"
CONFIGURATION_DIRECTORY =
#

CONFIGURATION_DIRECTORY

#
"#{project_yaml_directory?}configuration/"
TOPLEVEL_METHODS_DIRECTORY =
#

TOPLEVEL_METHODS_DIRECTORY

#
"#{@project_base_directory}toplevel_methods/"
CODON_TABLES_DIRECTORY =
#

CODON_TABLES_DIRECTORY

#
"#{@project_base_directory}codon_tables/"
CLEAVE_AND_DIGEST_DIRECTORY =
#

CLEAVE_AND_DIGEST_DIRECTORY

#
"#{@project_base_directory}cleave_and_digest/"
ELECTRON_MICROSCOPY_DIRECTORY =
#

ELECTRON_MICROSCOPY_DIRECTORY

#
"#{@project_base_directory}electron_microscopy/"
CODON_TABLES_DIRECTORY_FREQUENCY =
#

CODON_TABLES_DIRECTORY_FREQUENCY

#
"#{CODON_TABLES_DIRECTORY}frequencies/"
PDB_DIRECTORY =
#

PDB_DIRECTORY

This is called pdb_and_protein_structure/ since as of November 2023.

#
"#{@project_base_directory}pdb_and_protein_structure/"
PARSERS_DIRECTORY =
#

PARSERS_DIRECTORY

#
"#{@project_base_directory}parsers/"
ENZYMES_DIRECTORY =
#

ENZYMES_DIRECTORY

#
"#{@project_base_directory}enzymes/"
PALINDROMES_DIRECTORY =
#

PALINDROMES_DIRECTORY

#
"#{@project_base_directory}palindromes/"
PATTERN_DIRECTORY =
#

PATTERN_DIRECTORY

#
"#{@project_base_directory}pattern/"
NUCLEOTIDES_DIRECTORY =
#

NUCLEOTIDES_DIRECTORY

#
"#{@project_base_directory}nucleotides/"
COUNT_DIRECTORY =
#

COUNT_DIRECTORY

#
"#{@project_base_directory}count/"
AMINOACIDS_DIRECTORY =
#

AMINOACIDS_DIRECTORY

#
"#{@project_base_directory}aminoacids/"
BLOSUM_DIRECTORY =
#

BLOSUM_DIRECTORY

#
"#{project_yaml_directory?}blosum/"
CALCULATE_DIRECTORY =
#

CALCULATE_DIRECTORY

#
"#{@project_base_directory}calculate/"
CODONS_DIRECTORY =
#

CODONS_DIRECTORY

#
"#{@project_base_directory}codons/"
DOTPLOTS_DIRECTORY =
#

DOTPLOTS_DIRECTORY

#
"#{@project_base_directory}dotplots/"
SEQUENCE_DIRECTORY =
#

SEQUENCE_DIRECTORY

#
"#{@project_base_directory}sequence/"
PATHWAYS_DIRECTORY =
#

PATHWAYS_DIRECTORY

This constant will point to e. g. “/Programs/Ruby/2.6.4/lib/ruby/site_ruby/2.6.0/bioroebe/yaml/pathways/”.

#
"#{project_yaml_directory?}pathways/"
BIOROEBE_YAML_AMINOACIDS_DIRECTORY =
#

BIOROEBE_YAML_AMINOACIDS_DIRECTORY

#
"#{project_yaml_directory?}aminoacids/"
STRING_MATCHING_DIRECTORY =
#

STRING_MATCHING_DIRECTORY

#
"#{@project_base_directory}string_matching/"
FASTA_AND_FASTQ_DIRECTORY =
#

FASTA_AND_FASTQ_DIRECTORY

#
"#{@project_base_directory}fasta_and_fastq/"
VERSION =
#

VERSION

#
'0.13.32'
LAST_UPDATE =
#

LAST_UPDATE

This variable keeps track as to when the bioroebe project was last updated. The notation is: DD.MM.YYYY

#
'09.04.2024'
URL_TO_THE_DOCUMENTATION =
#

URL_TO_THE_DOCUMENTATION

Keep track of where the documentation to BioRoebe is kept at.

#
"https://www.rubydoc.info/gems/#{self.to_s.downcase}/#{VERSION}"
Aminoacids =
#

The following “alias” was added in May 2022.

#
Protein
UTF_ENCODING =
#

Bioroebe::UTF_ENCODING

#
'UTF-8'
USE_THIS_ENCODING =
#

Bioroebe::USE_THIS_ENCODING

#
UTF_ENCODING
Seq =
#

Usage example

x = Bioroebe::Seq.new(‘AGTACACTGGT’)

#
Sequence
N =
#

Bioroebe::N

#
"\n"
R =
#

Bioroebe::R

#
"\r"
TABULATOR =
#

TABULATOR

#
"\t"
ROW_TERMINATOR =
#

Bioroebe::ROW_TERMINATOR

This constant is not often in use, though.

#
"#{TABULATOR}|\n"
BE_VERBOSE =
#

BE_VERBOSE

#
true
TOKEN =
#

TOKEN (TOKEN tag)

#
'|'
ARRAY_AMINOACIDS_THAT_CAN_BE_PHOSPHORYLATED =
#

ARRAY_AMINOACIDS_THAT_CAN_BE_PHOSPHORYLATED

Just list the aminoacids that can typically be phosphorylated.

#
%w(
  S Y T
)
ENGLISH_LONG_NAMES_FOR_THE_AMINO_ACIDS =
#

ENGLISH_LONG_NAMES_FOR_THE_AMINO_ACIDS

We have to keep the long names for the amino acids in one constant, so that we can do queries lateron.

#
(%w( 
  Alanine
  Arginine
  Asparagine
  Cysteine
  Glutamine
  Glycine
  Histidine
  Isoleucine
  Leucine
  Lysine
  Methionine
  Phenylalanine
  Proline
  Serine
  Threonine
  Tryptophane
  Tyrosine
  Valine
) << 'Aspartic acid' << 'Glutamic acid').sort
POSSIBLE_AMINO_ACIDS =
#

POSSIBLE_AMINO_ACIDS

Which Aminoacids are possible/allowed? We will list them here:

ACDEFGHIKLMNPQRSTUVWY

Note that this is distinct from the constant AMINO_ACIDS, which is instead loaded from a local .yml file. This constant includes all the 20 canonical aminoacids, whereas AMINO_ACIDS may also include pyrrolysine and selenocysteine.

#
'ACDEFGHIKLMNPQRSTVWY'
TWENTY_CANONICAL_AMINOACIDS =

TWENTY_CANONICAL_AMINOACIDS

POSSIBLE_AMINO_ACIDS
ARRAY_AMINO_ACIDS_ALPHABET =
#

ARRAY_AMINO_ACIDS_ALPHABET

This keeps an Array with all aminoacids, in one-letter format.

So it is equivalent to:

["A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y"]
#
POSSIBLE_AMINO_ACIDS.chars
VERTICAL_UNICODE_BAR =
#

VERTICAL_UNICODE_BAR

#
'|'
AMINOACID_FAMILIES =
#

AMINOACID_FAMILIES

#
{
  'citratzyklus' => {
    # Alpha-Ketoglutarat: EPQR
    'alpha-ketoglutarat' => %w( E P Q R ),
    # Oxalacetat: DMN-KTI
    'oxalacetat' => %w( D N K M T I ),
  },
  'glykolyse' => {
    'pyruvat' => %w( A V L ),                 # AVL
    '3-phosphoglycerinsäure' => %w( S G C ), # SGC
    },
    'chorismat' => {
      'aromatische_familie' => %w( F Y W )       # FYW
    },
    'ribose-5-p' => {
      'histidinol' => %w( H ) # Histidine.
    },
}
VALID_WAYS_TO_EXIT =
#

VALID_WAYS_TO_EXIT

All ways to exit will be recorded here.

If you need to use more ways, simply append to this Array.

This constant may have to be moved into the bio-shell part eventually.

#
%w(
  quit q exit qq :q qt
  bye
  rda
  r2
  tq
  sq
  exit_program
  exitprogram
)
NAMES_ENTRIES =
#

NAMES_ENTRIES

This used to belong to the Taxonomy submodule.

#
'names.sql'
NODES_ENTRIES =
#

NODES_ENTRIES

This used to belong to the Taxonomy submodule.

#
'nodes.sql'
FASTA_ENTRIES =
#

FASTA_ENTRIES

This used to belong to the Taxonomy submodule.

#
'fasta.sql'
SHALL_WE_LOG_LAST_UPDATE =
#

SHALL_WE_LOG_LAST_UPDATE

This constant exists specifically for the taxonomy-component of the Bioroebe project.

#
true
NAME_OF_BIO_SHELL =
#

NAME_OF_BIO_SHELL

This constant can be used as the default prompt for the bioshell component.

#
'BIO SHELL> '
DEFAULT_DNA_SEQUENCE =
#

DEFAULT_DNA_SEQUENCE

This is a default “test” DNA sequence, in the sense that it can be used to quickly test functionality within the bioroebe project.

It was added in May 2020, but it may be that we have to remove it at a later time, or move it into a separate .yml file. For the time being, though, it will reside here.

#
'CGGCCCGATTTGGGTTTCGGAGCGATCGAAATACCAGCACTACCATGAATTCTAT'\
'ATGGCTGCCGTTCACAGCCTTAATTTTAGGCTTTCCACCTGATCACTCTTTAATC'\
'TCCATTGTTTCTGGTACGCAGAAATTGACGCTTCCCATTCATTCACGGCTAAAAT'\
'CAAGGATTCCACCAGAATCGCGGGCCGCGTGGGTGCGCCGTCGACCTCCTCGGCC'\
'AAATAAGAACGGGCAGGTAAGAGACTAGGGTACTCAAGAT'
DEFAULT_LENGTH_FOR_DNA =
#

DEFAULT_LENGTH_FOR_DNA

How long our DNA-generated strings should be by default.

This may be used by some scripts, so it provides a default value for use in these scripts.

150 nucleotides are the current default.

#
150
FIELD_TERMINATOR =
#

FIELD_TERMINATOR

#
"#{TABULATOR}|#{TABULATOR}"
MAIN_DELIMITER =

An alias to the above.

DELIMITER = FIELD_TERMINATOR
USERS_X =
#

USERS_X

#
'/home/x/'
HOME_DIRECTORY_OF_USER_X =

HOME_DIRECTORY_OF_USER_X

USERS_X
RUBY_SRC =
#

RUBY_SRC

This constant is only useful on my home directory. Most other users will not need it, ever.

#
"#{USERS_X}programming/ruby/src/"
BIOROEBE_AT_HOME =
#

BIOROEBE_AT_HOME

#
"#{RUBY_SRC}bioroebe/lib/bioroebe/"
LOCALHOST =
#

LOCALHOST

#
'http://localhost/'
PATH_TO_THE_RELION_BINARY =
#

PATH_TO_THE_RELION_BINARY

This constant can be set to determine where relion resides. It is mostly an ad-hoc constant.

#
'/opt/RELION/relion-1.3/bin/relion'
ARRAY_REGISTERED_ACTIONS =
#

ARRAY_REGISTERED_ACTIONS

ARRAY_REGISTERED_ACTIONS becomes @registered_actions.

#
%w(
  to_rna
  to_dna
  rest
  pubmed
  blosum
  restriction
  translate
  quit
  shorten_aminoacid
)
FILE_BIO_LANG =
#

FILE_BIO_LANG

#
"#{USERS_X}data/personal/yaml/bio_lang/bio_lang.md"
EMAIL =
#

EMAIL

My email address - not too terribly useful for other people, but nonetheless it may be useful to display it, in particular for GUI-related components of the bioroebe-project and simple feedback in the long run.

#
'[email protected]'
REGEX_FOR_N_GLYCOSYLATION_PATTERN =
#

REGEX_FOR_N_GLYCOSYLATION_PATTERN

See rubular at:

https://rubular.com/r/D95Cq7oR5x
#
/(?=(N[^P][ST][^P]))/
REGEX_PROSITE_FOR_ANY_AMINOACID =
#

REGEX_PROSITE_FOR_ANY_AMINOACID

#
/x\((\d+)\)/
STOP_CODONS =
#

Bioroebe::STOP_CODONS

The STOP codons that can be found in Humans, in RNA format.

#
%w(
  UAA UAG UGA
)
RNA_NUCLEOTIDES =
#

Bioroebe::RNA_NUCLEOTIDES

This will refer to an Array including all four RNA nucleotides, that is A, U, G and C.

#
%w( A U G C )
ALLOWED_RNA_NUCLEOTIDES =

ALLOWED_RNA_NUCLEOTIDES

RNA_NUCLEOTIDES
POSSIBLE_RNA_NUCLEOTIDES =
#

Bioroebe::POSSIBLE_RNA_NUCLEOTIDES

This is a bit different to RNA_NUCLEOTIDES in that N is also a part of it. It is not entirely clear whether this array here is kept, though.

#
%w(
  A U G C N
)
DNA_NUCLEOTIDES =
#

Bioroebe::DNA_NUCLEOTIDES

This is the variant without N.

#
%w( A T G C )
HASH_DNA_NUCLEOTIDES =
#

Bioroebe::HASH_DNA_NUCLEOTIDES

Since as of 20.04.2014, Uracil is also part of this Hash. While this is, strictly speaking, not absolutely correct, it does simplify some downstream code. However had, this may possibly be re-evaluated in the future.

This Hash may be helpful when the user wishes to find a complement to a nucleotide. There is a method that does the same, but this Hash should be faster than a method call, so use it in particular if you need to focus more on speed.

#
{
  'A' => 'T',
  'T' => 'A',
  'G' => 'C',
  'C' => 'G',
  'U' => 'A'
}
POSSIBLE_DNA_NUCLEOTIDES =
#

POSSIBLE_DNA_NUCLEOTIDES

This constant will keep all possible DNA nucleotides.

N is also a valid entry, ‘Yarrowia_lipolytica_genome.fa’ includes it. However had,

Only these sequences are allowed in DNA.

To scope to this, do:

Bioroebe::POSSIBLE_DNA_NUCLEOTIDES
#
%w(
  A T G C N
)
ARRAY_VALID_DNA_SEQUENCES =

ARRAY_VALID_DNA_SEQUENCES

POSSIBLE_DNA_NUCLEOTIDES
FTP_NCBI_TAXONOMY_DATABASE =
#

FTP_NCBI_TAXONOMY_DATABASE

This constant refers to the taxonomy-database from NCBI. This is the file that can be downloaded from the NCBI homepage (actually, the ftp-listing).

Take note that this database, in .tar.gz format, is about 50 MB in size or even larger these days. So only download it if you really need it locally.

#
'ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz'
URL_TO_TAXONOMY_ARCHIVE =
#

URL_TO_TAXONOMY_ARCHIVE

An “alias” to the above ^^^ constant.

#
FTP_NCBI_TAXONOMY_DATABASE
NCBI_NUCCORE =
#

NCBI_NUCCORE

#
'https://www.ncbi.nlm.nih.gov/nuccore/'
NCBI_GENE =
#

NCBI_GENE

#
'https://www.ncbi.nlm.nih.gov/gene/'
FILE_HYDROPATHY_TABLE =
#

FILE_HYDROPATHY_TABLE

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}hydropathy_table.yml"
FILE_NUCLEAR_LOCALIZATION_SEQUENCES =
#

FILE_NUCLEAR_LOCALIZATION_SEQUENCES

#
"#{project_yaml_directory?}nuclear_localization_sequences.yml"
FILE_DEFAULT_COLOURS_FOR_THE_AMINOACIDS =
#

FILE_DEFAULT_COLOURS_FOR_THE_AMINOACIDS

#
"#{project_yaml_directory?}configuration/default_colours_for_the_aminoacids.yml"
FILE_BROWSER =
#

FILE_BROWSER

#
"#{project_yaml_directory?}configuration/browser.yml"
FILE_AMINOACIDS_MOLECULAR_FORMULA =
#

FILE_AMINOACIDS_MOLECULAR_FORMULA

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_molecular_formula.yml"
FILE_AMINOACIDS_THREE_TO_ONE =
#

FILE_AMINOACIDS_THREE_TO_ONE

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_three_to_one.yml"
FILE_WEIGHT_OF_COMMON_PROTEINS =
#

FILE_WEIGHT_OF_COMMON_PROTEINS

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}weight_of_common_proteins.yml"
FILE_AMINO_ACIDS_LONG_NAME_TO_ONE_LETTER =
#

FILE_AMINO_ACIDS_LONG_NAME_TO_ONE_LETTER

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_long_name_to_one_letter.yml"
FILE_AMINO_ACIDS_MOLECULAR_FORMULA =
#

FILE_AMINO_ACIDS_MOLECULAR_FORMULA

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_molecular_formula.yml"
FILE_AMINO_ACIDS_MASS_TABLE =
#

FILE_AMINO_ACIDS_MASS_TABLE

bl $BIOROEBE_YAML/aminoacids/amino_acids_monoisotopic_mass_table.yml
#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_monoisotopic_mass_table.yml"
FILE_AMINO_ACIDS =
#

FILE_AMINO_ACIDS

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids.yml"
FILE_AMINO_ACIDS_ABBREVIATIONS =
#

FILE_AMINO_ACIDS_ABBREVIATIONS

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_abbreviations.yml"
DIRECTORY_CODON_TABLES_FREQUENCIES =
#

DIRECTORY_CODON_TABLES_FREQUENCIES

This constant may point to a directory such as:

/home/Programs/Ruby/2.7.0/lib/ruby/site_ruby/2.7.0/bioroebe/codon_tables/frequencies/
#
"#{CODON_TABLES_DIRECTORY}frequencies/"
FILE_NUCLEOTIDES =
#

FILE_NUCLEOTIDES

#
"#{project_yaml_directory?}nucleotides/nucleotides.yml"
NUCLEOTIDES =
nil
FILE_GFP_SEQUENCE =
#

FILE_GFP_SEQUENCE

#
"#{project_yaml_directory?}sequences/"\
"JX472995_Green_fluorescent_protein_from_Aequorea_victoria.fasta"
FILE_RESTRICTION_ENZYMES =
#

FILE_RESTRICTION_ENZYMES

bl $BIOROEBE/yaml/restriction/enzymes/restriction_enzymes.yml

#
"#{project_yaml_directory?}restriction_enzymes/restriction_enzymes.yml"
FILE_COLOURIZE_FASTA_SEQUENCES =
#

FILE_COLOURIZE_FASTA_SEQUENCES

This constants points to the .yml file that will hold information in how to colourize the FASTA sequences.

#
"#{project_yaml_directory?}configuration/colourize_fasta_sequences.yml"
FILE_BLOSUM45 =
#

FILE_BLOSUM45

#
"#{BLOSUM_DIRECTORY}/blosum45.yml"
FILE_BLOSUM50 =
#

FILE_BLOSUM50

#
"#{BLOSUM_DIRECTORY}/blosum50.yml"
FILE_BLOSUM62 =
#

FILE_BLOSUM62

#
"#{BLOSUM_DIRECTORY}/blosum62.yml"
FILE_BLOSUM80 =
#

FILE_BLOSUM80

#
"#{BLOSUM_DIRECTORY}/blosum80.yml"
FILE_BLOSUM90 =
#

FILE_BLOSUM90

#
"#{BLOSUM_DIRECTORY}/blosum90.yml"
FILE_BLOSUM_MATRIX =
#

BLOSUM_MATRIX

#
"#{BLOSUM_DIRECTORY}blosum_matrix.yml"
HYDROPATHY_TABLE =
YAML.load_file(
  FILE_HYDROPATHY_TABLE
)
FILE_CHROMOSOME_NUMBERS =
#

FILE_CHROMOSOME_NUMBERS

#
"#{project_yaml_directory?}chromosomes/chromosome_numbers.yml"
FILE_AMINO_ACIDS_FREQUENCY =
#

FILE_AMINO_ACIDS_FREQUENCY

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_frequency.yml"
FILE_AMINO_ACIDS_RESTE_YAML =
#

FILE_AMINO_ACIDS_RESTE_YAML

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_reste.yml"
FILE_AMINO_ACIDS_THREE_TO_ONE =
#

FILE_AMINO_ACIDS_THREE_TO_ONE

We’ll keep the keys downcased.

bl $RUBY_SRC/bioroebe/lib/bioroebe/yaml/aminoacids/amino_acids_three_to_one.yml
#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_three_to_one.yml"
FILE_AMINO_ACIDS_AVERAGE_MASS_TABLE =
#

FILE_AMINO_ACIDS_AVERAGE_MASS_TABLE

This will point to the file amino_acids_average_mass_table.yml.

#
"#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_average_mass_table.yml"
FILE_NUCLEOTIDES_WEIGHT =
#

FILE_NUCLEOTIDES_WEIGHT

The path to the file that holds the weight of the nucleotides.

#
"#{project_yaml_directory?}nucleotides/nucleotides_weight.yml"
UNICODE_HORIZONTAL_BAR =
#

UNICODE_HORIZONTAL_BAR

#
''
AMINO_ACIDS_MOLECULAR_FORMULA =
YAML.load_file(
  FILE_AMINO_ACIDS_MOLECULAR_FORMULA
)
AMINO_ACIDS_RESTE =
{}
AMINO_ACIDS_LONG_NAME_TO_ONE_LETTER =
YAML.load_file(_)
AMINO_ACIDS_MASS_TABLE =

Else hardcode the AminoAcid table here. This may no longer be necessary, though.

{
  'A' =>  71.03711, 'C' => 103.00919, 'D' => 115.02694,
  'E' => 129.04259, 'F' => 147.06841, 'G' =>  57.02146,
  'H' => 137.05891, 'I' => 113.08406, 'K' => 128.09496,
  'L' => 113.08406, 'M' => 131.04049, 'N' => 114.04293,
  'P' =>  97.05276, 'Q' => 128.05858, 'R' => 156.10111,
  'S' =>  87.03203, 'T' => 101.04768, 'V' =>  99.06841,
  'W' => 186.07931, 'Y' => 163.06333
}
AMINO_ACIDS_AVERAGE_MONOISOTOPIC_TABLE =

An alias.

AMINO_ACIDS_MASS_TABLE
AMINO_ACIDS =
#

Bioroebe::AMINO_ACIDS

Currently listing 21 AminoAcids from amino_acids.yml

bl $BIOROEBE/yaml/aminoacids/amino_acids.yml
#
YAML.load_file(
  FILE_AMINO_ACIDS
)
FILE_AMINO_ACIDS_ENGLISH =
#

::Bioroebe::AMINO_ACIDS_ENGLISH

#
YAML.load_file("#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_english.yml")
AMINO_ACIDS_ENGLISH =

AMINO_ACIDS_ENGLISH

FILE_AMINO_ACIDS_ENGLISH
AMINO_ACIDS_AVERAGE_MASS_TABLE =

Else simply hardcode the AminoAcid table here.

{
  'A' =>  71.0788,
  'C' => 103.1388,
  'D' => 115.0886,
  'E' => 129.1155,
  'F' => 147.1766,
  'G' =>  57.0519,
  'H' => 137.1411,
  'I' => 113.1594,
  'K' => 128.1741,
  'L' => 113.1594,
  'M' => 131.1926,
  'N' => 114.1038,
  'P' =>  97.1167,
  'Q' => 128.1307,
  'R' => 156.1875,
  'S' =>  87.0782,
  'T' => 101.1051,
  'V' =>  99.1326,
  'W' => 186.2132,
  'Y' => 163.1760
}
AMINO_ACIDS_THREE_TO_ONE =
hash
NUCLEAR_LOCALIZATION_SEQUENCES =
''
ARRAY_NLS_SEQUENCES =
[]
LOCAL_DIRECTORY_FOR_UNIPROT =
#

LOCAL_DIRECTORY_FOR_UNIPROT

This denotes the directory for uniprot-files.

#
"#{log_directory?}uniprot/"
AUTOGENERATED_SQL_FILES_DIR =
#

Bioroebe::AUTOGENERATED_SQL_FILES_DIR

#
"#{log_directory?}autogenerated_sql_files/"
USE_THIS_BROWSER =

opera # Hardcoded value in this case..

'firefox'
ProteinToDNA =
#

Bioroebe::ProteinToDNA

Use an “alias” to the other name.

#
ConvertAminoacidToDNA
Fasta =

Add an “alias” constant to class ParseFasta.

ParseFasta

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](i = nil) ⇒ Object

#

Bioroebe[]

Assign a sequence through the [] method.

Note that some aliases are allowed to this way; see the variants that use self.instance_eval below this method definition.

This method here could be compared to methods such as Integer(). Biopython uses something similar, by the way.

For instance, you can do this too:

Bioroebe << 'ATT'
x = Bioroebe['ATT']
x = Bioroebe << 'ATT'
#


685
686
687
# File 'lib/bioroebe/sequence/sequence.rb', line 685

def self.[](i = nil)
  Bioroebe::Sequence.new(i)
end

.ad_hoc_task(this_file = '/root/Bioroebe/table_ids.md') ⇒ Object

#

Bioroebe.ad_hoc_task

This method can be used to specifically run an “ad-hoc” task.

An ad-hoc task is something that we just quickly “hack” together, in order to solve some existing bioinformatics-related problem or another problem that may exist right now.

For instance, in May 2021, this was used for a university course that required us to work with MEGA X and compare different proteins from a phylogenetics point of view.

#


4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4051

def self.ad_hoc_task(
    this_file = '/root/Bioroebe/table_ids.md'
  )
  require 'bioroebe/fasta_and_fastq/download_fasta.rb'
  require 'bioroebe/fasta_and_fastq/simplify_fasta_header/simplify_fasta_header.rb'
  if this_file.is_a? Array
    this_file = this_file.join(' ')
  end
  cd ::Bioroebe.log_dir? # Make sure we are in the log-directory.
  e 'Now downloading some FASTA files, based on this file: '+
    this_file
  # ======================================================================= #
  # (1) Download the remote FASTA dataset
  # ======================================================================= #
  download_fasta this_file
  # ======================================================================= #
  # (2) cd into the fasta directory
  # ======================================================================= #
  cd ::Bioroebe.log_dir?+'fasta/'
  # ======================================================================= #
  # (3) batch rename all .fasta files next via simplify-fasta-header.
  # ======================================================================= #
  all_files = Dir['*.fasta']
  all_files.each {|this_fasta_file|
    Bioroebe.overwrite_fasta_header(this_fasta_file)
  }
end

.align_this_string_via_multiple_sequence_alignment(this_string = "PSRARRDAVG--DH--PAVEALP----PQSGPHKKEISFFTVRKEEAADADLWFPS PGGASK--VGQTDNDPQAIKDLP----PQGED------------------------ ") ⇒ Object

#

Bioroebe.align_this_string_via_multiple_sequence_alignment

This method will simply return an Array.

#


957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 957

def self.align_this_string_via_multiple_sequence_alignment(
    this_string =
      "PSRARRDAVG--DH--PAVEALP----PQSGPHKKEISFFTVRKEEAADADLWFPS
       PGGASK--VGQTDNDPQAIKDLP----PQGED------------------------
      "
  )
  if this_string.is_a? Array
    this_string = this_string.join("\n")
  end
  this_string = this_string.dup if this_string.frozen?
  this_string.strip!
  this_string.delete!(' ')
  splitted = this_string.split("\n")
  return splitted
end

.all_aminoacids?Boolean

#

Bioroebe.all_aminoacids?

This method will return all available aminoacids.

Example:

Bioroebe.all_aminoacids? # => ["A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y"]
#

Returns:

  • (Boolean)


162
163
164
# File 'lib/bioroebe/constants/constants.rb', line 162

def self.all_aminoacids?
  ARRAY_AMINO_ACIDS_ALPHABET
end

.allowed_dna_nucleotides?Boolean

#

Bioroebe.allowed_dna_nucleotides?

This will return an Array with valid DNA nucleotides.

#

Returns:

  • (Boolean)


522
523
524
# File 'lib/bioroebe/constants/constants.rb', line 522

def self.allowed_dna_nucleotides?
  POSSIBLE_DNA_NUCLEOTIDES - ['N']
end

.amino_acid_average_mass(i) ⇒ Object

#

Bioroebe.amino_acid_average_mass

The input to this method should be in the form of the one-letter code for aminoacids. Several aminoacids can be input, of course, such as ‘AGL’.

Do note that since as of March 2020 a float will be returned by this method, if the input was found to be a valid aminoacid.

Usage example:

Bioroebe.amino_acid_average_mass('F') # => "147.17660"
#


1985
1986
1987
1988
1989
1990
1991
1992
1993
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1985

def self.amino_acid_average_mass(i)
  use_this_table = AMINO_ACIDS_AVERAGE_MASS_TABLE
  i = i.split(//) if i.is_a? String
  i = [i] unless i.is_a? Array
  result = i.map {|entry|
    entry = use_this_table[entry].to_f
  }
  return ('%.5f' % result.sum).to_f # ← This is our properly formatted result.
end

.amino_acid_monoisotopic_mass(this_aminoacid) ⇒ Object

#

Bioroebe.amino_acid_monoisotopic_mass

We require the monoisotopic table for this method, and return the corresponding match to the given aminoacid.

The input format should be in the one-letter aminoacid abbreviation.

Invocation example:

Bioroebe.amino_acid_monoisotopic_mass 'L' # => 113.08406
Bioroebe.amino_acid_monoisotopic_mass 'K' # => 128.09496
#


2009
2010
2011
2012
2013
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2009

def self.amino_acid_monoisotopic_mass(this_aminoacid)
  use_this_table = AMINO_ACIDS_AVERAGE_MONOISOTOPIC_TABLE
  # '%.5f' % use_this_table[this_aminoacid].to_f
  use_this_table[this_aminoacid].to_f
end

.aminoacid_families?Boolean

#

Bioroebe.aminoacid_families?

Feedback which aminoacid-families we know of.

Usage example:

pp Bioroebe.aminoacid_families?; ''
#

Returns:

  • (Boolean)


223
224
225
# File 'lib/bioroebe/constants/constants.rb', line 223

def self.aminoacid_families?
  AMINOACID_FAMILIES
end

.aminoacid_frequency(of_this_sequence = '') ⇒ Object

#

Bioroebe.aminoacid_frequency

Usage example:

Bioroebe.aminoacid_frequency('MVTDEGAIYFTKDAARNWKAAVEETVSATLNRTVSSGITGASYYTGTFST')

Would yield the following Hash:

{"M"=>1, "V"=>4, "T"=>9, "D"=>2, "E"=>3, "G"=>4, "A"=>7, "I"=>2, "Y"=>3, "F"=>2, "K"=>2, "R"=>2, "N"=>2, "W"=>1, "S"=>5, "L"=>1}
#


2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2515

def self.aminoacid_frequency(
    of_this_sequence = ''
  )
  if of_this_sequence.is_a? Array
    of_this_sequence = of_this_sequence.first 
  end
  chars = of_this_sequence.split(//)
  hash = {}
  hash.default = 0
  chars.each {|this_char| hash[this_char] += 1 }
  return hash
end

.aminoacid_substitution(from_this_sequence = :default) ⇒ Object

#

Bioroebe.aminoacid_substitution

#


102
103
104
# File 'lib/bioroebe/aminoacids/aminoacid_substitution.rb', line 102

def self.aminoacid_substitution(from_this_sequence = :default)
  Bioroebe::AminoacidSubstitution.new(from_this_sequence)
end

.aminoacids?Boolean

#

Bioroebe.aminoacids?

Note that this will return a Hash that looks like this:

{"A"=>{"ala"=>"alanine", "d
#

Returns:

  • (Boolean)


995
996
997
# File 'lib/bioroebe/constants/constants.rb', line 995

def self.aminoacids?
  AMINO_ACIDS
end

.append_what_into(what = 'Hello world!', into = 'test.md') ⇒ Object

#

Bioroebe.append_what_into

This method can be used to append content onto a file.

#


1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1204

def self.append_what_into(
    what = 'Hello world!',
    into = 'test.md'
  )
  unless File.exist? into
    base_dir = File.dirname(into)
    unless File.directory? base_dir
      e rev+
      'No directory exists at '+sdir(base_dir)+
      rev+'. Thus creating it now.'
      create_directory(base_dir)
    end
    e rev+
      'No file exists at '+sfile(into)+rev+
      '. Thus creating it now.'
    create_file(into)
  end
  File.open(into, 'a') { |file|
    file << what
  }
end

.array_colourize_this_aminoacidObject

#

Bioroebe.array_colourize_this_aminoacid

Query as to which aminoacid we will colourize, if any at all.

#


1268
1269
1270
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1268

def self.array_colourize_this_aminoacid
  @array_colourize_this_aminoacid
end

.atomic_composition(of = 'GGGGA') ⇒ Object

#

Bioroebe.atomic_composition

This method will return the composition of atoms in a given protein, via Hash, such as:

{"C"=>11, "H"=>19, "N"=>5, "O"=>6, "S"=>0}

The Hash keeps track of 11 C atoms, 19 H atoms, 5 N atoms, 6 O atoms and 0 S atoms.

This hash can then be formatted via the method:

Bioroebe.show_atomic_composition()

Which can be found below.

Presently this method works on aminoacids only, but in theory the code could be extended to work with DNA nucleotides and RNA nucleotides as well.

Either way, the one letter abbreviation should be used as input to this method.

When we use aminoacids, we need to remember that a peptide bond deducts 1x H₂O (water). This will have to be deducted from the formula, but only if it is an internal aminoacid. In other words, the only two aminoacids that will behave differently, are the first one (since it will miss one -OH group) and the last aminoacid (as this one will lack a -H molecule.

Remember that the input sequence to this method should be the one-letter code for the aminoacid sequence at hand.

#


2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2122

def self.atomic_composition(
    of = 'GGGGA' # ← This should be the aminoacid sequence.
  )
  begin
    require 'chemistry_paradise/split_molecule_names.rb'
    require 'chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb'
  rescue LoadError
    if is_on_roebe?
      puts 'Two files from the chemistry_paradise gem are not available.'
    end
  end
  # ======================================================================= #
  # Load up the molecular formula for each aminoacid next. This will
  # be used as our reference-point for calculating things such as the
  # composition, or weight.
  # ======================================================================= #
  dataset_molecular_formula_for_the_aminoacids = YAML.load_file(
    FILE_AMINOACIDS_MOLECULAR_FORMULA
  )
  if of.is_a?(Array)
    if of.empty?
      of = 'GGGGA' # In this case reinstate the default.
    else
      if of.first.is_a?(String) and of.first.size > 1
        of = of.first.split(//) # Split it on a per-character basis here.
      end
    end
  end
  if of.is_a? String
    of = of.split(//)
  end
  unless of.is_a? Array
    of = [of]
  end
  hash_keeping_track_of_the_atomic_composition = {}
  # ======================================================================= #
  # Build up the default values, for the atoms C, H, N, O and S.
  # ======================================================================= #
  hash_keeping_track_of_the_atomic_composition['C'] = 0
  hash_keeping_track_of_the_atomic_composition['H'] = 0
  hash_keeping_track_of_the_atomic_composition['N'] = 0
  hash_keeping_track_of_the_atomic_composition['O'] = 0
  hash_keeping_track_of_the_atomic_composition['S'] = 0
  # ======================================================================= #
  # Next obtain the formula from the ChemistryParadise project. We
  # do so by iterating over the given input, and we assume that
  # this input is always an Array.
  # ======================================================================= #
  of.map.with_index {|this_amino_acid, position_of_that_aminoacid|
    # ===================================================================== #
    # Next, we have to obtain the formula for this amino acid.
    # ===================================================================== #
    this_amino_acid = AMINO_ACIDS_ENGLISH[this_amino_acid]
    formula_for_this_amino_acid = dataset_molecular_formula_for_the_aminoacids[this_amino_acid]
    # ===================================================================== #
    # The next case-menu will handle the position of the aminoacid at hand.
    # We will skip doing so if there is only one aminoacid though.
    # ===================================================================== #
    if of.first.to_s.size > 1
      case position_of_that_aminoacid # case tag
      when 0 # This is the first aminoacid. It loses only one 'OH' group.
        formula_for_this_amino_acid = 
          ::ChemistryParadise.remove_this_molecule_from('OH', formula_for_this_amino_acid)
      when (of.size - 1) # This is the last entry. It loses only one 'H' group.
        formula_for_this_amino_acid = 
          ::ChemistryParadise.remove_this_molecule_from('H', formula_for_this_amino_acid)
      else
        # ================================================================= #
        # Else it will lose a full H₂O group.
        # ================================================================= #
        formula_for_this_amino_acid = 
          ::ChemistryParadise.remove_this_molecule_from('H2O', formula_for_this_amino_acid)
      end
    end
    array_chemical_formula = ::ChemistryParadise.split_this_molecular_formula_into_a_hash(
      formula_for_this_amino_acid
    )
    array_chemical_formula.each {|molecule_and_number| # e. g. 'H13'
      if molecule_and_number =~ /\d+/ # If it has at the least one number.
        molecule_and_number =~ /([A-Z]+)(\d{1,2})/ # See: https://rubular.com/r/nCojEDcY6g
        molecule = $1.to_s.dup
        n_times  = $2.to_s.dup.to_i
        hash_keeping_track_of_the_atomic_composition[molecule] += n_times
      else # else it must be 1, since there is no other number, such as 'N'.
        hash_keeping_track_of_the_atomic_composition[molecule_and_number] += 1
      end
    }
  }
  return hash_keeping_track_of_the_atomic_composition
end

.automatically_rename_this_fasta_file(fasta_file) ⇒ Object

#

Bioroebe.automatically_rename_this_fasta_file

This method will automatically (try to) rename an existing fasta file, by tapping into the method called .return_new_filename_based_on_fasta_identifier().

#


135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 135

def self.automatically_rename_this_fasta_file(fasta_file)
  fasta_file = [fasta_file].flatten.compact
  fasta_file.each {|this_fasta_file|
    if File.exist? this_fasta_file
      new_filename = return_new_filename_based_on_fasta_identifier(this_fasta_file)
      erev "Renaming #{sfile(this_fasta_file)}#{rev} "\
           "to #{sfile(new_filename)} #{rev}next."
      Bioroebe.rename(this_fasta_file, new_filename)
    else
      no_file_exists_at(this_fasta_file)
    end
  }
end

.available_blosum_matrices?Boolean

#

Bioroebe.available_blosum_matrices?

This method will return an Array of all available blosum matrices.

Example output:

["blosum45", "blosum50", "blosum62", "blosum80", "blosum90", "blosum_matrix"]
#

Returns:

  • (Boolean)


78
79
80
81
82
# File 'lib/bioroebe/blosum/blosum.rb', line 78

def self.available_blosum_matrices?
  Bioroebe::Blosum.available_blosum_files?.map {|entry|
    File.basename(entry).delete_suffix('.yml')
  }
end

.available_codon_tables?Boolean

#

Bioroebe.available_codon_tables?

#

Returns:

  • (Boolean)


125
126
127
# File 'lib/bioroebe/codons/show_codon_tables.rb', line 125

def self.available_codon_tables?
  ::Bioroebe::CodonTables.definitions?.values # Do not sort this.
end

.base_composition(i = '52%GC') ⇒ Object

#

Bioroebe.base_composition

This method can be used to query the composition of a given DNA sequence, that is, in percentage, the values for A, T, C and G.

This method will then return a Hash, consisting of the percentage values of A, T, C and G in the given DNA sequence at hand.

Note that the input to this method has to include a ‘%’ character, at the least up until March 2020. Past March 2020 this requirement was dropped, but I still think it is visually more elegant to include a ‘%’ character.

#


3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3908

def self.base_composition(
    i = '52%GC'
  )
  if i.is_a? Array
    if i.empty?
      i = '52%GC' # Default value.
    else
      i = i.join(' ').strip
    end
  end
  # ======================================================================= #
  # Add support for Files here.
  # ======================================================================= #
  if i and File.exist?(i)
    i = File.readlines(i).reject {|line| line.start_with? '>' }.join("\n").delete("\n")
  end
  # ======================================================================= #
  # We must use a Hash for this.
  # ======================================================================= #
  hash = {
    'A' => 0,
    'T' => 0,
    'C' => 0,
    'G' => 0,
  }
  if i.include? '%'
    splitted = i.split('%').map(&:strip)
    frequency = splitted.first.to_i
    opposite_frequency = 100 - frequency
    characters = splitted.last.split(//)
    characters.each {|this_nucleotide|
      hash[this_nucleotide] = frequency / 2
    }
    # ===================================================================== #
    # Next calculate the missing nucleotides:
    # ===================================================================== #
    missing_nucleotides = hash.select {|key, value|
      value == 0
    }
    missing_nucleotides.each_pair {|this_nucleotide, value|
      hash[this_nucleotide] = opposite_frequency / 2
    }
  else
    frequency = Hash.new(0)
    chars = i.chars
    chars.each { |entry| frequency[entry] += 1 }
    sum = frequency.values.sum
    frequency.each_pair {|this_nucleotide, value|
      hash[this_nucleotide] = ((value * 100.0) / sum).round(2)
    }
  end
  return hash
end

.batch_create_windows_executablesObject

#

Bioroebe.batch_create_windows_executables

This method is only useful for windows. We will use “ocra” to create various .exe files that have the desired widgt-functionality.

Note that the functionality depends on the roebe-gem.

#


2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2837

def self.batch_create_windows_executables
  begin
    require 'roebe/custom_methods/module.rb'
  rescue LoadError; end
  array_these_files =  %w(
    /home/x/programming/ruby/src/bioroebe/lib/bioroebe/gui/libui/hamming_distance/hamming_distance.rb
  )
  array_these_files.each {|this_file|
    Roebe.ocra_build(
      this_file,
      File.basename(this_file).delete_suffix('.rb')
    )
  }
end

.be_verbose?Boolean

#

Bioroebe.be_verbose?

#

Returns:

  • (Boolean)


164
165
166
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 164

def self.be_verbose?
  @be_verbose
end

.bisulfite_treatment(i) ⇒ Object

#

Bioroebe.bisulfite_treatment

Simply convert all C into U. The underlying idea here is that bilsufite will convert unmethylated Cytosines into Uracil.

Usage example:

Bioroebe.bisulfite_treatment('CCCGCAATGCATACCTCGCCG') # => "UUUGUAATGUATAUUTUGUUG"
#


2822
2823
2824
2825
2826
2827
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2822

def self.bisulfite_treatment(i)
  if i.is_a? Array
    i = i.join('').strip
  end
  i.tr('C','U')
end

.blast_neighborhood(this_mer = 'CTC', optional_apply_filter_for_score_higher_than = nil) ⇒ Object

#

Bioroebe.blast_neighborhood

The second argument to this method is a score-filter, e. g. to select only entries that have a score higher than 1.

#


4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4248

def self.blast_neighborhood(
    this_mer                                    = 'CTC',
    optional_apply_filter_for_score_higher_than = nil
  )
  if this_mer.is_a? Array
    this_mer = this_mer.first
  end
  if this_mer.nil?
    this_mer = 'CTC' # Set the same default as above.
  end
  match_score     =  2
  mis_match_score = -2
  # ======================================================================= #
  # Next use an Array of sequences that we will compare.
  # ======================================================================= #
  compare_these_sequences = %w(
    AAA
    AAT
    AAC
    AAG
    ATA
    ATT
    ATC
    ATG
    ACA
    ACT
    ACC
    ACG
    AGA
    AGT
    AGC
    AGG
    TAA
    TAT
    TAC
    TAG
    TTA
    TTT
    TTC
    TTG
    TCA
    TCT
    TCC
    TCG
    TGA
    TGT
    TGC
    TGG
    CAA
    CAT
    CAC
    CAG
    CTA
    CTT
    CTC
    CTG
    CCA
    CCT
    CCC
    CCG
    CGA
    CGT
    CGC
    CGG
    GAA
    GAT
    GAC
    GAG
    GTA
    GTT
    GTC
    GTG
    GCA
    GCT
    GCC
    GCG
    GGA
    GGT
    GGC
    GGG
  )
  compare_these_sequences.each {|this_sequence|
    score = 0
    chars = this_sequence.chars
    first_char  = chars[0]
    second_char = chars[1]
    third_char  = chars[2]
    if first_char == this_mer[0]
      # =================================================================== #
      # Found the first match.
      # =================================================================== #
      score += match_score
    else
      # =================================================================== #
      # else it must be a mismatch
      # =================================================================== #
      score += mis_match_score
    end
    if second_char == this_mer[1]
      # =================================================================== #
      # Found the first match.
      # =================================================================== #
      score += match_score
    else
      # =================================================================== #
      # else it must be a mismatch
      # =================================================================== #
      score += mis_match_score
    end
    if third_char == this_mer[2]
      # =================================================================== #
      # Found the first match.
      # =================================================================== #
      score += match_score
    else
      # =================================================================== #
      # else it must be a mismatch
      # =================================================================== #
      score += mis_match_score
    end
    if optional_apply_filter_for_score_higher_than
       if (score.to_i > optional_apply_filter_for_score_higher_than)
        e "#{this_sequence}: score of "\
          "#{score.to_s.rjust(3)}"
       end
    else
      e this_sequence+': score of '+
        score.to_s.rjust(3)
    end
  }
end

.blosum_directory?Boolean

#

Bioroebe.blosum_directory?

#

Returns:

  • (Boolean)


899
900
901
# File 'lib/bioroebe/constants/constants.rb', line 899

def self.blosum_directory?
  "#{project_yaml_directory?}blosum/"
end

.blosum_matrix(i = FILE_BLOSUM_MATRIX) ⇒ Object

#

Bioroebe.blosum_matrix

#


801
802
803
# File 'lib/bioroebe/constants/constants.rb', line 801

def self.blosum_matrix(i = FILE_BLOSUM_MATRIX)
  YAML.load_file(i)
end

.calculate_exponential_growth(number_of_cells = 10, number_of_divisions = 10) ⇒ Object

#

Bioroebe.calculate_exponential_growth

This method can be used to calculate how many bacteria will exist after n cell divisions (provided that we know, and supply to this method, how many bacteria existed when we started our calculation).

#


4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4787

def self.calculate_exponential_growth(
    number_of_cells     = 10,
    number_of_divisions = 10
  )
  if number_of_cells.nil?
    number_of_cells = 10 # Default value.
  end
  if number_of_divisions.nil?
    number_of_divisions = 10 # Default value.
  end
  # ======================================================================= #
  # === Hashes
  #
  # Handle Hash as input given.
  # ======================================================================= #
  if number_of_cells.is_a? Hash
    if number_of_cells.has_key? :n_divisions
      number_of_divisions = number_of_cells.delete(:n_divisions)
    end
    if number_of_cells.has_key? :number_of_cells
      number_of_cells = number_of_cells.delete(:number_of_cells)
    elsif number_of_cells.has_key? :n_cells
      number_of_cells = number_of_cells.delete(:n_cells)
    end
  end
  # ======================================================================= #
  # We need numbers, aka integers - there are no "1.3" cells.
  # ======================================================================= #
  number_of_cells     = number_of_cells.to_i
  number_of_divisions = number_of_divisions.to_i
  total_amount_of_cells = 0
  total_amount_of_cells = number_of_cells * (2 ** number_of_divisions)
  return total_amount_of_cells
end

.calculate_levensthein_distance(string1 = 'TTACCC', string2 = 'TTTCCC', be_verbose = true) ⇒ Object

#

Bioroebe.calculate_levensthein_distance

The following method is based on

http://rosettacode.org/wiki/Levenshtein_distance#Ruby, slightly modified.

To test this code, do:

[ ['kitten','sitting'], ['saturday','sunday'], ["rosettde", "raisethyrd"] ].each { |s,t|
  puts "calculate_levensthein_distance('#{s}', '#{t}') = #{Bioroebe.calculate_levensthein_distance(s, t)}"
}

However had, rubygems has a levensthein variant too.

#


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/bioroebe/calculate/calculate_levensthein_distance.rb', line 27

def self.calculate_levensthein_distance(
    string1    = 'TTACCC',
    string2    = 'TTTCCC',
    be_verbose = true
  )
  case be_verbose
  when :be_quiet
    be_verbose = false
  end
  if string1.is_a?(Array) and (string1.size > 1)
    string2 = string1.shift
    string1 = string1.first
  elsif string1.is_a?(String) and string1.include?(' ')
    splitted = string1.split(' ')
    string2  = splitted.last
    string1  = splitted.first
  end
  m = string1.length
  n = string2.length
  return m if n == 0 # Stop at 0.
  return n if m == 0 # Stop at 0.
  arrays = Array.new(m+1) { Array.new(n+1) }
  # ======================================================================= #
  # Initialize the variable arrays next:
  # ======================================================================= #
  (0 .. m).each {|i| arrays[i][0] = i}
  (0 .. n).each {|j| arrays[0][j] = j}
  # ======================================================================= #
  # Now, iterate through:
  # ======================================================================= #
  (1 .. n).each {|j|
    (1 .. m).each {|i|
      arrays[i][j] = 
        if string1[i-1] == string2[j-1] # adjust index into string
          arrays[i-1][j-1]       # no operation required
        else
           [ arrays[i-1][j]+1,   # deletion     operation
             arrays[i][j-1]+1,   # insertion    operation
             arrays[i-1][j-1]+1, # substitution operation
           ].min
        end
    }
  }
  result = arrays[m][n]
  if be_verbose
    e rev+'The two strings '+simp(string1.to_s)+rev+' and '+
      simp(string2.to_s)+rev+' have n differences ('+
      steelblue('edit distance')+rev+'):'
    e "  #{simp(result.to_s)}"
  end
  return result
end

.calculate_melting_temperature_for_more_than_thirteen_nucleotides(i) ⇒ Object

#

Bioroebe.calculate_melting_temperature_for_more_than_thirteen_nucleotides

An alias exists for this method, called Bioroebe.melting_Temperature().

Usage example for the latter:

x = Bioroebe.melting_temperature('CCGTGTCGTACATCG')
#


269
270
271
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 269

def self.calculate_melting_temperature_for_more_than_thirteen_nucleotides(i)
  ::Bioroebe::CalculateMeltingTemperatureForMoreThanThirteenNucleotides.new(i)
end

.calculate_n50_value(i = [ 1989, 1934, 1841, 1785, 1737, 1649, 1361, 926, 848, 723 ]) ⇒ Object

#

Bioroebe.calculate_n50_value

This method will calculate the N50 value of the given input. The input to this method should be a sorted Array.

#


3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3037

def self.calculate_n50_value(
    i = [
      1989, 1934, 1841,
      1785, 1737, 1649,
      1361,  926,  848,
       723
    ]
  )
  # ======================================================================= #
  # The following conversion is necessary because ARGV will contain only
  # String objects, not integer-values.
  # ======================================================================= #
  i.map! {|entry| entry.to_i }
  calculate_sum_for_the_loop = 0
  sum = i.sum
  half = sum / 2.0
  find_the_proper_contig = nil
  i.each {|this_number|
    calculate_sum_for_the_loop += this_number
    # ===================================================================== #
    # Compare the temporary sum with the half-sum.
    # ===================================================================== #
    if calculate_sum_for_the_loop > half
      find_the_proper_contig = this_number
      break
    end
  }
  return find_the_proper_contig
end

.calculate_original_amount_of_cells_of_exponential_growth(number_of_cells = 1600, number_of_divisions = 5) ⇒ Object

#

Bioroebe.calculate_original_amount_of_cells_of_exponential_growth

The first argument, number_of_cells, means “how many cells do we have now/currently”. This is necessary, in order to calculate how many cells we used to have initially.

#


4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4829

def self.calculate_original_amount_of_cells_of_exponential_growth(
    number_of_cells     = 1600, # 1600 cells to start with.
    number_of_divisions =    5  #    5 generations by default.
  )
  number_of_cells     = number_of_cells.to_i
  number_of_divisions = number_of_divisions.to_i
  initial_amount_of_cells_was = 0
  initial_amount_of_cells_was = number_of_cells / ( 2 ** number_of_divisions )
  return initial_amount_of_cells_was
end

.calculate_the_frequencies_of_this_species(i = :homo_sapiens) ⇒ Object

#

Bioroebe.calculate_the_frequencies_of_this_species

#


2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2454

def self.calculate_the_frequencies_of_this_species(
    i = :homo_sapiens
  )
  require 'bioroebe/sequence/dna.rb'
  require 'yaml'
  if i.nil?
    i = :default
  end
  if i and i.is_a?(Array) and i.empty?
    i << :homo_sapiens
  end
  hash_aminoacids = {}
  hash_aminoacids.default = 0
  if i.is_a? Array
    i = i.first
  end
  case i.to_sym
  # ======================================================================= #
  # === :homo_sapiens
  # ======================================================================= #
  when :homo_sapiens,
       :homo,
       :human,
       :default
    i = "#{project_base_directory?}"\
        "codon_tables/frequencies/9606_Homo_sapiens.yml"
  end
  hash = YAML.load_file(i)
  # "GAC"=>25.1
  hash.each_pair {|key, value|
    this_aminoacid = Bioroebe.to_aa(key)
    hash_aminoacids[this_aminoacid] += value
  }
  e
  # ======================================================================= #
  # Convert it into percent:
  # ======================================================================= #
  hash_aminoacids.each_pair {|key, value_for_percentage|
    value_for_percentage = ((value_for_percentage * 100.0) / 1000.0).round(3).to_s
    value_for_percentage = '%.2f' % value_for_percentage
    e '  '+
      steelblue(key).to_s+' '+
      royalblue(
        value_for_percentage.rjust(6)+'%'
      )
  }
  e
end

.calculate_weight_of_the_aminoacids_in_this_fasta_file(fasta_file) ⇒ Object

#

Bioroebe.calculate_weight_of_the_aminoacids_in_this_fasta_file

This method will return a Hash containing the weight of the aminoacids in a .fasta file.

Usage example:

x = Bioroebe.calculate_weight_of_the_aminoacids_in_this_fasta_file('viruses.fa')

This may yield a Hash such as the following:

{ "sp|P23046|NSP5_ROTBV"  => 21647.5341,
  "sp|Q81835|SHDAG_HDVU2" => 22030.6392,
  "sp|A5HBD7|ST_POVWU"    => 23433.3773,
  "sp|Q91FT8|234R_IIV6"   => 21076.778 }
#


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 42

def self.calculate_weight_of_the_aminoacids_in_this_fasta_file(fasta_file)
  if File.exist? fasta_file
    hash = {}
    results = Bioroebe.parse_fasta_quietly(fasta_file)
    short_headers = results.short_headers?
    sequences = results.sequences?
    short_headers.each_with_index {|entry, index|
      sum = 0
      this_sequence = sequences[index]
      # Next, convert this sequence into the corresponding mass.
      this_sequence.chars.each {|this_specific_aminoacid|
        sum += Bioroebe.weight_of_this_aminoacid?(this_specific_aminoacid)
      }
      hash[entry] = sum.round(4)
    }
    hash
  else
    e 'No file exists at '+fasta_file.to_s+'.'
  end
end

.can_base_pair_with?(a, b) ⇒ Boolean

#

Bioroebe.can_base_pair_with?

Usage example:

Bioroebe.can_base_pair_with?('A','T') # => true
Bioroebe.can_base_pair_with?('A','G') # => false
#

Returns:

  • (Boolean)


4929
4930
4931
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4929

def self.can_base_pair_with?(a, b)
  ::Bioroebe.partner_nucleotide(a) == b
end

.cat(i = nil) ⇒ Object

#

Bioroebe.cat (cat tag)

A variant of cat to use here.

#


5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 5025

def self.cat(
    i = nil
  )
  if i.is_a? Array
    i = i.first
  end
  if i
    i = convert_global_env(i) if i.include? '$'
    i = Dir['*'][i.to_i - 1] if i =~ /^\d+$/
  end
  if i.nil?
    erev 'Please provide an argument to Bioroebe.cat() (the name of a file)'
  # ======================================================================= #
  # === Handle directories next
  # ======================================================================= #
  elsif File.directory? i
    erev "We can not read from `#{sdir(i)}#{rev}` as it is a directory."
  # ======================================================================= #
  # Else the File will exist in this clause:
  # ======================================================================= #
  elsif File.exist?(i)
    _ = File.extname(i).delete('.')
    case _ # case tag
    # ===================================================================== #
    # === fasta
    # ===================================================================== #
    when 'fasta',
         'fa'
      e 'This is a fasta file, so rather than cat-ing the content,'
      e 'we will send this dataset to the ParseFasta class.'
      require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
      Bioroebe::ParseFasta.new(i)
    else # The default here.
      e "Now displaying the file `#{sfile(i)}`."
      # e File.read(i)
      # ^^^ Or we could use the above. We have to reconsider this one day.
      File.readlines(i).each {|line| e "  #{line.chomp}" } # With a bit of padding.
    end
  else # else the file does not exist.
    e "#{swarn('Trying to display the file `')}#{sfile(i)}#{swarn('`')}"
    e swarn('but it does not exist.')
  end
end

.change_directory(i = '$HOME', be_verbose = false) ⇒ Object

#

Bioroebe.change_directory

This method allows us to change the directory.

Bioroebe.cd() is an alias to the method here.

#


4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4187

def self.change_directory(
    i          = '$HOME',
    be_verbose = false
  )
  case be_verbose
  # ======================================================================= #
  # === :do_report_current_directory
  # ======================================================================= #
  when :do_report_current_directory,
       :be_verbose
    be_verbose = true
  end
  case i # Do some sanitizing here. (case tag)
  # ======================================================================= #
  # === :home_directory
  # ======================================================================= #
  when :home_directory,
       :default,
       nil # ← Nil is also assumed to refer to this :default value.
    # ===================================================================== #
    # In this case we will try to cd into the base-directory of the
    # Bioroebe shell.
    # ===================================================================== #
    i = log_dir?
  # ======================================================================= #
  # === :download_dir
  # ======================================================================= #
  when :download_dir,':download_dir',
       :download_directory,':download_directory'
    i = download_dir?
  # ======================================================================= #
  # Bioroebe.save_dir? is defined in bioroebe/toplevel_methods/store_here.rb.
  # ======================================================================= #
  when 'base',
       'logdir',
       :bioroebe_log_directory
    # ===================================================================== #
    # Enter the main log dir, unless a file exists with the same name.
    # ===================================================================== #
    i = save_dir? unless File.exist?(i.to_s) # .to_s to avoid Symbols here.
  end
  i = i.dup if i.is_a?(String) and i.frozen?
  i << '/' unless i.end_with? '/'
  if File.directory? i
    e sdir(i) if be_verbose # Also colourize the directory and output it.
    Dir.chdir(i)
  else
    if be_verbose
      erev "No directory called `#{sdir(i)}#{rev}` exists,"
      erev 'thus we can not cd to this target.'
    end
  end
end

.clear_array_colourize_this_aminoacidObject

#

Bioroebe.clear_array_colourize_this_aminoacid

#


1259
1260
1261
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1259

def self.clear_array_colourize_this_aminoacid
  @array_colourize_this_aminoacid = []
end

.clear_stop_codonsObject

#

Bioroebe.clear_stop_codons

#


256
257
258
# File 'lib/bioroebe/codons/codons.rb', line 256

def self.clear_stop_codons
  @stop_codons = []
end

.cleave(with = :with_trypsin, i = ARGV) ⇒ Object

#

Bioroebe.cleave (cleave tag)

This is the general entry-point for “cleave-related” activities, such as cleaving a polypeptide or a DNA strand via an enzyme.

#


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/bioroebe/cleave_and_digest/cleave.rb', line 56

def self.cleave(
    with = :with_trypsin,
    i    = ARGV
  )
  case with
  # ======================================================================= #
  # === :with_trypsin
  # ======================================================================= #
  when :with_trypsin,
       :trypsin,
       :default
    Bioroebe.cleave_with_trypsin(i)
  else
    nil
  end
end

.cleave_with_trypsin(this_sequence = ARGV) ⇒ Object

#

Bioroebe.cleave_with_trypsin

Trypsin cleaves peptides on the C-terminal side of lysine and arginine amino acid residues. If a proline residue is on the carboxyl side of the cleavage site, the cleavage will not occur. If an acidic residue is on either side of the cleavage site, the rate of hydrolysis has been shown to be slower.

This method will return an Array.

#


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bioroebe/cleave_and_digest/cleave.rb', line 21

def self.cleave_with_trypsin(
    this_sequence = ARGV
  )
  # ======================================================================= #
  # === Handle Arrays first
  # ======================================================================= #
  if this_sequence.is_a? Array
    this_sequence = this_sequence.first
  end
  array_cleave_positions = [] # This is the Array that will be returned.
  subrange = ''.dup
  this_sequence.size.times {|index|
    this_char = this_sequence[index, 1]
    case this_char # case tag
    when 'K','R'
      subrange << this_char
      next_char_is = this_sequence[index+1, 1]
      unless next_char_is == 'P' # Exclude Proline.
        array_cleave_positions << subrange
        subrange = ''.dup
      end
    else
      subrange << this_char
    end
  }
  array_cleave_positions << subrange
  return array_cleave_positions
end

.cliner(use_this_token = :default_token, how_many_times = 80, use_this_colour = nil) ⇒ Object

#

Bioroebe.cliner

The first character denotes which token we will use, such as ‘#’, for the line that is to be displayed.

#


2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2555

def self.cliner(
    use_this_token  = :default_token,
    how_many_times  = 80,
    use_this_colour = nil
  )
  require 'bioroebe/colours/colours.rb'
  if use_this_token.is_a? Hash
    # ===================================================================== #
    # === :length
    # ===================================================================== #
    if use_this_token.has_key? :length
      how_many_times = use_this_token.delete(:length)
    end
    if use_this_token.is_a? Hash
      # =================================================================== #
      # === :token
      # =================================================================== #
      if use_this_token.has_key? :token
        use_this_token = use_this_token.delete(:token)
      end
    end
    use_this_token = :default if use_this_token.is_a? Hash
  end
  # ======================================================================= #
  # The following case-when menu must come after the check for Hashes
  # above.
  # ======================================================================= #
  case use_this_token
  when :default_token, :default
    use_this_token = '='
  end
  # ======================================================================= #
  # === handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    if yielded.is_a?(Hash)
      # =================================================================== #
      # === :colour
      # =================================================================== #
      if yielded.has_key? :colour
        use_this_colour = yielded[:colour]  
      # =================================================================== #
      # === :colours
      # =================================================================== #
      elsif yielded.has_key? :colours
        use_this_colour = yielded[:colours]
      end
    #else
    #  cliner(use_this_token, how_many_times)
    end
  end
  if use_this_colour
    e ::Colours.send(use_this_colour, use_this_token * how_many_times)
  else
    e use_this_token * how_many_times
  end
end

.codon_frequencies_of_this_sequence(i = ARGV) ⇒ Object

#

Bioroebe.codon_frequencies_of_this_sequence

Usage example:

x = Bioroebe.codon_frequencies_of_this_sequence('ATGGGCGGGGTGATGGCAATGCCTTTAATGCCGCCAAAAAAAAAAAAAAAA')

Will yield this Hash:

{"AAA"=>5, "ATG"=>4, "CCA"=>1, "CCG"=>1, "TTA"=>1, "CCT"=>1, "GCA"=>1, "GTG"=>1, "GGG"=>1, "GGC"=>1}
#


198
199
200
# File 'lib/bioroebe/codons/show_codon_usage.rb', line 198

def self.codon_frequencies_of_this_sequence(i = ARGV)
  Bioroebe::ShowCodonUsage.new(i) { :be_quiet }.result?
end

.codon_frequency_of_this_string(i = 'ATTCGTACGATCGACTGACTGACAGTCATTCGTAGTACGATCGACTGACTGACAGTCATTCGTAC'\ 'GATCGACTGACTGACAAGTCATTCGTACGATCGACTGACTTGACAGTCATAA', automatically_convert_into_a_RNA_sequence = true) ⇒ Object

#

Bioroebe.codon_frequency_of_this_string

The input to this method should ideally be a String. It will be assumed to be a RNA string, e. g. mRNA. Thus, all T are replaced with U by default. This can be toggled via the second argument of this method.

This method will return a Hash.

Usage example:

Bioroebe.codon_frequency_of_this_string
Bioroebe.codon_frequency_of_this_string 'ATTCGTACGATCGACTACTACT' # => {"UAC"=>2, "GAC"=>1, "AUC"=>1, "ACG"=>1, "CGU"=>1, "AUU"=>1}
#


917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 917

def self.codon_frequency_of_this_string(
    i = 'ATTCGTACGATCGACTGACTGACAGTCATTCGTAGTACGATCGACTGACTGACAGTCATTCGTAC'\
        'GATCGACTGACTGACAAGTCATTCGTACGATCGACTGACTTGACAGTCATAA',
    automatically_convert_into_a_RNA_sequence = true
  )
  i = i.join if i.is_a? Array
  if automatically_convert_into_a_RNA_sequence
    i = i.dup if i.frozen?
    i.tr!('T','U')
  end
  scanned = i.scan(/.../)
  tally = scanned.tally
  # ======================================================================= #
  # We still have to sort it.
  # ======================================================================= #
  sorted_hash = Hash[tally.sort_by {|key, value| value }.reverse]
  return sorted_hash
end

.codon_table_dataset?Boolean

#

Bioroebe.codon_table_dataset?

This method will return the “codon table dataset”, as a Hash.

This Hash will contain entries like this:

{"TAA"=>"*", "TGA"=>'*',"CCA"=>"P", ...

and so forth.

#

Returns:

  • (Boolean)


39
40
41
# File 'lib/bioroebe/codons/codon_table.rb', line 39

def self.codon_table_dataset?
  @codon_table_dataset
end

.codon_table_in_use?Boolean

#

Bioroebe.codon_table_in_use?

Query method to return the currently used codon table.

#

Returns:

  • (Boolean)


83
84
85
# File 'lib/bioroebe/codons/codon_table.rb', line 83

def self.codon_table_in_use?
  @codon_table_in_use
end

.codon_tablesObject

#

Bioroebe.codon_tables

This method will return all codon tables that we have registered.

This is probably not so terribly useful for most projects, but in the event that you do need all codon tables, you can use this method.

The result will be a Hash having key->value pairs such as:

"9" => {"TAA"=>"*", "TAG"=>"*"
#


30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bioroebe/codons/codon_tables.rb', line 30

def self.codon_tables
  require 'bioroebe/requires/require_yaml.rb'
  hash = {}
  _ = "#{yaml_directory?}codon_tables/*.yml"
  all_files = Dir[_].sort
  all_files.each {|yaml_file|
    next if yaml_file.end_with? 'overview.yml' # We reject this one here.
    dataset = YAML.load_file(yaml_file)
    entry_number = File.basename(yaml_file).delete_suffix('.yml')
    dataset = { entry_number => dataset}
    hash.merge!(dataset)
  }
  hash
end

.codons_for_this_aminoacid?(i = ARGV) ⇒ Boolean

#

Bioroebe.codons_for_this_aminoacid?

This method will return all possible DNA codons for a specific aminoacid, as an Array.

So for example, for the aminoacid serine, this method would return an Array containing all 6 codons that code for this aminoacid (if the eukaryotic codon table is used, which also includes humans).

This method supports to query only ONE aminoacid at a given time.

Currently the method relies on the file called “codons_of_the_aminoacids.yml”. In the future, the method here will probably be changed to add support for different codon tables.

Specific invocation examples:

Bioroebe.codons_for?(:serine)
Bioroebe.codons_for?(:tyrosine)
Bioroebe.codons_for?(:threonine)
Bioroebe.codons_for?('T')

To test this for another organism, try:

Bioroebe.use_this_codon_table(:yeast_mitochondria)
Bioroebe.codons_for?('T')
Bioroebe.decode_this_aminoacid 'K' # => ["AAA", "AAG"]
#

Returns:

  • (Boolean)


322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/bioroebe/codons/codons.rb', line 322

def self.codons_for_this_aminoacid?(
    i = ARGV
  )
  # ======================================================================= #
  # First, convert the input a bit and sanitize it.
  # ======================================================================= #
  i = i.first if i.is_a? Array
  if i.is_a?(String) and i.start_with?(':')
    i = i.delete(':').to_sym
  end
  case i # case tag
  when :default,
       nil
    i = :lysine
  end
  if i.is_a? Symbol
    # ===================================================================== #
    # === Convert e. g. :serine into 'ser'
    # ===================================================================== #
    _ = i.to_s.downcase[0 .. 2]
    i = AMINO_ACIDS_THREE_TO_ONE[_]
  end
  # ======================================================================= #
  # Next we must use the one-letter abbreviation, and then find all
  # entries that match to the given input at hand.
  #
  # @codon_table_dataset is a Hash and will have these key->value
  # entries:
  #
  #   "TTC" => "F"
  #
  # ======================================================================= #
  result = @codon_table_dataset.select {|key, value|
    value == i
  }
  return result.keys
end

.colourize_aa(i, array_colourize_these_aminoacids = array_colourize_this_aminoacid? ) ⇒ Object

#

Bioroebe.colourize_aa

Use this method if you wish to colourize an aminoacid, in a red colour.

The input should be the specific aminoacid sequence in question that you wish to see being colourized here.

This currently only works for aminoacids, and only in red. Perhaps at a later time it will become more flexible, but for now, it will be exclusive for aminoacids alone.

Usage example:

puts Bioroebe.colourize_aa 'STGYGGCTR', 'S T Y'
#


1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1901

def self.colourize_aa(
    i,
    array_colourize_these_aminoacids = array_colourize_this_aminoacid?
  )
  if array_colourize_these_aminoacids.is_a? String
    array_colourize_these_aminoacids = array_colourize_these_aminoacids.split(' ') # Split it into an Array.
  end
  unless array_colourize_these_aminoacids.empty?
    if i.nil?
      puts 'You first have to assign a sequence.'
    else
      if i.chars.any? {|entry| array_colourize_these_aminoacids.include? entry }
        # =================================================================== #
        # Ok, we have established a need to colourize the result.
        # =================================================================== #
        array_colourize_these_aminoacids.each {|colour|
          i.gsub!(/(#{colour})/, swarn('\\1')+rev)
        }
      end
    end
  end if use_colours? # But only if we use colours.
  return i
end

.colourize_this_aminoacid_sequence_for_the_commandline(i) ⇒ Object

#

Bioroebe.colourize_this_aminoacid_sequence_for_the_commandline

This method uses some hardcoded colour assignments to the 20 different aminoacids.

Usage example:

puts Bioroebe.colourize_this_aminoacid_sequence_for_the_commandline('NLKRSPTHY')
#


1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1694

def self.colourize_this_aminoacid_sequence_for_the_commandline(i)
  if i.is_a? Array
    i = i.join
  end
  dataset = YAML.load_file(FILE_DEFAULT_COLOURS_FOR_THE_AMINOACIDS)
  array_of_allowed_aminoacids = %w( A R N D B C E Q Z G H I L K M F P S T W Y V )
  _ = ''.dup
  splitted = i.chars
  splitted.each {|this_aminoacid|
    case this_aminoacid
    when *array_of_allowed_aminoacids
      this_aminoacid = send(dataset[this_aminoacid.to_s], this_aminoacid)
    # else # else it will not be colourized.
    end
    _ << this_aminoacid
  }
  return _
end

.colourize_this_fasta_dna_sequence(i = nil, &block) ⇒ Object

#

Bioroebe.colourize_this_fasta_dna_sequence

This toplevel method can be used to colourize a FASTA (DNA) sequence, e. g. “ATGCGCGTATTA” and so forth.

Note that this is intended for the commandline, that is to be displayed on e. g. a KDE Konsole terminal.

Usage examples:

puts Bioroebe.colourize_this_fasta_dna_sequence('ATGCGCATGCGCGTATTAGTATTAATGCGCGTATTAATGCGCGTATTA')
puts Bioroebe.colourize_this_fasta_dna_sequence('ATGCGCATGCGCGTATTAGTATTAATGCGCGTATTAATGCGCGTATTA') { :with_ruler }
puts Bioroebe.colourize_this_fasta_dna_sequence('TGCGCGTATTAGTATTAATGCGCGTATTAATGCGCGTATTA') { :with_ruler_steelblue_colour }
#


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 232

def self.colourize_this_fasta_dna_sequence(
    i = nil,
    &block
  )
  unless ::Bioroebe.respond_to?(:ruler_return_as_string_without_colours)
    require 'bioroebe/misc/ruler.rb'
  end
  if i.nil?
    e 'Please provide a valid FASTA sequence as input to '\
      'Bioroebe.colourize_this_fasta_dna_sequence()'
    return
  end
  if i.is_a? Array
    # ===================================================================== #
    # Arrays will be joined together.
    # ===================================================================== #
    i = i.join(' ').strip
  end
  # ======================================================================= #
  # Check for existing files next:
  # ======================================================================= #
  if i and File.file?(i)
    i = File.read(i)
  end
  original_input = i.dup
  i = i.dup # Always dup it here.
  if i.is_a? String
    # ===================================================================== #
    # The colours are either defined in a file called
    # 'colourize_fasta_sequences.yml' or they are simply hardcoded.
    #
    # The preferred (and thus default) way is to simply make use
    # of that .yml file. That works on my home system, so it
    # should work for other people as well.
    # ===================================================================== #
    if use_colours?
      this_file = FILE_COLOURIZE_FASTA_SEQUENCES
      if File.exist? this_file
        dataset_for_the_colours = YAML.load_file(this_file)
        dataset_for_the_colours.each_pair {|this_nucleotide, this_colour_to_be_used|
          i.gsub!(
            /#{this_nucleotide}/,
            Colours.send(this_colour_to_be_used, this_nucleotide)+
            rev
          )
        }
      else
        i.gsub!(/A/, "#{teal('A')}#{rev}")
        i.gsub!(/C/, "#{slateblue('C')}#{rev}")
        i.gsub!(/G/, "#{royalblue('G')}#{rev}")
        i.gsub!(/T/, "#{steelblue('T')}#{rev}")
        i.gsub!(/U/, "#{steelblue('U')}#{rev}") # Uracil is just the same as Thymine.
      end
    end
  end
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === with_ruler
    # ===================================================================== #
    when :with_ruler,
         :add_ruler,
         :ruler
      i.prepend(
        ::Bioroebe.ruler_return_as_string_without_colours(original_input)+
        "\n"
      )
    else # Assume something like:
         #   :with_ruler_steelblue_colour
      if yielded.to_s.include? 'colo' # This assumes "colour" or "color".
        use_this_colour = yielded.to_s.sub(/_colou?r/,'').
                                       sub(/with_ruler_/,'')
        this_string = send(use_this_colour,
          ::Bioroebe.ruler_return_as_string_without_colours(original_input)+
          "\n"
        )
        i.prepend(this_string)
      end
    end
  end
  return i
end

.colours(enable_or_disable = '+') ⇒ Object

#

Bioroebe.colours

This method can be used to quickly enable or disable colours, by passing ‘+’ or ‘-’.

#


131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/bioroebe/colours/colours.rb', line 131

def self.colours(
    enable_or_disable = '+'
  )
  case enable_or_disable.to_s
  when '+',
       'true'
    enable_colours
  when '-',
       'false',
       ''
    disable_colours
  end
end

.compacter(i = ARGV) ⇒ Object

#

Bioroebe.compacter

Note that this variant will NEVER ask for user-input of the Bioroebe::Compacter class.

#


243
244
245
246
247
# File 'lib/bioroebe/utility_scripts/compacter/compacter.rb', line 243

def self.compacter(
    i = ARGV
  )
  Bioroebe::Compacter.new(i) { :do_not_ask_for_user_input }
end

.complement(i = nil) ⇒ Object

#

Bioroebe.complement

This method will return the complementary DNA strand.

We will use possibilities though.

Usage example:

Bioroebe.complement 'ATGGGTCCC' # => "TACCCAGGG"
#


3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3974

def self.complement(
    i = nil
  )
  # ======================================================================= #
  # Refer to the main Hash.
  # ======================================================================= #
  hash = HASH_DNA_NUCLEOTIDES
  result = ''.dup
  i = i.first if i.is_a? Array
  if i
    if File.exist?(i)
      i = File.readlines(i).join(' ').strip
    end
    i.each_char { |char|
      char = char.upcase
      if hash.has_key? char
        result << hash[char]
      else
        case char.downcase # case tag
        when 'n' # Means any.
          result << '(A/T/G/C)'
        when 'r' # Means a purine.     (larger)
          result << '(A/G)'
        when 'y' # Means a pyrimidine. (smaller)
          result << '(T/C)'
        end
      end
    }
    return result
  end
end

.complementary_dna_strand(i = ARGV) ⇒ Object

#

Bioroebe.complementary_dna_strand

This method will simply return the corresponding (complementary) DNA strand.

Usage example:

Bioroebe.complementary_dna_strand('ATCATCATC') # => "TAGTAGTAG"
#


152
153
154
# File 'lib/bioroebe/nucleotides/complementary_dna_strand.rb', line 152

def self.complementary_dna_strand(i = ARGV)
  retrn Bioroebe::ComplementaryDnaStrand.new(i).result?
end

.complementary_rna_strand(i) ⇒ Object

#

Bioroebe.complementary_rna_strand

This method will simply return the corresponding (complementary) RNA strand.

Usage example:

Bioroebe.complementary_rna_strand('ATCATCATC') # => "UAGUAGUAG"
#


588
589
590
591
592
593
594
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 588

def self.complementary_rna_strand(i)
  if i.is_a? Array
    i = i.first
  end
  hash = partner_nucleotide_hash
  i.chars.map {|entry| hash[entry] }.join.tr('T','U')
end

.compseq(i = ARGV) ⇒ Object

#

Bioroebe.compseq

#


514
515
516
# File 'lib/bioroebe/utility_scripts/compseq/compseq.rb', line 514

def self.compseq(i = ARGV)
  Bioroebe::Compseq.new(i) { :disable_colours_and_be_quiet }.result_as_string?
end

.contains_an_inverted_repeat?(i = 'TTACGAAAAAACGTAA') ⇒ Boolean

#

Bioroebe.contains_an_inverted_repeat?

We assume an inverted repeat to exist if at the least 2 nucleotides match to one another in the reverse, so a total of 4 matching nucleotides. This assumption may not necessarily be correct and we may have to fine-tune this at a later time.

For testing purpose, the sequence ‘TTACGAAAAAACGTAA’ can be used.

#

Returns:

  • (Boolean)


532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 532

def self.contains_an_inverted_repeat?(
    #i = 'AGCCCCGCAAAAAAGGCGGGCU'
    i = 'TTACGAAAAAACGTAA' # This is in the 5'→3' direction.
  )
  contains_an_inverted_repeat = false
  longest_stretch = 0
  current_stretch = 0
  halfed_position = i.size / 2
  both_sides = [
    i[0 .. (halfed_position-1)],
    i[halfed_position .. -1]
  ]
  # ======================================================================= #
  # Now that we have both sides, we will try to match them. First reverse
  # the second, though.
  # ======================================================================= #
  first  = both_sides[0]
  second = both_sides[1].reverse # Work via the reverse sequence.
  first.chars.each_with_index {|this_nucleotide, index|
    if can_base_pair_with?(second[index], this_nucleotide)
      current_stretch += 1
      longest_stretch = current_stretch if current_stretch > longest_stretch 
    else
      current_stretch = 0
    end
  }
  if longest_stretch >= 2
    contains_an_inverted_repeat = true
  end
  return contains_an_inverted_repeat
end

.convert_global_env(i) ⇒ Object

#

Bioroebe.convert_global_env

Note that the method will pick only the first argument given to it if an Array is supplied.

#


801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 801

def self.convert_global_env(i)
  if i.is_a? Array
    i = i.first
  end
  unless Object.const_defined? :ConvertGlobalEnv
    begin # Require an external gem in this case.
      require 'convert_global_env'
    rescue LoadError; end
  end
  if Object.const_defined? :ConvertGlobalEnv
    if i and !i.start_with?('$')
      i = i.dup if i.frozen?
      i.prepend('$')
    end
    return ConvertGlobalEnv.convert(i, :do_not_report_errors) # Handle ENV variables.
  end
  return i
end

.convert_one_letter_to_full(i) ⇒ Object

#

Bioroebe.convert_one_letter_to_full

Convert one aminoacid to the real name.

Usage example:

Bioroebe.convert_one_letter_to_full('T') # => "threonine"
#


1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1959

def self.convert_one_letter_to_full(i)
  if i.is_a? Array
    i.each {|entry| convert_one_letter_to_full(entry) }
  else
    i = i.to_s.downcase # need it to be downcased.
    three_letters = convert_one_letter_to_three(i)
    i = AMINO_ACIDS_ABBREVIATIONS[three_letters]
    return i
  end
end

.convert_one_letter_to_three(i) ⇒ Object

#

Bioroebe.convert_one_letter_to_three

Convert a one-letter-code for an aminoacid into the slightly longer three-letter-code variant for that particular aminoacid.

Note that this method will return the result in a downcased variant, such as “gly” for “glycine”.

Returns:

A string of three characters, if it is a valid one-letter aminoacid.

Usage example for an aminoacid such as Glycine:

Bioroebe.convert_one_letter_to_three('G') # => "gly"
#


1611
1612
1613
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1611

def self.convert_one_letter_to_three(i)
  AMINO_ACIDS_THREE_TO_ONE.invert[i.upcase]
end

.convert_this_codon_to_that_aminoacid(i = ARGV, &block) ⇒ Object

#

Bioroebe.convert_this_codon_to_that_aminoacid

#


225
226
227
228
229
230
# File 'lib/bioroebe/codons/convert_this_codon_to_that_aminoacid.rb', line 225

def self.convert_this_codon_to_that_aminoacid(
    i = ARGV,
    &block
  )
  Bioroebe::ConvertThisCodonToThatAminoacid.new(i) { :be_quiet }.result?.to_s
end

.count_amount_of_aminoacids(i) ⇒ Object

#

Bioroebe.count_amount_of_aminoacids

#


344
345
346
# File 'lib/bioroebe/count/count_amount_of_aminoacids.rb', line 344

def self.count_amount_of_aminoacids(i)
  CountAmountOfAminoacids.new(i)
end

.count_amount_of_nucleotides(i) ⇒ Object

#

Bioroebe.count_amount_of_nucleotides

This method will always return the result in the form of a single line. The order is: A C G T

This can also be used to solve a problem listed at Rosalind.

Invocation examples:

Bioroebe.count_amount_of_nucleotides 'AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC' => "20 17 12 21"
Bioroebe.count_amount_of_nucleotides File.read('/rosalind_dna.txt').strip
#


483
484
485
486
# File 'lib/bioroebe/count/count_amount_of_nucleotides.rb', line 483

def self.count_amount_of_nucleotides(i)
  _ = ::Bioroebe::CountAmountOfNucleotides.new(i, :do_not_run_yet) { :display_short_form }
  _.return_the_amount_of_nucleotides_in_short_form_on_a_single_line
end

.count_AT(i = ARGV) ⇒ Object

#

Bioroebe.count_AT

This method will count how characters in a given String are “A” or “T”, in total. The method will assume that an Array passed to it is meant to be a String.

So, every time this method encounters a “A” or a “T” in that string, we will “add” +1 to the number that will be returned by that method.

Usage example:

Bioroebe.count_AT 'ATTATATACCGCGCCCATATAAA' # => 15
#


25
26
27
28
29
# File 'lib/bioroebe/count/count_at.rb', line 25

def self.count_AT(i = ARGV)
  i = i.join(' ').strip if i.is_a? Array
  i.upcase.count('A')+
  i.upcase.count('T')
end

.count_GC(i = ARGV) ⇒ Object

#

Bioroebe.count_GC

This method will count how characters in a given String are “G” or “C”, in total. The method will assume that an Array passed to it is meant to be a String.

So, every time this method encounters a “G” or a “C” in that string, we will “add” +1 to the number that will be returned by that method.

Specific usage examples:

Bioroebe.count_GC 'ATTATTATGGCCAATATA' # => 4
Bioroebe.count_GC 'ATG' # => 1
#


27
28
29
30
31
# File 'lib/bioroebe/count/count_gc.rb', line 27

def self.count_GC(i = ARGV)
  i = i.join(' ').strip if i.is_a? Array
  i.upcase.count('G')+
  i.upcase.count('C')
end

.count_non_DNA_bases_in_this_sequence(i, array = Bioroebe.return_DNA_nucleotides) ⇒ Object

#

Bioroebe.count_non_DNA_bases_in_this_sequence

Usage example:

Bioroebe.count_non_DNA_bases_in_this_sequence('ATCGF')
#


3021
3022
3023
3024
3025
3026
3027
3028
3029
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3021

def self.count_non_DNA_bases_in_this_sequence(
    i, array = Bioroebe.return_DNA_nucleotides
  )
  i = i.dup
  array.each {|this_nucleotide|
    i.delete!(this_nucleotide)
  }
  return i.size
end

.create_file(i) ⇒ Object

#

Bioroebe.create_file

This method can be used to create a file.

#


1195
1196
1197
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1195

def self.create_file(i)
  FileUtils.touch(i) unless File.file?(i)
end

.create_jar_archiveObject

#

Bioroebe.create_jar_archive

This method will create a .jar file.

To invoke it from the commandline do:

bioroebe --jar

To execute a .jar file do:

java -jar foobar.jar
#


3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3131

def self.create_jar_archive
  e 'Creating a .jar archive next:'
  e
  original_dir = return_pwd
  cd '/home/x/programming/ruby/src/bioroebe/lib/bioroebe/java/bioroebe/src/main/java/'
  esystem 'jar cf bioroebe.jar bioroebe/'
  target_file = File.absolute_path('bioroebe.jar')
  cd original_dir
  if File.exist? target_file
    e 'Moving the created .jar file into the current working '\
      'directory next.'
    move_file(target_file, original_dir)
    e 'It should now be at:'
    e
    e sfile("  #{original_dir}#{File.basename(target_file)}")
    e
  end
  #   esystem 'jar cfe bioroebe.jar myClass myClass.class'
  e
end

.create_new_sequence(i = ARGV, &block) ⇒ Object

#

Bioroebe.create_new_sequence

Create a new Bioroebe::Sequence object. It will also assign to the @sequence module-level instance variable.

#


727
728
729
# File 'lib/bioroebe/sequence/sequence.rb', line 727

def self.create_new_sequence(i = ARGV, &block)
  @sequence = ::Bioroebe::Sequence.new(i, &block)
end

.create_random_aminoacids(how_many_aminoacids = CREATE_N_AMINOACIDS, split_at = nil, be_verbose = false, &block) ⇒ Object

#

Bioroebe.create_random_aminoacids

This method will create a random chain of aminoacids.

The first argument to this method shall denote how many aminoacids are to be generated, e. g. 25 would mean to create “25 aminoacids”.

If the second argument, called ‘split_at`, is not nil and is a number, then this method we add a newline into the returned String.

This method will return a String, consisting of the random aminoacids.

Usage Examples:

Bioroebe.create_random_aminoacids 125
Bioroebe.create_random_aminoacids  25 # => "SQHWVGGGVSRCWLMWAPECMYVWW"
Bioroebe.create_random_aminoacids  15 # => "CLKHMLMGLVAEEKA"
Bioroebe.random_aminoacids(5) # => "STRRM"
Bioroebe.random_aminoacids(8) # => "TRTQHSNN"s
#


203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/bioroebe/aminoacids/create_random_aminoacids.rb', line 203

def self.create_random_aminoacids(
    how_many_aminoacids = CREATE_N_AMINOACIDS,
    split_at            = nil,
    be_verbose          = false,
    &block
  )
  _ = ::Bioroebe::CreateRandomAminoacids.new(
        how_many_aminoacids,
        split_at,
        be_verbose,
        &block
      )
  return _.amino_acid_sequence # ← And return the aminoacid sequence here.
end

.create_the_pdf_tutorial(read_from_this_file = '/home/x/programming/ruby/src/bioroebe/README.md', store_where = '/Depot/j/example.pdf') ⇒ Object

#

Bioroebe.create_the_pdf_tutorial

This method can be used to quickly turn the README.md file into a .pdf file, for whatever the reason the user may want this.

#


2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2858

def self.create_the_pdf_tutorial(
    read_from_this_file = '/home/x/programming/ruby/src/bioroebe/README.md',
    store_where         = '/Depot/j/example.pdf'
  )

  require 'prawn'

  Prawn::Fonts::AFM.hide_m17n_warning = true # Hide a useless warning.

  pdf = Prawn::Document.new(
          page_size: 'A4',
          page_layout: :landscape
        )
  pdf.text "The Bioroebe Project", size: 80
  pdf.start_new_page
  pdf.bounding_box [50, 600], width: 200 do
    pdf.fill_color '000000'
    pdf.text "making bioinformatics great again:", size: 15
  end
  pdf.start_new_page
  dataset = File.read(read_from_this_file, encoding: UTF_ENCODING)
  dataset = dataset.encode("Windows-1252", invalid: :replace, undef: :replace)

  pdf.text(dataset)
  e 'Storing at this location: '+store_where
  pdf.render_file store_where
end

.decode_this_aminoacid_sequence(i = 'KKKA') ⇒ Object

#

Bioroebe.decode_this_aminoacid_sequence

This method can be used as means to decode an aminoacid sequence, such as a String like ‘KKKA’.

The input to this method may also be in the form of an Array, such as [‘K’,‘K’,‘K’,‘A’]. Only valid one-letter aminoacids will be honoured by this method; invalid letters will be silently dropped.

After that, this method will replace all valid letters, that is valid aminoacids (in single letter code), with the corresponding codon. It will return all possibilities.

Invocation example:

Bioroebe.decode_this_aminoacid_sequence('KKKA') # => [["AAG", "AAA"], ["AAG", "AAA"], ["AAG", "AAA"], ["GCT", "GCC", "GCA", "GCG"]]
#


385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/bioroebe/codons/codons.rb', line 385

def self.decode_this_aminoacid_sequence(
    i = 'KKKA'
  )
  if i.is_a? Array
    i = i.join
  end
  if i.is_a? String
    # ===================================================================== #
    # We may have a 3-letter code too, so check for that first.
    # ===================================================================== #
    if i.include? '-'
      i = i.split('-').map {|entry| ::Bioroebe.three_to_one(entry) }
    else
      i = i.split(//)
    end
  end
  i = [i].flatten.map {|entry|
    ::Bioroebe.decode_this_aminoacid(entry)
  }
  return i
end

.deduce_aminoacid_sequence(from_this_sequence = :default) ⇒ Object

#

Bioroebe.deduce_aminoacid_sequence

#


465
466
467
468
469
# File 'lib/bioroebe/aminoacids/deduce_aminoacid_sequence.rb', line 465

def self.deduce_aminoacid_sequence(
    from_this_sequence = :default
  )
  Bioroebe::DeduceAminoacidSequence.new(from_this_sequence)
end

.deduce_most_likely_aminoacid_sequence(from_this_sequence = :default) ⇒ Object

#

Bioroebe.deduce_most_likely_aminoacid_sequence

#


140
141
142
# File 'lib/bioroebe/nucleotides/most_likely_nucleotide_sequence_for_this_aminoacid_sequence.rb', line 140

def self.deduce_most_likely_aminoacid_sequence(from_this_sequence = :default)
  Bioroebe::MostLikelyNucleotideSequenceForThisAminoacidSequence.new(from_this_sequence)
end

.deduce_most_likely_aminoacid_sequence_as_string(i, use_this_codon_tables_frequencies = :default) ⇒ Object

#

Bioroebe.deduce_most_likely_aminoacid_sequence_as_string

This method will attempt to deduce the most likely aminoacid sequence for a given protein, as a String.

Usage example:

Bioroebe.deduce_most_likely_aminoacid_sequence_as_string('KKKA') # => "AAGAAGAAGGCC"
#


452
453
454
455
456
457
458
459
460
461
# File 'lib/bioroebe/codons/codons.rb', line 452

def self.deduce_most_likely_aminoacid_sequence_as_string(
    i, use_this_codon_tables_frequencies = :default
  )
  result = return_the_most_likely_codon_sequence_for_this_aminoacid_sequence(
    i, 
    use_this_codon_tables_frequencies
  )
  result = result.join if result.is_a? Array
  return result
end

.default_colour?Boolean

#

Bioroebe.default_colour?

#

Returns:

  • (Boolean)


96
97
98
# File 'lib/bioroebe/colours/colours.rb', line 96

def self.default_colour?
  @default_colour
end

.delimiter?Boolean

#

Bioroebe.delimiter?

This is simply the primary delimiter used for reading “multiline input” of the Bioroebe::Shell component.

#

Returns:

  • (Boolean)


413
414
415
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 413

def self.delimiter?
  '___'
end

.determine_n_glycosylation_matches(of_this_protein_sequence = 'MKNKFKTQEELVNHLKTVGFVFANSEIYNGLANAWDYGPLGVLLKNNLKNLWWKEFVTKQKDV'\ 'VGLDSAIILNPLVWKASGHLDNFSDPLIDCKNCKARYRADKLIESFDENIHIAENSSNEEFAK'\ 'VLNDYEISCPTCKQFNWTEIRHFNLMFKTYQGVIEDAKNVVYLRPETAQGIFVNFKNVQRSMR'\ 'LHLPFGIAQIGKSFRNEITPGNFIFRTREFEQMEIEFFLKEESAYDIFDKYLNQIENWLVSAC'\ 'GLSLNNLRKHEHPKEELSHYSKKTIDFEYNFLHGFSELYGIAYRTNYDLSVHMNLSKKDLTYF'\ 'DEQTKEKYVPHVIEPSVGVERLLYAILTEATFIEKLENDDERILMDLKYDLAPYKIAVMPLVN'\ 'KLKDKAEEIYGKILDLNISATFDNSGSIGKRYRRQDAIGTIYCLTIDFDSLDDQQDPSFTIRE'\ 'RNSMAQKRIKLSELPLYLNQKAHEDFQRQCQK') ⇒ Object

#

Bioroebe.determine_n_glycosylation_matches

This method can be used to determine N-Glycosylation patterns in a protein.

The input to this method should be an aminoacid chain - aka a protein sequence.

This method will return an Array. This Array holds the indices where a N-glycosylation pattern begins.

Usage example:

Bioroebe.determine_n_glycosylation_matches # => [85, 118, 142, 306, 395]
#


2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2063

def self.determine_n_glycosylation_matches(
    of_this_protein_sequence =
      'MKNKFKTQEELVNHLKTVGFVFANSEIYNGLANAWDYGPLGVLLKNNLKNLWWKEFVTKQKDV'\
      'VGLDSAIILNPLVWKASGHLDNFSDPLIDCKNCKARYRADKLIESFDENIHIAENSSNEEFAK'\
      'VLNDYEISCPTCKQFNWTEIRHFNLMFKTYQGVIEDAKNVVYLRPETAQGIFVNFKNVQRSMR'\
      'LHLPFGIAQIGKSFRNEITPGNFIFRTREFEQMEIEFFLKEESAYDIFDKYLNQIENWLVSAC'\
      'GLSLNNLRKHEHPKEELSHYSKKTIDFEYNFLHGFSELYGIAYRTNYDLSVHMNLSKKDLTYF'\
      'DEQTKEKYVPHVIEPSVGVERLLYAILTEATFIEKLENDDERILMDLKYDLAPYKIAVMPLVN'\
      'KLKDKAEEIYGKILDLNISATFDNSGSIGKRYRRQDAIGTIYCLTIDFDSLDDQQDPSFTIRE'\
      'RNSMAQKRIKLSELPLYLNQKAHEDFQRQCQK'
  )
  if of_this_protein_sequence.is_a? Array
    of_this_protein_sequence.each {|this_sequence|
      determine_n_glycosylation_matches(this_sequence)
    }
  else
    scanned = of_this_protein_sequence.scan(
      REGEX_FOR_N_GLYCOSYLATION_PATTERN
    )
    scanned.flatten.uniq.map {|substring|
      of_this_protein_sequence.index(substring)+1 # +1 because ruby starts at 0.
    }
  end
end

.determine_start_codons_from_the_codon_table(this_codon_table_dataset = @codon_table_dataset) ⇒ Object

#

Bioroebe.determine_start_codons_from_the_codon_table

#


61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/bioroebe/codons/codons.rb', line 61

def self.determine_start_codons_from_the_codon_table(
    this_codon_table_dataset = @codon_table_dataset
  )
  this_codon_table_dataset = this_codon_table_dataset.select {|key, value|
    key == 'START' # '*' refers to a stop codon.
  }
  use_these_start_codons = this_codon_table_dataset.values
  if use_these_start_codons.is_a? Array
    use_these_start_codons = use_these_start_codons.first
  end
  set_start_codon(
    use_these_start_codons
  )
end

.determine_stop_codons_from_the_codon_table(this_codon_table_dataset = @codon_table_dataset) ⇒ Object

#

Bioroebe.determine_stop_codons_from_the_codon_table

This method will determine the stop codons in use for the given species/organism, depending on the proper codon table.

#


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/bioroebe/codons/codons.rb', line 45

def self.determine_stop_codons_from_the_codon_table(
    this_codon_table_dataset = @codon_table_dataset
  )
  this_codon_table_dataset = this_codon_table_dataset.select {|key, value|
    value == '*' # '*' refers to a stop codon.
  }
  use_these_stop_codons = this_codon_table_dataset.keys
  set_stop_codons(
    use_these_stop_codons
  )
end

.digest_this_dna(this_DNA_sequence, hash = {}) ⇒ Object

#

Bioroebe.digest_this_dna

This method depends on the file bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb.

Usage examples:

x = Bioroebe.digest_this_dna(:lambda_genome, with: :EcoRI)
x = Bioroebe.digest_this_dna("/root/Bioroebe/fasta/NC_001416.1_Enterobacteria_phage_lambda_complete_genome.fasta", with: :EcoRI)
x = Bioroebe.digest_this_dna("/Depot/j/foobar.fasta", with: :PvuII)
#


3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3773

def self.digest_this_dna(
    this_DNA_sequence,
    hash = {}
  )
  require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
  restriction_enzymes = Bioroebe.load_and_return_the_restriction_enzymes
  this_restriction_enzyme = nil
  nucleotide_sequence = nil
  if this_DNA_sequence.is_a? Array
    this_DNA_sequence = this_DNA_sequence.first
  end
  if this_DNA_sequence.is_a?(String) and File.exist?(this_DNA_sequence)
    nucleotide_sequence = ::Bioroebe::ParseFasta.new(this_DNA_sequence).sequence?
  end
  # ======================================================================= #
  # === Handle the hash next (and ensure that it is a Hash)
  # ======================================================================= #
  if hash.is_a? Hash
    # ===================================================================== #
    # === :with
    # ===================================================================== #
    if hash.has_key? :with
      this_restriction_enzyme = hash.delete(:with).to_s
    end
  end
  target_sequence = restriction_enzymes[this_restriction_enzyme].dup
  if target_sequence =~ /\d$/ # If it ends with a number.
    target_sequence.chop!
    target_sequence.strip!
  end
  if nucleotide_sequence and
     nucleotide_sequence.include?(target_sequence)
    print rev+'Yes, the restriction-sequence '+
          lightblue(target_sequence)+
          rev+
          ' is found in the given sequence. '
    scanned = nucleotide_sequence.scan(
      /#{target_sequence}/
    )
    erev "It can be found #{steelblue(scanned.size.to_s)}#{rev} "\
         "times, at these positions:"
    e
    sub_sequences = nucleotide_sequence.split(/#{target_sequence}/)
    sub_sequences.sort_by {|entry| entry.size }.reverse.each {|sequence|
      erev "  #{sequence.size}"
    }
    e
    return sub_sequences
  else
    e 'Nothing found.'
  end
end

.directory_frequencies?(codon_tables_directory = CODON_TABLES_DIRECTORY) ⇒ Boolean

#

Bioroebe.directory_frequencies?

Preferentially use this method past the year 2022 - it is a tiny bit more flexible than the above constant.

#

Returns:

  • (Boolean)


685
686
687
688
689
# File 'lib/bioroebe/constants/constants.rb', line 685

def self.directory_frequencies?(
    codon_tables_directory = CODON_TABLES_DIRECTORY
  )
  "#{codon_tables_directory}frequencies/"
end

.disable_colours(be_verbose = false) ⇒ Object

#

Bioroebe.disable_colours

Use this method if you wish to disable colours for the whole Bioroebe project.

#


186
187
188
189
190
191
# File 'lib/bioroebe/colours/colours.rb', line 186

def self.disable_colours(be_verbose = false)
  if be_verbose
    e 'Disabling colours.'
  end
  @use_colours = false
end

.display_all_open_reading_frames_from_this_sequence(i = ARGV) ⇒ Object

#

Bioroebe.display_all_open_reading_frames_from_this_sequence

#


1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1537

def self.display_all_open_reading_frames_from_this_sequence(i = ARGV)
  require 'bioroebe/colours/colours.rb'
  if i.empty?
    array = Bioroebe.return_all_open_reading_frames_from_this_sequence
    pp array
    pp Bioroebe.to_aa(array)
  else
    this_sequence = i
    array = return_all_open_reading_frames_from_this_sequence(this_sequence)
    this_sequence = this_sequence.join
    if array.empty?
      e "No open reading from has been found from "\
        "this sequence: #{this_sequence}"
    else
      e rev+
        'The following ORFs have been found in this sequence: '
      e
      e "  #{Colours.lightgreen(this_sequence)}"
      e
      array.each_with_index {|sequence, index| index += 1
        name_for_the_ORF = "ORF number #{index}"
        e "  #{Colours.steelblue(sequence.ljust(50))} "\
          "#{Colours.lightslategrey('#')} "\
          "#{Colours.mediumseagreen(name_for_the_ORF)}"
      }
      e
    end
  end
end

.dna_sequence(i) ⇒ Object

#

Bioroebe.dna_sequence

Usage example:

dna = Bioroebe.dna_sequence('ATTCGGU')
#


200
201
202
203
204
# File 'lib/bioroebe/sequence/dna.rb', line 200

def self.dna_sequence(i)
  i = i.first if i.is_a? Array
  i.delete!('U') # Reject Uracil there.
  ::Bioroebe::DNA.new(i)
end

.dna_to_aminoacid_sequence(i = ARGV) ⇒ Object

#

Bioroebe.dna_to_aminoacid_sequence

Usage example:

Bioroebe.dna_to_aminoacid_sequence('ATGGGGCCC') # => "MGP"
#


650
651
652
653
654
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 650

def self.dna_to_aminoacid_sequence(
    i = ARGV
  )
  ::Bioroebe::DnaToAminoacidSequence.new(i) { :be_quiet }.sequence?
end

.do_not_truncateObject

#

Bioroebe.do_not_truncate

Do not truncate any “too long” output. This method disable the truncate-functionality.

#


146
147
148
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 146

def self.do_not_truncate
  @truncate = false
end

.do_truncateObject

#

Bioroebe.do_truncate

#


136
137
138
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 136

def self.do_truncate
  @truncate = true
end

.dotplot_array(dna_x, dna_y) ⇒ Object

#

Bioroebe.dotplot_array

This method can be used to return a 2D dotplot-array of two input sequences. Be careful with large data as input - the RAM usage may go up, so this method has NOT been optimized for such situations. It is deliberately kept simple.

#


215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/bioroebe/dotplots/advanced_dotplot.rb', line 215

def self.dotplot_array(dna_x, dna_y)
  dotplot_matrix = Array.new(
    dna_y.size, Array.new(dna_x.size, 0)
  )
  dotplot_matrix = Array.new(dna_y.size) {
    Array.new(dna_x.size) { 0 }
  }
  dna_x.chars.each_with_index {|x_value, x_index|
    # ===================================================================== #
    # Next, we work from top-to-bottom.
    # ===================================================================== #
    dna_y.chars.each_with_index {|y_value, y_index|
      if x_value == y_value
        dotplot_matrix[y_index][x_index] = 1
      end
    }
  }
  return dotplot_matrix
end

.downcase_chunked_display(i, group_together_n_nucleotides = 10) ⇒ Object

#

Bioroebe.downcase_chunked_display

This is similar to the regular chunked display, but will return the nucleotides in a downcased manner, aka “A” will become “a” and so forth.

In the past this functionality resided in its own .rb file, but since as of March 2020 a bin/ executable was added, so that the functionality can be more easily called when the bioroebe gem is installed.

Usage example:

Bioroebe.downcase_chunked_display 'ATGGGGCCTGCAATGGGGCCTGCAATGGGGCCTGCAATGGGGCCTGCAATGGGGCCTGCAATGGGGCCTGCAATGGGGCCTGCAATGGGGCCTGCA'
#


4131
4132
4133
4134
4135
4136
4137
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4131

def self.downcase_chunked_display(
    i,
    group_together_n_nucleotides = 10
  )
  sequence = ::Bioroebe.return_chunked_display(i, group_together_n_nucleotides).downcase
  return sequence
end

.download(from_these_URLs) ⇒ Object

#

Bioroebe.download

#


4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4428

def self.download(
    from_these_URLs
  )
  require 'open-uri'
  array_these_urls = [from_these_URLs].flatten.compact
  array_these_urls.each {|remote_url|
    # ===================================================================== #
    # First, we must determine the remote file listing here.
    # Due to convenience we will simply use curl here.
    # ===================================================================== #
    cmd = "curl -s \"#{remote_url}\" --list-only"
    # e cmd
    remote_files = `#{cmd}`.split("\n")
    remote_files.each {|this_remote_file|
      target = remote_url+this_remote_file
      e "Downloading `#{this_remote_file}` next. '"\
        "(Full target: '#{target})"
      wget_download(target)
    }
  }
end

.download_directory?Boolean

#

Bioroebe.download_directory?

#

Returns:

  • (Boolean)


171
172
173
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 171

def self.download_directory?
  "#{log_directory?}Downloads/"
end

.download_fasta(i) ⇒ Object

#

Bioroebe.download_fasta

Easier wrapper-method to download fasta files.

#


233
234
235
# File 'lib/bioroebe/fasta_and_fastq/download_fasta.rb', line 233

def self.download_fasta(i)
  ::Bioroebe::DownloadFasta.new(i).location?
end

.download_human_genome(from_this_URL = 'https://bioconductor.org/packages/release/data/annotation/src/contrib/BSgenome.Hsapiens.UCSC.hg38_1.4.4.tar.gz') ⇒ Object

#

Bioroebe.download_human_genome

#


2758
2759
2760
2761
2762
2763
2764
2765
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2758

def self.download_human_genome(
    from_this_URL = 'https://bioconductor.org/packages/release/data/annotation/src/contrib/BSgenome.Hsapiens.UCSC.hg38_1.4.4.tar.gz'
  )
  esystem "wget #{from_this_URL}"
  extract(
    File.basename(from_this_URL)
  )
end

.download_taxonomy_database(i = ::Bioroebe::FTP_NCBI_TAXONOMY_DATABASE) ⇒ Object

#

Bioroebe.download_taxonomy_database

#


92
93
94
95
96
# File 'lib/bioroebe/databases/download_taxonomy_database.rb', line 92

def self.download_taxonomy_database(
    i = ::Bioroebe::FTP_NCBI_TAXONOMY_DATABASE
  )
  DownloadTaxonomyDatabase.new(i)
end

.download_this_pdb(i = '355D') ⇒ Object

#

Bioroebe.download_this_pdb

This method can be used to download a remote .pdb file to the local file-system. If the default pdb/ directory exists as well locally then the downloaded .pdb file will be relocated into that file.

An example for a remote URL to a .pdb file would be:

https://files.rcsb.org/view/2BTS.pdb
https://files.rcsb.org/view/355D.pdb
#


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bioroebe/pdb_and_protein_structure/download_this_pdb.rb', line 29

def self.download_this_pdb(
    i = '355D'
  )
  # ======================================================================= #
  # Treat all input as an Array past the next point.
  # ======================================================================= #
  [i].flatten.compact.each {|this_entry|
    if this_entry.frozen?
      this_entry = this_entry.dup
    end
    if this_entry.end_with? '.pdb' # This will lateron be appended again anyway.
      this_entry.sub!(/\.pdb$/,'')
    end
    this_entry.upcase! # For convenience.
    unless this_entry.end_with? '.pdb'
      this_entry << '.pdb'
    end
    e this_entry
    # ===================================================================== #
    # Build up our remote URL next:
    # ===================================================================== #
    remote_url = "https://files.rcsb.org/view/#{this_entry}"
    e steelblue(remote_url)
    esystem "wget #{remote_url}"
    _ = File.basename(remote_url)
    if File.exist? _
      ::Bioroebe.move_file_to_its_correct_location(_)
    end
  }
end

.e(i = '') ⇒ Object

#

Bioroebe.e

#


246
247
248
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 246

def self.e(i = '')
  puts i
end

.edit_C_to_U(of_this_sequence, retain_hyphens = false) ⇒ Object

#

Bioroebe.edit_C_to_U

This method attempts to do a RNA editing job, such as may be done in mitochondrial DNA.

Usage examples:

Bioroebe.edit_C_to_U('AGG-GGU-GCU-UCG-GAU-CGG-GAG')                  # => "AGGGGUGUUUUGGAUUGGGAG"
Bioroebe.edit_C_to_U('AGG-GGU-GCU-UCG-GAU-CGG-GAG', :retain_hyphens) # => "AGG-GGU-GUU-UUG-GAU-UGG-GAG"
Bioroebe.to_aa(Bioroebe.edit_C_to_U('AGG-GGU-GCU-UCG-GAU-CGG-GAG', false)) # => "AGG-GGU-GUU-UUG-GAU-UGG-GAG")
#


4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4402

def self.edit_C_to_U(
    of_this_sequence,
    retain_hyphens = false
  )
  case retain_hyphens
  # ======================================================================= #
  # === :retain_hyphens
  # ======================================================================= #
  when :retain_hyphens
    retain_hyphens = true
  end
  if of_this_sequence.is_a? Array
    of_this_sequence = of_this_sequence.first
  end
  if of_this_sequence.frozen?
    of_this_sequence = of_this_sequence.dup
  end
  unless retain_hyphens
    of_this_sequence.delete!('-') if of_this_sequence.include? '-'
  end
  of_this_sequence.tr('C','U')
end

.editor?Boolean

#

Bioroebe.editor?

This method will determine which editor is to be used, if we have to use an editor for the bioroebe project.

#

Returns:

  • (Boolean)


442
443
444
445
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 442

def self.editor?
  require 'bioroebe/configuration/constants.rb'
  ::Bioroebe::Configuration::DEFAULT_EDITOR_TO_USE
end

.embeddable_interfaceObject

#

Bioroebe.embeddable_interface

#


775
776
777
778
779
# File 'lib/bioroebe/www/embeddable_interface.rb', line 775

def self.embeddable_interface
  object = Object.new
  object.extend(::Bioroebe::EmbeddableInterface)
  return object
end

.enable_coloursObject

#

Bioroebe.enable_colours

Use this method to enable colours for the whole Bioroebe project.

All classes that are part of the Bioroebe project should honour this setting (if it is a class that may make use of colours; some smaller classes do not need colours, and hence have no need for the method here).

#


203
204
205
# File 'lib/bioroebe/colours/colours.rb', line 203

def self.enable_colours
  @use_colours = true
end

.ensure_that_the_base_directories_existObject

#

Bioroebe.ensure_that_the_base_directories_exist

This method will ensure that the base directory for the Bioroebe project exist.

#


3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3259

def self.ensure_that_the_base_directories_exist
  # ======================================================================= #
  # We also need to create the temp directory, as well as having to
  # notify the user that this will be done. The taxonomy subdirectory
  # will also be created.
  # ======================================================================= #
  use_this_log_dir = log_dir?
  unless File.exist? use_this_log_dir
    erev "The base directory at `#{sdir(use_this_log_dir)}#{rev}` does not exist."
    erev 'It will thus be created next.'
    mkdir use_this_log_dir
  end
  # ======================================================================= #
  # === Ensure that the Downloads/ directory exists
  # ======================================================================= #
  _ = "#{use_this_log_dir}Downloads/"
  unless File.exist? _
    erev "The directory at `#{sdir(_)}#{rev}` does not exist."
    erev 'It will thus be created next.'
    mkdir _
  end
  # ======================================================================= #
  # === Ensure that the pdb/ directory exists
  # ======================================================================= #
  _ = "#{use_this_log_dir}pdb/"
  unless File.exist? _
    erev "The directory at `#{sdir(_)}#{rev}` does not exist."
    erev 'It will thus be created next.'
    mkdir _
  end
  autogenerated_sql_files_dir =
    AUTOGENERATED_SQL_FILES_DIR
  unless Dir.exist? autogenerated_sql_files_dir
    erev 'The directory at `'+sdir(autogenerated_sql_files_dir)+
         rev+'` does not exist.'
    erev 'It will thus be created next.'
    mkdir(autogenerated_sql_files_dir)
  end
end

.erev(i = '') ⇒ Object

#

Bioroebe.erev

#


69
70
71
# File 'lib/bioroebe/colours/colours.rb', line 69

def self.erev(i = '')
  puts "#{rev}#{i}"
end

.esystem(i) ⇒ Object

#

Bioroebe.esystem

#


253
254
255
256
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 253

def self.esystem(i)
  puts i.to_s
  system i.to_s
end

.every_reverse_palindrome_in_this_string(i = 'TCAATGCATGCGGGTCTATATGCAT', min_length = 4, max_length = 12) ⇒ Object

#

Bioroebe.every_reverse_palindrome_in_this_string

This method can return every reverse palindrome in the given input String.

The output will be an Array such as this:

[[4, 6], [5, 4], [6, 6], [7, 4], [17, 4], [18, 4], [4, 6], [5, 4]]
#


4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4984

def self.every_reverse_palindrome_in_this_string(
    i          = 'TCAATGCATGCGGGTCTATATGCAT',
    min_length =  4,
    max_length = 12
  )
  require 'bioroebe/sequence/reverse_complement.rb'
  if i.is_a? Array # Arrays will become Strings - or rather, whatever is the first argument.
    i = i.first
  end
  if i and File.exist?(i)
    i = File.readlines(i).reject {|entry|
      entry.start_with?('>')
    }.map {|inner_entry| inner_entry.strip }.join
  end
  # ======================================================================= #
  # How do we find all subsequences that are relevant? Well - we
  # need to find all the sequences between min_length and
  # max_length, e. g. 4 and 12.
  # ======================================================================= #
  string = i.dup
  array_containing_starting_index_and_length_of_reverse_palindromes = []
  i.size.times {
    substrings = return_every_substring_from_this_sequence(string)
    substrings.each {|entry|
      next if entry.size > max_length
      if (entry.size >= min_length) and
         (Bioroebe.reverse_complement(entry) == entry)
        array_containing_starting_index_and_length_of_reverse_palindromes << 
          [i.index(entry)+1, entry.size]
      end
    }
    string[0,1] = ''
  }
  return array_containing_starting_index_and_length_of_reverse_palindromes
end

.ewarn(i = '') ⇒ Object

#

Bioroebe.swarn

#


168
169
170
# File 'lib/bioroebe/colours/colours.rb', line 168

def self.ewarn(i = '')
  e swarn(i)
end

.extract(i = ARGV) ⇒ Object

#

Bioroebe.extract

This method can be used to quickly extract a local archive.

#


2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2298

def self.extract(
    i = ARGV
  )
  require 'bioroebe/colours/sdir_sfancy_sfile_simp_swarn.rb'
  if i.is_a? Array
    i = i.join(' ').strip
  end
  unless i.include?('/')
    unless File.exist? i
      i = return_pwd+
          File.basename(i)
    end
  end
  if File.exist? i
    case i
    when /bz2$/
      _ = "tar -xfv #{i}"
    when /xz$/
      _ = "tar -xvf #{i}"
    end
    if be_verbose?
      e "Now extracting `#{sfancy((i).squeeze('/'))}`."
      esystem(_)
      e 'Done extracting!'
    else
      system _
    end
  else
    ewarn "Can not extract #{sfile(i)} because it does "\
          "not appear to exist."
  end
end

.extractseq(i = 'AAAGGGTTT', *regions) ⇒ Object

#

Bioroebe.extractseq

Bioroebe.extractseq reads a sequence and writes sub-sequences from it to file. The set of regions to extract is specified on the command-line or in a file as pairs of start and end positions. The regions are written in the order in which they are specified. Thus, if the sequence AAAGGGTTT has been input and the regions: 7-9, 3-4 have been specified, then the output sequence will be:

TTTAG

See the next ruler for that:

012345678 # real index
123456789 # desired index
AAAGGGTTT

Usage example

Bioroebe.extractseq('AAAGGGTTT', '7-9','3-4') # => TTTAG
#


282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 282

def self.extractseq(
    i = 'AAAGGGTTT',
    *regions
  )
  new_sequence = ''.dup
  regions.each {|this_region|
    splitted = this_region.split('-') # We assume a '-' must be there.
    first_position = splitted[0].to_i - 1
    last_position  = splitted[1].to_i - 1
    subsequence = i[first_position .. last_position]
    new_sequence << subsequence
  }
  return new_sequence
end

.fasta_dir?Boolean

#

Bioroebe.fasta_dir?

#

Returns:

  • (Boolean)


721
722
723
# File 'lib/bioroebe/constants/constants.rb', line 721

def self.fasta_dir?
  "#{Bioroebe.log_dir?}fasta/"
end

.fasta_directory?Boolean

#

Bioroebe.fasta_directory?

This method will return a path such as “/root/Bioroebe/fasta/”.

#

Returns:

  • (Boolean)


193
194
195
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 193

def self.fasta_directory?
  "#{::Bioroebe.log_directory?}fasta/"
end

.fetch_data_from_uniprot(i = ARGV) ⇒ Object

#

Bioroebe.fetch_data_from_uniprot

#


259
260
261
# File 'lib/bioroebe/utility_scripts/fetch_data_from_uniprot/fetch_data_from_uniprot.rb', line 259

def self.fetch_data_from_uniprot(i = ARGV)
  Bioroebe::FetchDataFromUniprot.new(i)
end

.fetch_fasta_sequence_from_pdb(i = ARGV) ⇒ Object

#

Bioroebe.fetch_fasta_sequence_from_pdb

#


126
127
128
# File 'lib/bioroebe/pdb_and_protein_structure/fetch_fasta_sequence_from_pdb.rb', line 126

def self.fetch_fasta_sequence_from_pdb(i = ARGV)
  Bioroebe::FetchFastaSequenceFromPdb.new(i)
end

.file_amino_acidsObject

#

Bioroebe.file_amino_acids

#


638
639
640
# File 'lib/bioroebe/constants/constants.rb', line 638

def self.file_amino_acids
  FILE_AMINO_ACIDS
end

.file_amino_acids_abbreviationsObject

#

Bioroebe.file_amino_acids_abbreviations

#


651
652
653
# File 'lib/bioroebe/constants/constants.rb', line 651

def self.file_amino_acids_abbreviations
  FILE_AMINO_ACIDS_ABBREVIATIONS
end

.file_amino_acids_frequencyObject

#

Bioroebe.file_amino_acids_frequency

#


830
831
832
# File 'lib/bioroebe/constants/constants.rb', line 830

def self.file_amino_acids_frequency
  "#{BIOROEBE_YAML_AMINOACIDS_DIRECTORY}amino_acids_frequency.yml"
end

.file_amino_acids_long_name_to_one_letterObject

#

Bioroebe.file_amino_acids_long_name_to_one_letter

This method will return a String such as:

"/home/Programs/Ruby/3.1.2/lib/ruby/site_ruby/3.1.0/bioroebe/yaml/aminoacids/amino_acids_long_name_to_one_letter.yml"
#


1134
1135
1136
# File 'lib/bioroebe/constants/constants.rb', line 1134

def self.file_amino_acids_long_name_to_one_letter
  "#{project_yaml_directory?}aminoacids/amino_acids_long_name_to_one_letter.yml"
end

.file_fastq_quality_schemesObject

#

Bioroebe.file_fastq_quality_schemes

This constant will point to a location such as this one here:

/Programs/Ruby/2.6.4/lib/ruby/site_ruby/2.6.0/bioroebe/yaml/fastq_quality_schemes.yml
#


733
734
735
# File 'lib/bioroebe/constants/constants.rb', line 733

def self.file_fastq_quality_schemes
  "#{project_yaml_directory?}fasta_and_fastq/fastq_quality_schemes.yml"
end

.file_molecular_weightObject

#

Bioroebe.file_molecular_weight

#


1122
1123
1124
# File 'lib/bioroebe/constants/constants.rb', line 1122

def self.file_molecular_weight
  "#{project_yaml_directory?}aminoacids/molecular_weight.yml"
end

.file_restriction_enzymesObject

#

Bioroebe.file_restriction_enzymes

#


885
886
887
# File 'lib/bioroebe/constants/constants.rb', line 885

def self.file_restriction_enzymes
  FILE_RESTRICTION_ENZYMES
end

.file_statistics?Boolean

#

Bioroebe.file_statistics?

This file can normally be found here:

$BIOROEBE/yaml/statistics.yml
#

Returns:

  • (Boolean)


714
715
716
# File 'lib/bioroebe/constants/constants.rb', line 714

def self.file_statistics?
  "#{Bioroebe.log_dir?}statistics.yml"
end

.file_talensObject

#

Bioroebe.file_talens

#


740
741
742
# File 'lib/bioroebe/constants/constants.rb', line 740

def self.file_talens
  "#{project_yaml_directory?}talens.yml"
end

.filter_away_invalid_aminoacids(i) ⇒ Object

#

Bioroebe.filter_away_invalid_aminoacids

Usage example:

Bioroebe.filter_away_invalid_aminoacids('ATMÜ') # => "ATM"
#


174
175
176
177
# File 'lib/bioroebe/constants/constants.rb', line 174

def self.filter_away_invalid_aminoacids(i)
  array_that_is_allowed = all_aminoacids?
  return i.chars.select {|entry| array_that_is_allowed.include? entry }.join
end

.filter_away_invalid_nucleotides(i, preserve_uracil = false) ⇒ Object

#

Bioroebe.filter_away_invalid_nucleotides

This method can be used to filter away invalid nucleotides. An “invalid” nucleotide is, for example, if you work with DNA sequences, any character that is not allowed to be part of DNA. For example, Uracil, which can be found (almost exclusively) only in RNA.

As for now, the behaviour is to downcase the given input before applying the .tr() method on the given String.

Usage example:

Bioroebe.filter_away_invalid_nucleotides 'ATGCCGGAGGAGANNN' # => "ATGCCGGAGGAGA"
#


3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3842

def self.filter_away_invalid_nucleotides(
    i,
    preserve_uracil = false
  )
  if i.is_a? Array
    i = i.join(' ').strip
  end
  case preserve_uracil
  when :preserve_uracil
    preserve_uracil = true
  when :preserve_nothing
    preserve_uracil = false
  end
  i = i.to_s.upcase
  if preserve_uracil
    i.tr!('B,D-F,H-S,V-Z','') # A T C G U
  else
    i.tr!('B,D-F,H-S,U-Z','') # A T C G
  end
  return i
end

.find_substring(full_string = 'GATATATGCATATACTT', this_substring = :default) ⇒ Object

#

Bioroebe.find_substring

This method can be used to find a substring within a larger String.

For example, in the below default values, the substring “ATAT” would exist at the positions 2, 4 and 10, if compared to the larger parent string “GATATATGCATATACTT”.

The following display may help you see this more easily, in regards to the substring matches:

GATATATGCATATACTT
 ATATAT  ATAT

If you look closely, you will be able to see that “ATAT” can be found three times in the string above.

Indices in this context start at position 1, not 0. This is mostly done to refer to nucleotides or aminoacids, which also typically start at the first letter. Position 0 makes no sense for a nucleotide - what would “nucleotide 0” even refer to?

The first argument to this method may also be the path to a locally existing file, such as “/rosalind_subs.txt”. In fact this method has been largely motivated by Rosalind tasks.

The method will return an Array with the positions of all substrings that are found in the full_string variable. See the usage example below for how this may be.

Usage example:

Bioroebe.find_substring 'GATATATGCATATACTT', 'ATAT' # => [2, 4, 10]
#


2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2401

def self.find_substring(
    full_string    = 'GATATATGCATATACTT', # ← The full String comes here.
    this_substring = :default             # ← The substring we are searching for comes here.
  )
  if full_string.is_a? Array
    # ===================================================================== #
    # Presently this method will only work on the first member of an Array.
    # ===================================================================== #
    full_string = full_string.first
  end
  if full_string and File.file?(full_string) and
     this_substring == :default
    # ===================================================================== #
    # In this case it is ok to read from that file.
    # ===================================================================== #
    _ = File.read(full_string)
    splitted = _.split("\n")
    full_string    = splitted.first
    this_substring = splitted.last
  end
  case this_substring
  # ======================================================================= #
  # Use a default value in this case. In reality users should supply
  # their own substring when they use this method here.
  # ======================================================================= #
  when :default,
       nil
    this_substring = 'ATAT'
  else
    if this_substring.empty?
      this_substring = 'ATAT'
    end
  end
  if full_string.nil? or full_string.empty?
    full_string = 'GATATATGCATATACTT' # ← Use the default in this case.
  end
  result = Array.new.tap { |indexes|
    final_index_position = full_string.size - this_substring.size
    i = 0
    while (i < final_index_position)
      index = full_string.to_s.index(this_substring.to_s, i)
      break if index.nil?
      i = index + 1
      indexes << i
    end
  }
  result = nil if result.empty? # ← We will try this here; could also return an empty Array, though.
  result # Return our findings here.
end

.format_this_nucleotide_sequence(i = ARGV, &block) ⇒ Object

#

Bioroebe.format_this_nucleotide_sequence

#


660
661
662
663
664
665
666
667
668
669
670
# File 'lib/bioroebe/nucleotides/show_nucleotide_sequence/show_nucleotide_sequence.rb', line 660

def self.format_this_nucleotide_sequence(
    i = ARGV,
    &block
  )
  _ = ::Bioroebe::ShowNucleotideSequence.new(
    i, :do_not_report_anything, &block
  )
  _.clear_padding
  _.format
  _.formatted_sequence?
end

.frequency_per_thousand(i) ⇒ Object

#

Bioroebe.frequency_per_thousand

The input to this method should be a String ideally. If an Array is input then it will simply be .join()-ed.

This method will return a String, if all goes well.

#


867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 867

def self.frequency_per_thousand(i)
  result = "fields: [triplet] [frequency: per thousand] ([number])\n".dup # This String will be returned.
  if i.is_a? Array
    i = i.join
  end
  i.delete!("\n")
  hash = ::Bioroebe.codon_frequency_of_this_string(i)
  hash.default = 0
  total_n_elements = hash.values.sum
  append_this = <<-EOF 

UUU#{thousand_percentage(hash['UUU'], total_n_elements)}(     #{hash['UUU']})  UCU#{thousand_percentage(hash['UCU'], total_n_elements)}(     #{hash['UCU']})  UAU#{thousand_percentage(hash['UAU'], total_n_elements)}(     #{hash['UAU']})  UGU#{thousand_percentage(hash['UGU'], total_n_elements)}(     #{hash['UGU']})
UUC#{thousand_percentage(hash['UUC'], total_n_elements)}(     #{hash['UUC']})  UCC#{thousand_percentage(hash['UCC'], total_n_elements)}(     #{hash['UCC']})  UAC#{thousand_percentage(hash['UAC'], total_n_elements)}(     #{hash['UAC']})  UGC#{thousand_percentage(hash['UGC'], total_n_elements)}(     #{hash['UGC']})
UUA#{thousand_percentage(hash['UUA'], total_n_elements)}(     #{hash['UUA']})  UCA#{thousand_percentage(hash['UCA'], total_n_elements)}(     #{hash['UCA']})  UAA#{thousand_percentage(hash['UAA'], total_n_elements)}(     #{hash['UAA']})  UGA#{thousand_percentage(hash['UGA'], total_n_elements)}(     #{hash['UGA']})
UUG#{thousand_percentage(hash['UUG'], total_n_elements)}(     #{hash['UUG']})  UCG#{thousand_percentage(hash['UCG'], total_n_elements)}(     #{hash['UCG']})  UAG#{thousand_percentage(hash['UAG'], total_n_elements)}(     #{hash['UAG']})  UGG#{thousand_percentage(hash['UGG'], total_n_elements)}(     #{hash['UGG']})

CUU#{thousand_percentage(hash['CUU'], total_n_elements)}(     #{hash['CUU']})  CCU#{thousand_percentage(hash['CCU'], total_n_elements)}(     #{hash['CCU']})  CAU#{thousand_percentage(hash['CAU'], total_n_elements)}(     #{hash['CAU']})  CGU#{thousand_percentage(hash['CGU'], total_n_elements)}(     #{hash['CGU']})
CUC#{thousand_percentage(hash['CUC'], total_n_elements)}(     #{hash['CUC']})  CCC#{thousand_percentage(hash['CCC'], total_n_elements)}(     #{hash['CCC']})  CAC#{thousand_percentage(hash['CAC'], total_n_elements)}(     #{hash['CAC']})  CGC#{thousand_percentage(hash['CGC'], total_n_elements)}(     #{hash['CGC']})
CUA#{thousand_percentage(hash['CUA'], total_n_elements)}(     #{hash['CUA']})  CCA#{thousand_percentage(hash['CCA'], total_n_elements)}(     #{hash['CCA']})  CAA#{thousand_percentage(hash['CAA'], total_n_elements)}(     #{hash['CAA']})  CGA#{thousand_percentage(hash['CGA'], total_n_elements)}(     #{hash['CGA']})
CUG#{thousand_percentage(hash['CUG'], total_n_elements)}(     #{hash['CUG']})  CCG#{thousand_percentage(hash['CCG'], total_n_elements)}(     #{hash['CCG']})  CAG#{thousand_percentage(hash['CAG'], total_n_elements)}(     #{hash['CAG']})  CGG#{thousand_percentage(hash['CGG'], total_n_elements)}(     #{hash['CGG']})

AUU#{thousand_percentage(hash['AUU'], total_n_elements)}(     #{hash['AUU']})  ACU#{thousand_percentage(hash['ACU'], total_n_elements)}(     #{hash['ACU']})  AAU#{thousand_percentage(hash['AAU'], total_n_elements)}(     #{hash['AAU']})  AGU#{thousand_percentage(hash['AGU'], total_n_elements)}(     #{hash['AGU']})
AUC#{thousand_percentage(hash['AUC'], total_n_elements)}(     #{hash['AUC']})  ACC#{thousand_percentage(hash['ACC'], total_n_elements)}(     #{hash['ACC']})  AAC#{thousand_percentage(hash['AAC'], total_n_elements)}(     #{hash['AAC']})  AGC#{thousand_percentage(hash['AGC'], total_n_elements)}(     #{hash['AGC']})
AUA#{thousand_percentage(hash['AUA'], total_n_elements)}(     #{hash['AUA']})  ACA#{thousand_percentage(hash['ACA'], total_n_elements)}(     #{hash['ACA']})  AAA#{thousand_percentage(hash['AAA'], total_n_elements)}(     #{hash['AAA']})  AGA#{thousand_percentage(hash['AGA'], total_n_elements)}(     #{hash['AGA']})
AUG#{thousand_percentage(hash['AUG'], total_n_elements)}(     #{hash['AUG']})  ACG#{thousand_percentage(hash['ACG'], total_n_elements)}(     #{hash['ACG']})  AAG#{thousand_percentage(hash['AAG'], total_n_elements)}(     #{hash['AAG']})  AGG#{thousand_percentage(hash['AGG'], total_n_elements)}(     #{hash['AGG']})

GUU#{thousand_percentage(hash['GUU'], total_n_elements)}(     #{hash['GUU']})  GCU#{thousand_percentage(hash['GCU'], total_n_elements)}(     #{hash['GCU']})  GAU#{thousand_percentage(hash['GAU'], total_n_elements)}(     #{hash['GAU']})  GGU#{thousand_percentage(hash['GGU'], total_n_elements)}(     #{hash['GGU']})
GUC#{thousand_percentage(hash['GUC'], total_n_elements)}(     #{hash['GUC']})  GCC#{thousand_percentage(hash['GCC'], total_n_elements)}(     #{hash['GCC']})  GAC#{thousand_percentage(hash['GAC'], total_n_elements)}(     #{hash['GAC']})  GGC#{thousand_percentage(hash['GGC'], total_n_elements)}(     #{hash['GGC']})
GUA#{thousand_percentage(hash['GUA'], total_n_elements)}(     #{hash['GUA']})  GCA#{thousand_percentage(hash['GCA'], total_n_elements)}(     #{hash['GCA']})  GAA#{thousand_percentage(hash['GAA'], total_n_elements)}(     #{hash['GAA']})  GGA#{thousand_percentage(hash['GGA'], total_n_elements)}(     #{hash['GGA']})
GUG#{thousand_percentage(hash['GUG'], total_n_elements)}(     #{hash['GUG']})  GCG#{thousand_percentage(hash['GCG'], total_n_elements)}(     #{hash['GCG']})  GAG#{thousand_percentage(hash['GAG'], total_n_elements)}(     #{hash['GAG']})  GGG#{thousand_percentage(hash['GGG'], total_n_elements)}(     #{hash['GGG']})
EOF
  result << append_this
  return result
end

.gc_content(of_this_sequence, round_to_n_positions = 3) ⇒ Object

#

Bioroebe.gc_content

This is a convenience method that will return back the GC content, as a percentage value, of the input-given sequence (nucleotide sequence).

So for instance, the following example will correctly return 50.0 because the G and C content of the sequence is exactly 50%.

The second argument can be used for denoting where to round.

Usage example:

Bioroebe.gc_content('ATCG') # => 50.0
#


280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/bioroebe/calculate/calculate_gc_content.rb', line 280

def self.gc_content(
    of_this_sequence,
    round_to_n_positions = 3
  )
  if of_this_sequence.is_a? Array
    of_this_sequence.each {|entry|
      gc_content(of_this_sequence, round_to_n_positions)
    }
  else
    ::Bioroebe::CalculateGCContent.gc_percentage(
      of_this_sequence, round_to_n_positions
    )
  end
end

.genbank_to_fasta(this_file, be_verbose = :be_verbose) ⇒ Object

#

Bioroebe.genbank_to_fasta

This method will convert from a genbank file, to a .fasta file.

Invocation example:

Bioroebe.genbank_to_fasta('/home/x/programming/ruby/src/bioroebe/lib/bioroebe/data/genbank/sample_file.genbank')
#


1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
# File 'lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb', line 1457

def self.genbank_to_fasta(
    this_file,
    be_verbose = :be_verbose
  )
  case be_verbose
  when :be_quiet
    be_verbose = false
  end
  if this_file.is_a? Array
    this_file = this_file.first
  end
  if File.exist? this_file
    _ = Bioroebe::ParseFasta.new(this_file) { :be_quiet }
  else
    _ = Bioroebe::ParseFasta.new(:do_not_run_yet) { :be_quiet }
    _.set_data # This will use the default file.
    _.split_into_proper_sections
  end
  file_path = _.save_into_a_fasta_file(be_verbose)
  return file_path
end

.generate_nucleotide_sequence_based_on_these_frequencies(n_nucleotides = 1061, hash_frequencies = { A: 0.3191430, C: 0.2086633, G: 0.2580345, T: 0.2141593 }) ⇒ Object

#

Bioroebe.generate_nucleotide_sequence_based_on_these_frequencies

The second argument to this method should be a Hash.

The default output may be a String such as this one here:

AACTGAACATTTTAGGAGATATCAAGACCCTCTGATTCTCAAGGAATAATTAGCTAATTT

Usage example:

Bioroebe.generate_nucleotide_sequence_based_on_these_frequencies(:default, { A: 0.25, C: 0.25, G: 0.25, T: 0.25 })
#


4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4675

def self.generate_nucleotide_sequence_based_on_these_frequencies(
    n_nucleotides = 1061, # Denote how many nucleotides to use.
    hash_frequencies = {
      A: 0.3191430,
      C: 0.2086633,
      G: 0.2580345,
      T: 0.2141593
    }
  )
  case n_nucleotides
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    n_nucleotides = 500
  end
  result = ''.dup
  frequency_for_A = hash_frequencies[:A]
  frequency_for_C = hash_frequencies[:C]
  frequency_for_G = hash_frequencies[:G]
  frequency_for_T = hash_frequencies[:T]
  n_nucleotides.times {|run_number_n|
    use_this_number = rand(0)
    if use_this_number <= frequency_for_A
      result << 'A'
    elsif use_this_number <= (frequency_for_A+frequency_for_C)
      result << 'C'
    elsif use_this_number <= (frequency_for_A+frequency_for_C+frequency_for_G)
      result << 'G'
    elsif use_this_number <= (frequency_for_A+frequency_for_C+frequency_for_G+frequency_for_T)
      result << 'T'
    end
  }
  return result
end

.generate_pdf_tutorialObject

#

Bioroebe.generate_pdf_tutorial

#


11918
11919
11920
# File 'lib/bioroebe/shell/shell.rb', line 11918

def self.generate_pdf_tutorial
  ::Bioroebe::Shell.generate_pdf_tutorial
end

.generate_random_dna_sequence(i = ARGV, optional_hash_with_the_frequencies = {}) ⇒ Object

#

Bioroebe.generate_random_dna_sequence

This method will “generate” a random DNA sequence (as a String).

A String will be returned by this method.

The second argument to this method can be a Hash, specifying the percentage likelihood for each of the nucleotides. See the following usage examples to find out how to use this.

Usage examples:

Bioroebe.random_dna 15 # => "TTGGTAAGCTCTTTA"
Bioroebe.random_dna 25 # => "TTAGCACAAGCATGGACGGACCAGA"
Bioroebe.random_dna(50, { A: 10, T: 10, C: 10, G: 70}) # => "GGGGTGGGGAGGGTATGCGGAGGAAGGGCGGGAAGGGCGGGGGCTGGGCG"
Bioroebe.random_dna(20, 'ATGGGGGGGG') # => "TGAGGGGGGGGGTGGGAGGG"
Bioroebe.random_dna(20, 'ATGGGGGGGG') # => "GGTAGGGGGGGGTAGGGGGG"
#


3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3646

def self.generate_random_dna_sequence(
    i                                  = ARGV,
    optional_hash_with_the_frequencies = {} # ← This may be a String too, mind you.
  )
  # ======================================================================= #
  # First define our result-String. This one will be returned by this
  # method.
  # ======================================================================= #
  result = ''.dup
  _ = Bioroebe::DNA_NUCLEOTIDES # Get a handle to the four DNA nucleotides.
  if i.is_a? Array
    i = i.join.strip
  end
  case i
  when :default
    i = 250
  end
  i = i.to_i # This is "n times".
  # ======================================================================= #
  # First handle the case where the user passed a String:
  # ======================================================================= #
  if optional_hash_with_the_frequencies.is_a? String
    pool = optional_hash_with_the_frequencies.dup.chars.shuffle
    i.times {
      if pool.size == 0
        pool = optional_hash_with_the_frequencies.dup.chars.shuffle
      end
      result << pool.pop
    }
  elsif optional_hash_with_the_frequencies.empty?
    # ===================================================================== #
    # This is the default clause.
    # ===================================================================== #
    i.times {
      result << _.sample
    }
  else
    # ===================================================================== #
    # Else, the user wants to use a frequency hash:
    # ===================================================================== #
    hash = optional_hash_with_the_frequencies
    frequency_for_A = hash[:A]
    frequency_for_T = hash[:T]
    frequency_for_C = hash[:C]
    frequency_for_G = hash[:G]
    i.times {
      percentage = rand(100)+1
      if percentage <= frequency_for_A
        match = 'A'
      elsif (percentage > frequency_for_A) and
            (percentage <= frequency_for_A+frequency_for_T)
        match = 'T'
      elsif (percentage > frequency_for_A+frequency_for_T) and
            (percentage <= frequency_for_A+frequency_for_T+frequency_for_C)
        match = 'C'
      elsif (percentage > frequency_for_A+frequency_for_T+frequency_for_C) and
            (percentage <= frequency_for_A+frequency_for_T+frequency_for_C+frequency_for_G)
        match = 'G'
      else
        e 'Not found a match for '+percentage.to_s
      end
      result << match
    }
  end
  result
end

.generate_random_rna_sequence(i = ARGV) ⇒ Object

#

Bioroebe.generate_random_rna_sequence

The input-argument should be a number, an Integer, such as 10.

Usage example:

Bioroebe.generate_random_rna_sequence(10)
#


2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2662

def self.generate_random_rna_sequence(i = ARGV)
  if i.is_a? Array
    i = i.join(' ').strip
  end
  _ = Bioroebe::RNA_NUCLEOTIDES # Point to the allowed RNA-nucleotides here.
  result = ''.dup
  i.to_s.to_i.times {
    result << _.sample
  }
  return result
end

.guess_format(i) ⇒ Object

#

Bioroebe.guess_format

#


2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2770

def self.guess_format(i)
  case i
  # ======================================================================= #
  # === fasta
  # ======================================================================= #
  when /.fa$/,
       /.fna$/,
       /.faa$/,
       /.fasta$/
    'fasta'
  # ======================================================================= #
  # === fastq
  # ======================================================================= #
  when /.fq$/,
       /.fastq$/
    'fastq'
  when /.fx/
    ''
  end
end

.hamming_distance(sequence1 = 'ATCG', sequence2 = 'ATCC') ⇒ Object

#

Bioroebe.hamming_distance

This method will return an Integer, aka a number, which represents the hamming distance between two sequences of equal length. This will state how many differences exist between two same-sized sequences (aka sequences that have the same length).

Do note that a second implementation may exist for the hamming distance, in the Bioroebe project.

Usage example:

Bioroebe.hamming_distance('ATCG','ATCC') # => 1
#


1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1062

def self.hamming_distance(
    sequence1 = 'ATCG',
    sequence2 = 'ATCC'
  )
  if sequence1.nil?
    e 'Please provide a sequence (String) as input to this method.'
    return
  end
  if sequence1.is_a? String
    sequence1 = sequence1.split(//)
  end
  if sequence2.is_a? String
    sequence2 = sequence2.split(//)
  end
  array_sequence1 = [sequence1].flatten
  array_sequence2 = [sequence2].flatten
  # ======================================================================= #
  # Zip the two sequences together, then reduce this Array of
  # zipped values to an integer value, which will be returned.
  # ======================================================================= #
  zipped_array = array_sequence1.zip(array_sequence2)
  hamming_value = 0
  zipped_array.each { |left, right|
    hamming_value += 1 unless left == right
  }
  return hamming_value
end

.has_this_restriction_enzyme?(name_of_restriction_enzyme) ⇒ Boolean

#

Bioroebe.has_this_restriction_enzyme?

This method will determine whether we have a specific restriction enzyme registered in the yaml file restriction_enzymes.yml or whether we do not. That way we can query whether a restriction enzyme is registered (and thus available) or whether it is not.

The method will downcase all keys in use to simplify finding a matching entry.

Usage example:

Bioroebe.has_this_restriction_enzyme? 'MvnI'    # => true
Bioroebe.has_this_restriction_enzyme? 'EcoRI'   # => true
Bioroebe.has_this_restriction_enzyme? 'EcoRII'  # => true
Bioroebe.has_this_restriction_enzyme? 'EcoRIII' # => false
Bioroebe.has_this_restriction_enzyme? 'PvuI'    # => true
Bioroebe.has_this_restriction_enzyme? 'PvuII'   # => true
Bioroebe.has_this_restriction_enzyme? 'PvuIII'  # => false
#

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bioroebe/enzymes/has_this_restriction_enzyme.rb', line 33

def self.has_this_restriction_enzyme?(
    name_of_restriction_enzyme
  )
  _ = {}
  if name_of_restriction_enzyme.frozen?
    name_of_restriction_enzyme = name_of_restriction_enzyme.dup
  end
  name_of_restriction_enzyme.delete!('?') if name_of_restriction_enzyme.include? '?'
  name_of_restriction_enzyme.downcase!
  ::Bioroebe.restriction_enzymes?.each_pair {|key, value|
    _[key.downcase] = value
  }
  return _.has_key? name_of_restriction_enzyme
end

.hash_codon_tables?Boolean

#

Bioroebe.hash_codon_tables?

#

Returns:

  • (Boolean)


115
116
117
# File 'lib/bioroebe/codons/codon_tables.rb', line 115

def self.hash_codon_tables?
  ::Bioroebe::CodonTables.definitions?
end

.index_this_fasta_file(i = ARGV) ⇒ Object

#

Bioroebe.index_this_fasta_file

This method will use samtools faidx to index files.

#


569
570
571
572
573
574
575
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 569

def self.index_this_fasta_file(i = ARGV)
  [i].flatten.compact.each {|this_file|
    e
    esystem "samtools faidx #{this_file}"
    e
  }
end

.infer_type_from_this_sequence(i = 'ATGGTACGACAC') ⇒ Object

#

Bioroebe.infer_type_from_this_sequence

This method will try to infer the type from a given sequence.

The three valid return types are the following symbols:

:dna
:rna
:protein

Note that this may not work 100% reliably, so do not depend too much on this method working absolutely perfect.

#


4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4473

def self.infer_type_from_this_sequence(
    i = 'ATGGTACGACAC'
  )
  if i.is_a? Array
    i = i.join
  end
  type = :dna # This is the default - DNA.
  # ======================================================================= #
  # === :rna
  # ======================================================================= #
  if i.include? 'U'
    type = :rna
  # ======================================================================= #
  # === :dna
  # ======================================================================= #
  elsif i =~ /^[ATCG]+$/
    type = :dna 
  # ======================================================================= #
  # === :protein
  # ======================================================================= #
  else # else simply assume this to be a protein.
    type = :protein
  end
  return type
end

.initialize_codonsObject

#

Bioroebe.initialize_codons

This method will first initialize the stop-codons, and then determine the start codons in use.

#


82
83
84
85
# File 'lib/bioroebe/codons/codons.rb', line 82

def self.initialize_codons
  initialize_stop_codons
  determine_start_codons_from_the_codon_table
end

.initialize_default_stop_codonsObject

#

Bioroebe.initialize_default_stop_codons

This method will initialize the default stop codons. This defaults to

    1. the stop codons that can be found in the human genome.

Note that this method will NOT work if @stop_codons already contains elements; this is a tiny “safeguard” to prevent erroneous use. If you wish to not be handicapped then clear it by yourself first, via:

Bioroebe.clear_stop_codons
#


246
247
248
249
250
251
# File 'lib/bioroebe/codons/codons.rb', line 246

def self.initialize_default_stop_codons
  if @stop_codons.empty?
    @stop_codons << %w( TAG TAA TGA ) # <- Add the default stop codons here.
    @stop_codons.flatten! 
  end
end

.input_as_dna(i) ⇒ Object

#

Bioroebe.input_as_dna

This method will only accept input that is DNA, that is, the short letter variant (thus, A, T, C or G). Any other input will be stripped away, aka discarded, so this methods acts as a filter - a forward-filter for DNA.

The method will return a “String” that is assumed to be a “DNA string”. You can expect only DNA nucleotides to be part of that string.

Usage example:

Bioroebe.input_as_dna 'UUTGAGGACCA' # => "TGAGGACCA"
#


4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4516

def self.input_as_dna(i)
  i = i.first if i.is_a? Array
  i = i.dup if i.frozen?
  i.upcase!
  # ======================================================================= #
  # The next method is defined in this file here.
  # ======================================================================= #
  i = filter_away_invalid_nucleotides(i, :preserve_nothing)
  return i
end

.is_a_protein?(i = ARGV, &block) ⇒ Boolean

#

Bioroebe.is_a_protein?

Usage example:

puts Bioroebe.is_a_protein?('AGATCGTACTGAGCTATCGTAC') # => false
puts Bioroebe.is_a_protein?('WWW') # => true
#

Returns:

  • (Boolean)


740
741
742
743
744
745
746
747
# File 'lib/bioroebe/sequence/sequence.rb', line 740

def self.is_a_protein?(i = ARGV, &block)
  if i.is_a? Array
    i = i.join(' ').strip
  end
  _ = Bioroebe.sequence(i)
  _.try_to_infer_the_type
  return _.is_a_protein?
end

.is_a_purine?(i = 'A') ⇒ Boolean

#

Bioroebe.is_a_purine?

This method will simply return true if we have a purine (as the given input to this method), and false otherwise.

The argument given to this method should be a single letter, such as ‘A’ or ‘G’ (a String).

In nucleic acids, two types of nucleobases are purine derivatives and would, thus, return true via this method:

- adenine (A)
- guanine (G)
#

Returns:

  • (Boolean)


612
613
614
615
616
617
618
619
620
621
622
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 612

def self.is_a_purine?(
    i = 'A'
  )
  i = i.first if i.is_a? Array
  case i
  when 'A','G'
    true
  else # This is for T, C and U, at the least.
    false
  end
end

.is_a_pyrimidine?(i = 'C') ⇒ Boolean

#

Bioroebe.is_a_pyrimidine?

This method will return true if we have a pyrimidine (as input), and false otherwise.

In DNA and RNA we may find these pyrimidine derivatives:

cytosine (C), thymine (T), and uracil (U)

URL for explanations is at:

https://en.wikipedia.org/wiki/Pyrimidine
#

Returns:

  • (Boolean)


3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3329

def self.is_a_pyrimidine?(
    i = 'C'
  )
  i = i.first if i.is_a? Array
  case i
  when 'C','T','U'
    true
  else # This is for A and G, at the least.
    false
  end
end

.is_a_stop_codon?(i) ⇒ Boolean

#

Bioroebe.is_a_stop_codon?

This method will return true if the given input to this method (== codon) is a stop codon in the currently selected codon table, otherwise it will return false.

Returns:

- true if the given input is a stop codon
- false otherwise

Usage examples:

Bioroebe.is_a_stop_codon? 'TAG'
Bioroebe.stop_codon? 'TAG'
#

Returns:

  • (Boolean)


228
229
230
# File 'lib/bioroebe/codons/codons.rb', line 228

def self.is_a_stop_codon?(i)
  @stop_codons.include?(i.upcase)
end

.is_an_aminoacid?(i) ⇒ Boolean

#

Bioroebe.is_an_aminoacid?

This method will return either true or false, depending on whether the given input is an Aminoacid or whether it is not.

Currently this requires the long letter, but it should be no problem to also check or one-letter key codes.

Usage examples:

Bioroebe.is_aminoacid? 'Tryptophane' # => true
Bioroebe.is_aminoacid? 'Glycine'
Bioroebe.is_aminoacid? 'lysine'      # => true
Bioroebe.is_aminoacid? 'GB'
#

Returns:

  • (Boolean)


1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1751

def self.is_an_aminoacid?(i)
  i = i.first if i.is_a? Array
  i = i.dup if i.frozen?
  if i
    i.downcase!
    return_value = false
    keys = AMINO_ACIDS_RESTE.keys
    return_value = true if keys.include? i
    return return_value
  else
    e 'Something went wrong in the method Bioroebe.is_an_aminoacid?() - '\
      'nil was passed.'
    e 'caller() was:'
    e
    pp caller
    e
  end
end

.is_in_the_three_letter_code?(i = 'Lys-Asp-Glu-Leu') ⇒ Boolean

#

Bioroebe.is_in_the_three_letter_code?

This method can be used to check whether the given input is in the three letter code.

Usage examples:

Bioroebe.is_in_the_three_letter_code? 'Lys-Asp-Glu-Leu'     # => true
Bioroebe.is_in_the_three_letter_code? 'Lys-Asp-Glu-Leu-Lun' # => false
#

Returns:

  • (Boolean)


1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1126

def self.is_in_the_three_letter_code?(
    i = 'Lys-Asp-Glu-Leu'
  )
  result = true
  dataset = AMINO_ACIDS_THREE_TO_ONE
  if i.is_a? Array
    i = i.join('-').strip
  end
  i = i.to_s.dup
  i.strip!
  i.delete!(' ') if i.include? ' '
  i.delete!('-') if i.include? '-'
  scanned = i.scan(/.../).map(&:downcase)
  scanned.each {|key|
    if dataset.has_key? key
    else
      result = false
    end
  }
  return result
end

.is_on_roebe?Boolean

#

Bioroebe.is_on_roebe?

#

Returns:

  • (Boolean)


12
13
14
# File 'lib/bioroebe/toplevel_methods/roebe.rb', line 12

def self.is_on_roebe?
  ENV['IS_ROEBE'] == '1' # This is the case on my home system.
end

.is_palindrome?(i) ⇒ Boolean

#

Bioroebe.is_palindrome?

This method will return true if the target sequence is a palindrome, and false otherwise.

When will a sequence be considered to be a “palindrome”?

Firstly, it must have an even number of components. If it has an odd number then it can never be a Palindrome, by definition alone.

So, “GATC” is a palindrome, but “GATCC” can never be. (GATC is a palindrome because the reverse of GATC will bind to itself again.)

Usage examples:

Bioroebe.is_palindrome? 'GAATTC'   # => true
Bioroebe.is_palindrome? 'GAATTCCC' # => false
#

Returns:

  • (Boolean)


4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4888

def self.is_palindrome?(i)
  require 'bioroebe/toplevel_methods/nucleotides.rb'
  if i.is_a? Array
    i = i.first
  end
  hash = ::Bioroebe.partner_nucleotide_hash
  return_value = false
  if i
    if i.to_s.size.odd? # Then it can never be a Palindrome.
    else # Ok, it may be a palindrome here.
      first_half = i[0 .. (i.size / 2)-1]
      _ = ''.dup
      first_half.chars.reverse.each {|char|
        _ << hash[char] if hash.has_key? char
      }
      if (first_half + _) == i # Compare it to the original input.
        return_value = true
      end
    end
    return return_value
  else
    :invalid_input
  end
end

.is_reverse_complement?(i) ⇒ Boolean

#

Bioroebe.is_reverse_complement?

This method was specifically added to solve a problem at Rosalind.

Usage example:

Bioroebe.is_reverse_complement?('GCATGC')  # => true
Bioroebe.is_reverse_complement?('GCATGCA') # => false
#

Returns:

  • (Boolean)


3622
3623
3624
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3622

def self.is_reverse_complement?(i)
  ::Bioroebe.complement(i) == i.reverse
end

.is_start_codon?(i) ⇒ Boolean

#

Bioroebe.is_start_codon?

Query-method to determine whether the given input is a start codon.

The method will return true if the given input is a start codon in the currently selected codon table; otherwise this method will return false.

This way the method can be used to determine whether something is a start codon.

Note that the method does not do any additional checks, so, for instance, if you have RNA and work with that, then you may have to convert it to DNA before calling this method here. See the usage examples below for that.

Usage examples:

Bioroebe.is_a_start_codon? 'AUG' # => false
Bioroebe.is_a_start_codon? 'ATG' # => true
#

Returns:

  • (Boolean)


96
97
98
# File 'lib/bioroebe/codons/start_codons.rb', line 96

def self.is_start_codon?(i)
  @start_codon == i.upcase
end

.is_this_a_valid_codon?(i) ⇒ Boolean

#

Bioroebe.is_this_a_valid_codon?

Invocation examples:

Bioroebe.is_this_a_valid_codon?('UUU') # => true
Bioroebe.is_this_a_valid_codon?('UUS') # => false
#

Returns:

  • (Boolean)


436
437
438
439
# File 'lib/bioroebe/codons/codons.rb', line 436

def self.is_this_a_valid_codon?(i)
  conversion_result = Bioroebe.codon_to_aminoacid(i)
  !conversion_result.empty?
end

.is_this_sequence_a_EGF2_pattern?(this_sequence, use_this_pattern = :default) ⇒ Boolean

#

Bioroebe.is_this_sequence_a_EGF2_pattern?

This method makes use of a “special” syntax, which will be explained next.

An ‘x’ represents any amino acid.

ALV

represents any of the 3 amino acids (Ala, Leu, Val).

A(2,4) - represents 2 to 4 Ala.

x(2,4) - represents 2 to 4 amino acids (any).

The pattern for the EGF-like domain signature 2 is:

C-x-C-x(2)-[GP]-[FYW]-x(4,8)-C

This means cystein, any aminoacid, cystein, two any aminoacids, either G or P, either F or Y o W, then 4 up to 8 any aminoacid, followed by C.

#

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/bioroebe/patterns/is_this_sequence_a_EGF2_pattern.rb', line 33

def self.is_this_sequence_a_EGF2_pattern?(
    this_sequence,
    use_this_pattern = :default
  )
  result = false
  if this_sequence.is_a? Array
    this_sequence = this_sequence.first
    if this_sequence.nil?
      this_sequence = 'XXCXCXXGFXXXXCXX'
    end
  end
  case use_this_pattern
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    use_this_pattern = 'C-x-C-x(2)-[GP]-[FYW]-x(4,8)-C'
  end
  # ======================================================================= #
  # See this on rubular: https://rubular.com/r/1DSfXLyuCy1QSi
  # ======================================================================= #
  use_this_regex =
    /(C[ACDEFGHIKLMNPQRSTVWY]C[ACDEFGHIKLMNPQRSTVWY]{2}[GP][FYW][ACDEFGHIKLMNPQRSTVWY]{4,8}C)/
  this_sequence =~ use_this_regex
  if $1
    result = true
  end
  return result
end

.last_updated?Boolean

#

Bioroebe.last_updated?

#

Returns:

  • (Boolean)


33
34
35
# File 'lib/bioroebe/version/version.rb', line 33

def self.last_updated?
  LAST_UPDATE
end

.leading_five_prime(i = '', get_rid_of_spaces = false, use_hyphen = true) ⇒ Object

#

Bioroebe.leading_five_prime

This method will output the leading 5’ part of a nucleotide sequence, like a header. In this context, the most commonly usage case for this method is to display a leading “5’-” part to a sequence such as “ATCGATCG”.

The hyphen refers to the ‘-’ character which may be used by this method. This is optional, though - have a look at the third argument to this method called ‘use_hyphen?.

#


4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4564

def self.leading_five_prime(
    i                 = '', # The default to '' is important.
    get_rid_of_spaces = false,
    use_hyphen        = true # By default this method will use '-' characters.
  )
  case get_rid_of_spaces
  # ======================================================================= #
  # === :no_spaces
  # ======================================================================= #
  when :no_spaces,
       :get_rid_of_spaces
    get_rid_of_spaces = true
  end
  if i.is_a? Array
    i = i.join.strip
  end
  if use_hyphen
    _ = "5' - #{i}" # ← This here is the header-tag.
  else # This variant is a bit simpler and shorter.
    _ = "5' #{i}" # ← This here is the header-tag.
  end
  if get_rid_of_spaces
    _ = _.dup if _.frozen?
    _.delete!(' ')
  end
  return _
end

.length_modifier(of_this_file = ARGV, &block) ⇒ Object

#

Bioroebe.length_modifier

#


76
77
78
79
80
81
# File 'lib/bioroebe/fasta_and_fastq/length_modifier/length_modifier.rb', line 76

def self.length_modifier(
    of_this_file = ARGV,
    &block
  )
  Bioroebe::LengthModifier.new(of_this_file, &block)
end

.levenshtein_distance(str1, str2) ⇒ Object

#

Bioroebe.levenshtein_distance

Usage example:

Bioroebe.levenshtein_distance('shevy', 'chevy').to_s # => 1
#


5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 5084

def self.levenshtein_distance(
    str1,
    str2
  )
  n = str1.length
  m = str2.length

  return m if n.zero?
  return n if m.zero?

  x = nil
  d = (0 .. m).to_a # Get the distance.

  # ======================================================================= #
  # To avoid duplicating an enumerable object, create it outside of the
  # loop.
  # ======================================================================= #
  str2_codepoints = str2.codepoints

  str1.each_codepoint.with_index(1) { |char1, i|
    j = 0
    while j < m
      cost = (char1 == str2_codepoints[j]) ? 0 : 1
      x = min3(
        d[j + 1] + 1, # insertion
        i + 1,        # deletion
        d[j] + cost   # substitution
      )
      d[j] = i
      i = x
      j += 1
    end
    d[m] = x
  }
  x # Return the cost here.
end

.load_and_return_the_restriction_enzymesObject

#

Bioroebe.load_and_return_the_restriction_enzymes

This method will load, and then return the restriction enzymes that are bundled within the bioroebe-project.

#


878
879
880
# File 'lib/bioroebe/constants/constants.rb', line 878

def self.load_and_return_the_restriction_enzymes
  YAML.load_file(FILE_RESTRICTION_ENZYMES)
end

.load_psych_or_syck(i = @use_this_yaml_engine) ⇒ Object

#

Bioroebe.load_psych_or_syck

#


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/bioroebe/requires/require_yaml.rb', line 63

def self.load_psych_or_syck(
    i = @use_this_yaml_engine
  )
  case i
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default,
       :psych,
       nil
    require 'yaml' # This should suffice as-is.
  else # Else give more information to the user how to get syck.
    begin
      require 'syck'
    rescue LoadError
      # =================================================================== #
      # Inform the user how syck can be installed.
      # =================================================================== #
      e
      e 'syck is not available. It can be installed via:'
      e
      e '  gem install syck'
      e
    end
  end
end

.load_the_codon_table_dataset(use_this_codon_table = @codon_table_in_use) ⇒ Object

#

Bioroebe.load_the_codon_table_dataset

Several aliases can be used as input for this method, such as:

Bioroebe.load_the_codon_table_dataset(:codons_of_the_aminoacids)
#


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/bioroebe/codons/codon_table.rb', line 96

def self.load_the_codon_table_dataset(
    use_this_codon_table = @codon_table_in_use
  )
  this_file = nil
  # ======================================================================= #
  # We ideally prefer a Symbol here as input, but we won't force it.
  # Since as of May 2020, a Symbol would be bad, because the user
  # shall be able to supply a String too, onto which we can then
  # use a regex. Thus, we have to extend the following entries to
  # support the full name as well - we'll put this as the second
  # last position.
  # ======================================================================= #
  case use_this_codon_table # case tag
  # ======================================================================= #
  # === :human
  # ======================================================================= #
  when :human,
       :humans,
       :default,
       :codons_of_the_aminoacids,
       /^Standard(-|_| |,)?\(?Eukaryote\)?$/i,
       /^human?$/i,
       1
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/1.yml"
  # ======================================================================= #
  # === :mitochondria
  #
  # This actually refers to "The Vertebrate Mitochondrial Code".
  # ======================================================================= #
  when :mitochondria,
       :vertebrate_mitochondria,
       /^Vertebrate(-|_| |,)?Mitochondrial$/i,
       2
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/2.yml"
  # ======================================================================= #
  # === :yeast_mitochondria
  # ======================================================================= #
  when :yeast_mitochondrial_code,
       :yeast_mitochondria,
       :yeast_mt,
       /^Yeast(-|_| |,)?Mitochondrial$/i,
       3
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/3.yml"
  # ======================================================================= #
  # === Coelenterate Mitochondrial Code
  # ======================================================================= # 
  when 4,
       /^Coelenterate(-|_| |,)?Mitochondrial$/i,
       /^Coelenterate(-|_| |,)?Mitochondrial(-|_| |,)?Code$/i,
       /^Mold(-|_| |,)?(-|_| |,)?Protozoan(-|_| |,)?(-|_| |,)?Coelenterate(-|_| |,)?Mitochondrial(-|_| |,)?and(-|_| |,)?Mycoplasma\/Spiroplasma$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/4.yml"
  # ======================================================================= #
  # === 5
  # ======================================================================= #
  when 5,
       /^Invertebrate(-|_| |,)?Mitochondrial$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/5.yml"
  # ======================================================================= #
  # === 6
  # ======================================================================= #
  when 6,
       /^Ciliate(-|_| |,)?Macronuclear(-|_| |,)?and(-|_| |,)?Dasycladacean$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/6.yml"
  # ======================================================================= #
  # === 7
  # ======================================================================= #
  when 7
    e 'No codon table 7 exists. Please avoid calling it.'
  # ======================================================================= #
  # === 8
  # ======================================================================= #
  when 8
    e 'No codon table 8 exists. Please avoid calling it.'
  # ======================================================================= #
  # === 9
  # ======================================================================= #
  when 9,
       /^Echinoderm(-|_| |,)?Mitochondrial$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/9.yml"
  # ======================================================================= #
  # === 11
  # ======================================================================= #
  when 10,
       /^Euplotid(-|_| |,)?Nuclear$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/10.yml"
  # ======================================================================= #
  # === :bacteria
  #
  # This is the codon-table for bacteria, including E. coli.
  # ======================================================================= #
  when :bacteria,
       :bacterium,
       :prokaryotes,
       :ecoli,
       :e_coli,
       11,
       /^Bacteria$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/11.yml"
  # ======================================================================= #
  # === 11
  # ======================================================================= #
  when 12,
       /^Alternative(-|_| |,)?Yeast(-|_| |,)?Nuclear$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/12.yml"
  # ======================================================================= #
  # === 13
  # ======================================================================= #
  when 13,
       /^Ascidian(-|_| |,)?Mitochondrial$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/13.yml"
  # ======================================================================= #
  # === 14
  # ======================================================================= #
  when 14,
       /^Flatworm(-|_| |,)?Mitochondrial$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/14.yml"
  # ======================================================================= #
  # === Blepharisma Macronuclear
  #
  # This refers to a unicellular protist. See:
  #
  #   https://en.wikipedia.org/wiki/Blepharisma
  #
  # ======================================================================= #
  when :blepharisma_macronuclear,
       15,
       /^Blepharisma(-|_| |,)?Macronuclear$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/15.yml"
  # ======================================================================= #
  # === Chlorophycean Mitochondrial
  # ======================================================================= #
  when :chlorophycean_mitochondrial,
       16,
       /^Chlorophycean(-|_| |,)?Mitochondrial$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/16.yml"
  # ======================================================================= #
  # === Trematode Mitochondrial Code
  # ======================================================================= #
  when :trematode_mitochondrial_code,
       21,
       /^Trematode(-|_| |,)?Mitochondrial$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/21.yml"
  # ======================================================================= #
  # === Scenedesmus obliquus mitochondrial
  # ======================================================================= #
  when :scenedesmus_obliquus_mitochondrial,
       22,
       /^Scenedesmus(-|_| |,)?obliquus(-|_| |,)?mitochondrial$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/22.yml"
  # ======================================================================= #
  # === Thraustochytrium Mitochondrial
  # ======================================================================= #
  when :thraustochytrium_mitochondrial,
       23,
       /^Thraustochytrium(-|_| |,)?Mitochondrial$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/23.yml"
  # ======================================================================= #
  # === Pterobranchia Mitochondrial
  # ======================================================================= #
  when :pterobranchia_mitochondrial,
       24,
       /^Pterobranchia(-|_| |,)?Mitochondrial(-|_| |,)?Code$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/24.yml"
  # ======================================================================= #
  # === Candidate Division SR1 and Gracilibacteria Code
  # ======================================================================= #
  when :candidate_division_sr1_and_gracilibacteria,
       25,
       /^Candidate(-|_| |,)?Division(-|_| |,)?SR1(-|_| |,)?and(-|_| |,)?Gracilibacteria(-|_| |,)?Code$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/25.yml"
  # ======================================================================= #
  # === Pachysolen tannophilus Nuclear Code
  # ======================================================================= #
  when :pachysolen_tannophilus_nuclear,
       :pachysolen_tannophilus_nuclear_code,
       26,
       /^Pachysolen(-|_| |,)?tannophilus(-|_| |,)?Nuclear(-|_| |,)?Code$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/26.yml"
  # ======================================================================= #
  # === Karyorelict
  # ======================================================================= #
  when :karyorelict,
       :karyorelict_nuclear_code,
       27,
       /^Karyorelict(-|_| |,)?Nuclear$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/27.yml"
  # ======================================================================= #
  # === Condylostoma Nuclear Code
  # ======================================================================= #
  when :condylostoma,
       :condylostoma_nuclear_code,
       28,
       /^Condylostoma(-|_| |,)?Nuclear$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/28.yml"
  # ======================================================================= #
  # === Mesodinium Nuclear Code
  # ======================================================================= #
  when :mesodinium,
       :mesodinium_nuclear_code,
       29,
       /^Mesodinium(-|_| |,)?Nuclear$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/29.yml"
  # ======================================================================= #
  # === Peritrich Nuclear Code
  # ======================================================================= #
  when :peritrich,
       :peritrich_nuclear_code,
       30,
       /^Peritrich(-|_| |,)?Nuclear$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/30.yml"
  # ======================================================================= #
  # === Blastocrithidia Nuclear Code
  # ======================================================================= #
  when :blastocrithidia,
       :blastocrithidia_nuclear_code,
       31,
       /^Blastocrithidia(-|_| |,)?Nuclear$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/31.yml"
  # ======================================================================= #
  # === Cephalodiscidae Mitochondrial UAA-Tyr Code
  # ======================================================================= #
  when :cephalodiscidae,
       :cephalodiscidae_nuclear_code,
       33,
       /^Cephalodiscidae(-|_| |,)?Mitochondrial(-|_| |,)?UAA-Tyr(-|_| |,)?Code$/i
    this_file = "#{::Bioroebe.project_yaml_directory?}codon_tables/33.yml"
  else
    e "(Line: #{__LINE__}) Unknown input was given "\
    "to file bioroebe/codons/codon_table.rb: `#{use_this_codon_table}`"
  end
  @codon_table_dataset = YAML.load_file(this_file)
end

.log_directory?Boolean

#

Bioroebe.log_directory?

This method will keep track over where we will store output, related to the Bioroebe project. On my home system this will default to “/root/Bioroebe” usually.

#

Returns:

  • (Boolean)


46
47
48
# File 'lib/bioroebe/log_directory/log_directory.rb', line 46

def self.log_directory?
  @log_directory
end

.longest_common_substring(sequences) ⇒ Object

#

Bioroebe.longest_common_substring

This method will return the longest common substring. There may be more than one solution, though.

Note that this method was specifically written for Rosalind, so it may not be too overly useful for most general tasks. For example, it is not optimised for speed, so you should probably not use it for very long sequences.

#


3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3095

def self.longest_common_substring(sequences)
  if sequences and !sequences.empty? and File.file?(sequences.first)
    require 'bioroebe/requires/require_all_fasta_and_fastq_files.rb'
    hash = parse_fasta_quietly(sequences.first).hash?
    sequences = hash.values.map {|entry| entry.delete("\n") }
  end
  # ======================================================================= #
  # First obtain a handle towards the shortest sequence.
  # ======================================================================= #
  shortest_sequence = sequences.min_by(&:length)
  maxlen = shortest_sequence.length
  maxlen.downto(1) {|len|
    0.upto(maxlen - len) { |start|
      substring = shortest_sequence.to_s[start,len]
      if sequences.all? {|seq| seq.to_s.include? substring }
        return shortest_sequence.class.new(substring)
      end
    }
  }
  return nil
end

.map_ncbi_entry_to_eutils_id(i = 'NC_001416.1.fasta') ⇒ Object

#

Bioroebe.map_ncbi_entry_to_eutils_id

This is a general “URL mapper” from certain NCBI IDs to specific nucleotide sequences. Only some URLs will be mapped, in particular those that I use more frequently.

The method was created specifically to allow simpler input via the commandline and the bioshell - it is easier to remember a name such as “rhinovirus” as opposed to the NC entry, which is “NC_038311”.

Usage examples:

Bioroebe.map_ncbi_entry_to_eutils_id 'rhinovirus'
Bioroebe.map_ncbi_entry_to_eutils_id 'T6'
#


3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3170

def self.map_ncbi_entry_to_eutils_id(
    i = 'NC_001416.1.fasta'
  )
  case i
  # ======================================================================= #
  # === Lambda phage genome
  # ======================================================================= #
  when /^-?-?NC_001416.1.fasta$/i,
       'lambda'
    i = '9626243'
  # ======================================================================= #
  # === P1
  # ======================================================================= #
  when 'NC_005856.1.fasta',
       'P1'
    i = '46401626'
  # ======================================================================= #
  # === P2
  # ======================================================================= #
  when 'NC_041848.1.fasta',
       'P2'
    i = '1631913463'
  # ======================================================================= #
  # === T12
  # ======================================================================= #
  when 'NC_028700.1.fasta',
       'T12'
    i = '966201481'
  # ======================================================================= #
  # === T2
  # ======================================================================= #
  when 'AP018813.1.fasta',
       'T2'
    i = 'AP018813.1'
  # ======================================================================= #
  # === T4
  # ======================================================================= #
  when 'NC_000866.4.fasta',
       'T4'
    i = 'NC_000866.4'
  # ======================================================================= #
  # === T6
  # ======================================================================= #
  when 'T6'
    i = 'MH550421.1'
  # ======================================================================= #
  # === rhinovirus
  # ======================================================================= #
  when /NC_038311/,
       'rhinovirus'
    i = '1464306962'
  end
  return i
end

.min3(a, b, c) ⇒ Object

#

Bioroebe.min3

#


3883
3884
3885
3886
3887
3888
3889
3890
3891
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3883

def self.min3(a, b, c)
  if a < b && a < c
    a
  elsif b < c
    b
  else
    c
  end
end

.mirror_repeat_of(this_sequence = 'GAC', use_separator_token = false, use_colours = true, be_verbose = false) ⇒ Object

#

Bioroebe.mirror_repeat_of

This is the easier toplevel API for class MirrorRepeat.

Note that this will not report anything; it will just return a String that can then be embedded elsewhere.

Usage example:

x = Bioroebe.mirror_repeat('ATGC')
#


215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/bioroebe/utility_scripts/mirror_repeat/mirror_repeat.rb', line 215

def self.mirror_repeat_of(
    this_sequence       = 'GAC',
    use_separator_token = false, # Whether to show a "|" or not.
    use_colours         = true,
    be_verbose          = false
  )
  _ = Bioroebe::MirrorRepeat.new(this_sequence) {{
    separator_token: use_separator_token,
    use_colours:     use_colours,
    be_verbose:      be_verbose
  }}
  return _.result?
end

.mkdir(i) ⇒ Object

#

Bioroebe.mkdir (mkdir tag)

#


3302
3303
3304
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3302

def self.mkdir(i)
  FileUtils.mkdir_p(i)
end

.move_file(a, b) ⇒ Object

#

Bioroebe.move_file

#


1093
1094
1095
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1093

def self.move_file(a, b)
  FileUtils.mv(a, b)
end

.move_file_to_its_correct_location(i) ⇒ Object

#

Bioroebe.move_file_to_its_correct_location

#


140
141
142
# File 'lib/bioroebe/utility_scripts/move_file_to_its_correct_location.rb', line 140

def self.move_file_to_its_correct_location(i)
  Bioroebe::MoveFileToItsCorrectLocation.new(i)
end

.mv(old, new) ⇒ Object

#

Bioroebe.mv

This method can be used to rename or move a (local) file.

#


1186
1187
1188
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1186

def self.mv(old, new)
  FileUtils.mv(old, new)
end

.n_stop_codons_in_this_sequence?(i = :default, check_for_this_frame = nil) ⇒ Boolean

#

Bioroebe.n_stop_codons_in_this_sequence?

This method will return how many stop codons have been found in the passed sequence (the argument to this method), as an integer number, such as 4 or 6 or 0.

Note that by default, this method will NOT honour specific frames - so if you need a frame-aware method, such as frame1, frame2 or frame3, then you may have to use another method or check afterwards whether the stop codons can be in the correct frame. Or, an alterative, is to input a subsequence that already has the proper frame aligned with,

    1. if you drop the leading, or the first two, nucleotides, before

calling this method here.

The optional second argument for this method allows us to check only for a given frame, such as frame1, frame2 or frame3. frame1 specifies the default, as-is; frame2 means a shift of 1; frame3 means a shift of 2 (frame4 for a shift of +3 would again restore the original reading frame, so we can ignore all of these events that come past that, since the reading frame will remain the same).

By default this is turned off, though.

#

Returns:

  • (Boolean)


144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/bioroebe/codons/codons.rb', line 144

def self.n_stop_codons_in_this_sequence?(
    i                    = :default,
    check_for_this_frame = nil
  )
  if i.is_a? Array
    i = i.join(' ').strip
  end
  case i
  when :default, nil
    # i = 'ATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAG'
    i = 'ATGCCCGGGTGA'
  end
  n_stop_codons = 0
  if @stop_codons.empty?
    Bioroebe.set_use_this_codon_table(:default)
  end
  array_stop_codons = @stop_codons
  if check_for_this_frame
    # ===================================================================== #
    # Check for the corresponding frame.
    # ===================================================================== #
    case check_for_this_frame
    when :frame1
      i =        i.scan(/.../).select {|entry| array_stop_codons.include? entry }
    when :frame2
      i = i[1..-1].scan(/.../).select {|entry| array_stop_codons.include? entry }
    when :frame3
      i = i[2..-1].scan(/.../).select {|entry| array_stop_codons.include? entry }
    end
    n_stop_codons += i.size
  else
    # ===================================================================== #
    # If we do not have to care about frames then we can just do a direct
    # counting.
    # ===================================================================== #
    array_stop_codons.each {|this_stop_codon|
      scanned = i.scan(/#{this_stop_codon}/)
      n_stop_codons += scanned.size
    }
  end
  n_stop_codons
end

.n_transitions(string1 = 'ATGAAA', string2 = 'ATGCTG') ⇒ Object

#

Bioroebe.n_transitions

In genetics, a transition is a point mutation that changes a purine nucleotide to another purine (A ←→ G) or a pyrimidine nucleotide to another pyrimidine (C ←→ T).

The method Bioroebe.n_transitions will return an Integer value.

It expects two Strings as arguments.

Usage example:

Bioroebe.n_transitions('ATGAAAAACA', 'ATGCTGATGG') # => 2
#


4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4755

def self.n_transitions(
    string1 = 'ATGAAA',
    string2 = 'ATGCTG'
  )
  n_transitions = 0
  chars1 = string1.chars
  chars2 = string2.chars
  chars1.each_with_index {|char1, index|
    char2 = chars2[index]
    if char1 == char2
      # Equal, so it can not be a transition or transversion.
    elsif is_a_pyrimidine?(char1)
      # In this case it can be either a transition or a transversion.
      if is_a_pyrimidine?(char2)
        n_transitions += 1
      end
    elsif is_a_purine?(char1)
      if is_a_purine?(char2)
        n_transitions += 1
      end
    end
  }
  n_transitions
end

.n_transversions(string1 = 'ATGAAA', string2 = 'ATGCTG') ⇒ Object

#

Bioroebe.n_transversions

#


4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4714

def self.n_transversions(
    string1 = 'ATGAAA',
    string2 = 'ATGCTG'
  )
  n_transversions = 0
  chars1 = string1.chars
  chars2 = string2.chars
  chars1.each_with_index {|char1, index|
    char2 = chars2[index]
    if char1 == char2
      # Equal, so it can not be a transition or transversion.
    elsif is_a_pyrimidine?(char1)
      # In this case it can be either a transition or a transversion.
      if is_a_purine?(char2)
        n_transversions += 1
      end
    elsif is_a_purine?(char1)
      if is_a_pyrimidine?(char2)
        n_transversions += 1
      end
    end
  }
  n_transversions
end

.no_file_exists_at(i) ⇒ Object

#

Bioroebe.no_file_exists_at

#


1177
1178
1179
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1177

def self.no_file_exists_at(i)
  erev "No file exists at `#{sfile(i)}#{rev}`."
end

.nucleotide_permutations(level = 2, nucleotides = DNA_NUCLEOTIDES) ⇒ Object

#

Bioroebe.nucleotide_permutations

This method will try to permutate the given nucleotides, so that we get an Array that has e. g. “AA”, “AT”, “AG”, “AC”. So really all permutations possible.

The first argument to this method tells us how long we will run the algorithm at hand. A level of 2 means to show only permutations for two nucleotides and so forth. Unfortunately, this does not yet work with anything more than 2 for the time being.

Since as of August 2019, this method can also read from a local file - this was added to specifically solve a problem of the ROSALIND challenges. The task can be seen here: rosalind.info/problems/lexf/

Usage example:

Bioroebe.nucleotide_permutations
#


3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3537

def self.nucleotide_permutations(
    level       = 2,
    nucleotides = DNA_NUCLEOTIDES # => ["A", "T", "G", "C"]
  )
  # ======================================================================= #
  # Grab a reference to the possible nucleotides next.
  # ======================================================================= #
  _ = []
  if level and File.file?(level.to_s)
    dataset = File.read(level).strip
    splitted = dataset.split("\n")
    nucleotides = splitted.first.strip.split(' ')
    level = splitted.last
  end
  level = level.to_i # We need an Integer past this point.
  (level - 1).times {
    nucleotides.each {|entry|
      _ << nucleotides.map {|inner_entry| entry+inner_entry }
    }
  }
  return _.flatten.uniq.sort
end

.number_of_clones(average_size_of_the_dna_fragments = 10_000, size_of_the_genome = 4_693_221, desired_probability = 0.99) ⇒ Object

#

Bioroebe.number_of_clones

This method will “calculate” the number of clones required for an experiment that attempts to create a genomic library.

The general formula is:

N = ln (1 - P ) / ln (1 - a/b)

Where:

N is the number of clones required.
P is the desired probability.
a is the average size of the DNA fragments that are cloned.
b is the size of the genome at hand (in n bp).
#


3243
3244
3245
3246
3247
3248
3249
3250
3251
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3243

def self.number_of_clones(
    average_size_of_the_dna_fragments = 10_000,
    size_of_the_genome                = 4_693_221, # ← E. coli K12.
    desired_probability               = 0.99       # ← Or 0.95 (this is P)
  )
  n_clones = Math.log(1 - desired_probability) /
            (Math.log(1 - (average_size_of_the_dna_fragments.to_f / size_of_the_genome.to_f)))
  n_clones.round(0)
end

.one_to_three(i, use_this_as_join_token = '-') ⇒ Object

#

Bioroebe.one_to_three

This method will convert from the one-aminoacid letter to the three-letter code.

Usage example:

Bioroebe.one_to_three('HIM') # => "His-Ile-Met"
#


5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 5132

def self.one_to_three(
    i,
    use_this_as_join_token = '-' # Or it could be empty, for no-join token.
  )
  if i.is_a? Array
    i = i.join
  end
  inverted_hash = AMINO_ACIDS_THREE_TO_ONE.invert
  chars = i.chars
  result = chars.map {|one_aminoacid_letter|
    "#{inverted_hash[one_aminoacid_letter].capitalize}#{use_this_as_join_token}"
  }.join
  return result.chop
end

.only_nucleotides?(i) ⇒ Boolean

#

Bioroebe.only_nucleotides?

This filter-method will return true or false depending on whether we have only valid nucleotides as part of the given input to this method.

In order for this to work, we will tap into the constant called HASH_DNA_NUCLEOTIDES. Note that, despite the name, we also include RNA there.

Usage examples:

Bioroebe.only_nucleotides? 'ATGCG'  # => true
Bioroebe.only_nucleotides? 'ATGCGi' # => false
#

Returns:

  • (Boolean)


3604
3605
3606
3607
3608
3609
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3604

def self.only_nucleotides?(i)
  i = i.join.strip if i.is_a? Array
  allowed_keys = HASH_DNA_NUCLEOTIDES.keys
  chars = i.chars
  chars.all? {|entry| allowed_keys.include? entry }
end

.open_in_browser(this_url, use_this_browser = :use_the_default_browser) ⇒ Object

#

Bioroebe.open_in_browser

This method will try to open a remote URL in the specified browser - the one that has been noted down in ‘browser.yml’. It is accessed via the Symbol :use_the_default_browser (as second argument to this method).

If you wish to make use of another browser then you can also pass in the location to the browser as the second argument tp this method.

Usage example:

Bioroebe.open_in_browser('derstandard.at')
#


699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 699

def self.open_in_browser(
    this_url,
    use_this_browser = :use_the_default_browser
  )
  if this_url.is_a? Array
    this_url.each {|entry|
      open_in_browser(entry, use_this_browser)
    }
  else
    case use_this_browser # case tag
    # ===================================================================== #
    # === :default
    # ===================================================================== #
    when :default,
         :use_the_default_browser
      # =================================================================== #
      # Sanitize the default setting here, by loading up the content of
      # the proper yaml file.
      # =================================================================== #
      use_this_browser =
        YAML.load_file(FILE_BROWSER)
    end
    this_url = ::Bioroebe.try_to_pass_through_beautiful_url(this_url)
    esystem "#{use_this_browser.strip} -new-tab #{this_url}"
  end
end

.open_reading_frames_to_aminoacid_sequence(i = 'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGA'\ 'TTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG') ⇒ Object

#

Bioroebe.open_reading_frames_to_aminoacid_sequence

This method is similar to Bioroebe.open_reading_frames(), but it will additionally convert to the corresponding aminoacids at once.

This method will return a String as a result.

Usage example:

x = Bioroebe.open_reading_frames_to_aminoacid_sequence('AAAATGGGCCCATGA') # => ["MGP"]
#


1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1580

def self.open_reading_frames_to_aminoacid_sequence(
    i = 'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGA'\
        'TTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG'
  )
  all_aminoacids = ::Bioroebe.open_reading_frames(i).map {|nucleotide_sequence|
    ::Bioroebe.to_aa(nucleotide_sequence)
  }
  if all_aminoacids
    all_aminoacids = all_aminoacids.first
  end
  return all_aminoacids
end

.overwrite_fasta_header(of_this_file = ARGV, &block) ⇒ Object

#

Bioroebe.overwrite_fasta_header

Usage example:

overwritefastaheader YP_003540719.1_cytochrome_b_mitochondrion_Columba_livia.fasta
#


93
94
95
96
97
98
99
100
101
# File 'lib/bioroebe/fasta_and_fastq/simplify_fasta_header/simplify_fasta_header.rb', line 93

def self.overwrite_fasta_header(
    of_this_file = ARGV,
    &block
  )
  of_this_file = [of_this_file].flatten.compact # Ensure that we have an Array here.
  of_this_file << ['--overwrite']
  of_this_file.flatten!
  Bioroebe::SimplifyFastaHeader.new(of_this_file, &block)
end

.palindrome_generator(i = 6) ⇒ Object

#

Bioroebe.palindrome_generator

Usage example:

puts Bioroebe.palindrome_generator(10)
#


255
256
257
# File 'lib/bioroebe/palindromes/palindrome_generator.rb', line 255

def self.palindrome_generator(i = 6)
  ::Bioroebe::PalindromeGenerator.new(i).result?
end

.parse(i = ARGV) ⇒ Object

#

Bioroebe.parse

This is a general parse-related method.

The main idea for this method is to parse files in particular, in a simplified manner. That means, for example, if the input to this method is a genbank file, then this method will simply return the sequence. If it is a .pdb file, same thing. A .fasta file, same result - the content will be returned. Thus, this method attempts to make it simpler to parse a wide array of different file formats - simply feed it what you want and you get the “most logical” output.

Usage example:

Bioroebe.parse('/home/x/programming/ruby/src/bioroebe/lib/bioroebe/data/genbank/sample_file.genbank')
#


1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1291

def self.parse(
    i = ARGV
  )
  if i.is_a? Array
    i = i.first
  end
  if i
    case i
    # ===================================================================== #
    # === .genbank
    # ===================================================================== #
    when /\.genbank$/i
      require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb' 
      i = Bioroebe.genbank_to_fasta(i, :be_quiet)
    # ===================================================================== #
    # === .pdb
    # ===================================================================== #
    when /\.pdb$/i
      require 'bioroebe/pdb/parse_pdb_file.rb'
      i = Bioroebe.return_aminoacid_sequence_from_this_pdb_file(i)
    # ===================================================================== #
    # === .fasta
    # ===================================================================== #
    when /\.fasta$/i,
         /\.fa$/i
      require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
      i = Bioroebe::ParseFasta.new(i) { :be_quiet }.sequence?
    end
    return i
  end
end

.parse_fasta(i, use_colours = true) ⇒ Object

#

Bioroebe.parse_fasta

Easier reader-method for .fasta files.

The second argument determines whether we will use colours or whether we will not. For now, the default is to not use colours when we use this particular class method.

Invocation examples:

x = Bioroebe.parse_fasta('/rosalind_gc.txt')
hash = Bioroebe.parse_fasta('/rosalind_gc.txt').hash?
#


1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
# File 'lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb', line 1508

def self.parse_fasta(
    i,
    use_colours = true
  )
  use_this_hash = {
    use_colours: use_colours
  }
  if block_given?
    use_this_hash = {
      use_colours: use_colours,
      be_verbose:  yield
    }
  end
  ::Bioroebe::ParseFasta.new(i) { use_this_hash }
end

.parse_fasta_file(i = ARGV, use_colours = true) ⇒ Object

#

Bioroebe.parse_fasta_file

#


1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
# File 'lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb', line 1482

def self.parse_fasta_file(
    i           = ARGV,
    use_colours = true
  )
  use_this_hash = {
    use_colours: use_colours,
    be_verbose:  false
  }
  ParseFasta.new(i) { use_this_hash }
end

.parse_fasta_quietly(i, use_colours = true) ⇒ Object

#

Bioroebe.parse_fasta_quietly

As the variant above, but will work quietly.

#


1382
1383
1384
1385
1386
# File 'lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb', line 1382

def self.parse_fasta_quietly(
    i, use_colours = true
  )
  ::Bioroebe.parse_fasta(i, use_colours) { :be_quiet }
end

.parse_pdb_file(i = ARGV) ⇒ Object

#

Bioroebe.parse_pdb_file

#


1043
1044
1045
# File 'lib/bioroebe/pdb_and_protein_structure/parse_pdb_file.rb', line 1043

def self.parse_pdb_file(i = ARGV)
  Bioroebe::ParsePdbFile.new(i)
end

.parse_this_prosite_pattern(i = '[GSTNE]-[GSTQCR]-[FYW]-{ANW}-x(2)-P') ⇒ Object

#

Bioroebe.parse_this_prosite_pattern

Usage example:

Bioroebe.parse_this_prosite_pattern('[GSTNE]-[GSTQCR]-[FYW]-{ANW}-x(2)-P') # => "EGFIWQP"
#


1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1778

def self.parse_this_prosite_pattern(
    i = '[GSTNE]-[GSTQCR]-[FYW]-{ANW}-x(2)-P'
  )
  i = i.first if i.is_a? Array
  if i.include? '-'
    splitted = i.split('-')
    return splitted.map {|entry|
      return_random_aminoacid_from_this_prosite_pattern(entry)
    }.join
  end
end

.partner_nucleotide(i) ⇒ Object

#

Bioroebe.partner_nucleotide

This small “table” will simply return the corresponding Nucleotide matching the given input at hand - in other words, the corresponding DNA nucleotide that can base-pair with the input nucleotide.

Since this is a method call this may be a bit slow if you have to invoke the method repeatedly. In this case, you should consider using the method befined below, through the method Bioroebe.partner_nucleotide_hash(), and then use that Hash instead.

Usage example:

Bioroebe.partner_nucleotide('A') # => "T"
Bioroebe.should_match_to?('T') # => "A"
#


499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 499

def self.partner_nucleotide(i)
  i = i.first if i.is_a? Array # We only handle the first entry in an Array.
  if i
    i = i.dup if i.frozen?
    i.upcase! # just in caase.
    case i # case tag.
    when 'A'
      return 'T'
    when 'T','U'
      return 'A'
    when 'G'
      return 'C'
    when 'C'
      return 'G'
    else
      return nil # means illegal value.
    end
  end
  return i # Return just in case.
end

.partner_nucleotide_hashObject

#

Bioroebe.partner_nucleotide_hash

This method will return a Hash, which should be faster for lookup.

#


3511
3512
3513
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3511

def self.partner_nucleotide_hash
  HASH_DNA_NUCLEOTIDES
end

.pathwaysObject

#

Bioroebe.pathways

#


145
146
147
# File 'lib/bioroebe/utility_scripts/pathways/pathways.rb', line 145

def self.pathways
  Bioroebe::Pathways.show_all_pathways
end

.pdb_directory?Boolean

#

Bioroebe.pdb_directory?

This refers to the local pdb/ directory.

#

Returns:

  • (Boolean)


4455
4456
4457
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4455

def self.pdb_directory?
  return "#{log_dir?}pdb/"
end

.percentage_count_non_DNA_bases_in_this_sequence(i, array = Bioroebe.return_DNA_nucleotides) ⇒ Object

#

Bioroebe.percentage_count_non_DNA_bases_in_this_sequence

Usage examples:

Bioroebe.percentage_count_non_DNA_bases_in_this_sequence('ATCGF')
Bioroebe.percentage_count_non_DNA_bases_in_this_sequence('ACTNGTGCTYGATRGTAGC', %w( A T G C Y R ))
#


3005
3006
3007
3008
3009
3010
3011
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3005

def self.percentage_count_non_DNA_bases_in_this_sequence(
    i, array = Bioroebe.return_DNA_nucleotides
  )
  n = count_non_DNA_bases_in_this_sequence(i, array)
  percentage = (n * 100.0 / i.size.to_f)
  return percentage
end

.permanently_disable_opnObject

#

Bioroebe.permanently_disable_opn

The purpose of this method is to permanently disable opn for the whole Bioroebe-project.

#


423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 423

def self.permanently_disable_opn
  require 'bioroebe/project/project.rb'
  require 'bioroebe/colours/colours.rb'
  erev 'Permanently disabling the use of opn for the Bioroebe project next.'
  target_dir = CONFIGURATION_DIRECTORY
  target_file = "#{target_dir}use_opn.yml"
  if File.exist? target_file
    erev 'Modifying the file `'+
         sfile(target_file)+rev+'` next.'
    write_what_into('false', target_file)
  end
end

.permutations(i) ⇒ Object

#

Bioroebe.permutations

You can also pass in the location to a local file as the first argument to this method.

Invocation example:

Bioroebe.permutations 7
#


156
157
158
159
160
161
162
163
164
165
# File 'lib/bioroebe/utility_scripts/permutations/permutations.rb', line 156

def self.permutations(i)
  if i.is_a? Array
    i.each {|entry| permutations(entry) }
  else
    if i and File.file?(i)
      i = File.read(i).strip
    end
    ::Bioroebe::Permutations.new(i)
  end
end

.phred_error_probability(quality_score = 50, optional_use_this_formatting = nil) ⇒ Object

#

Bioroebe.phred_error_probability

Datasets obtained from next-generation reads specify a Phred score for each base. This is also known as the “Q score” (Quality score).

The Q score is an integer value, and is typically within the range 2 to 40. Q indicates the probability that the base call is incorrect (P_e).

For example, Q=2 means that the error probability is 63%, so the machine is reporting that the base is more likely to be wrong than right, while Q=20 corresponds to an error probability of only 1%.

The second argument to this method can be used to format to a specific number. So if we pass in 6 as the second argument then the result will be rounded to 6 slots after the first ‘.’. See the usage examples below.

Usage examples:

Bioroebe.phred_error_probability '48'
Bioroebe.phred_error_probability '48',6 # => "0.000016"
#


997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 997

def self.phred_error_probability(
    quality_score                = 50,
    optional_use_this_formatting = nil
  )
  if quality_score.is_a? Array
    quality_score = quality_score.first
  end
  quality_score = quality_score.to_f # Need a Float past this point.
  result = 10 ** (- quality_score / 10.0)
  # ======================================================================= #
  # Next, do some rounding if the user requested this through the
  # second argument to this method.
  # ======================================================================= #
  if optional_use_this_formatting
    if optional_use_this_formatting.is_a? Numeric
      use_this_formatting_rule = "%.#{optional_use_this_formatting}f"
      result = use_this_formatting_rule % result
    else
      result = optional_use_this_formatting.to_s % result
    end
  end
  return result
end

.plain_palindrome(i) ⇒ Object

#

Bioroebe.plain_palindrome

This method is simply than Bioroebe.is_palindrome?. It will simply check for the current sequence.

Usage example:

Bioroebe.plain_palindrome('OTTO') # => true
Bioroebe.plain_palindrome('Saippuakivikauppias') # => true
#


4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4852

def self.plain_palindrome(i)
  if i.is_a? Array
    i = i.join(' ').strip
  end
  i = i.dup.downcase
  if i.size.even?
    first_half  = i[0 .. (i.size / 2 - 1)]
    second_half = i[(i.size / 2) .. -1]
    return (first_half == second_half.reverse)
  else # This is for odd numbers.
    first_half  = i[0 .. (i.size / 2 - 1)]
    second_half = i[(i.size / 2 + 1) .. -1]
    return (first_half == second_half.reverse)
  end
end

.possible_codons_for_these_aminoacids(i = ARGV) ⇒ Object

#

Bioroebe.possible_codons_for_these_aminoacids

This variant is similar to Bioroebe.possible_codons_for_this_aminoacid, but the main use case is to specifically return an Array of ALL codons for a given aminoacid sequence.

Usage example:

Bioroebe.possible_codons_for_these_aminoacids('KLKKMNRRTS') # => [["AAG", "AAA"], ["TTA", "TTG", "CTT", "CTC", "CTA", "CTG"], # and so forth
#


352
353
354
355
356
357
358
359
360
# File 'lib/bioroebe/codons/possible_codons_for_this_aminoacid.rb', line 352

def self.possible_codons_for_these_aminoacids(i = ARGV)
  if i.is_a? String
    i = i.split(//)
  end
  i = [i].flatten.compact
  return i.map {|entry|
    ::Bioroebe.possible_codons_for_this_aminoacid(entry)
  }
end

.possible_codons_for_this_aminoacid(i = ARGV) ⇒ Object

#

Bioroebe.possible_codons_for_this_aminoacid

Usage example:

Bioroebe.possible_codons_for_this_aminoacid('A') # => ["GCT", "GCC", "GCA", "GCG"]
Bioroebe.aminoacid_to_possible_codons('R')       # => ["CGT", "CGC", "CGA", "CGG", "AGA", "AGG"]
Bioroebe.possible_codons_for_this_aminoacid('M') # => ["ATR"]
#


331
332
333
334
335
336
# File 'lib/bioroebe/codons/possible_codons_for_this_aminoacid.rb', line 331

def self.possible_codons_for_this_aminoacid(i = ARGV)
  possible_codons_for_this_aminoacid = ::Bioroebe::PossibleCodonsForThisAminoacid.new(
    i
  ) { :do_not_simplify_purines_and_pyrimidines }
  return possible_codons_for_this_aminoacid.array_as_result
end

.project_base_dir?Boolean

#

Bioroebe.project_base_dir?

This method will return the value of @project_base_directory - that is where the files that belong to Bioroebe are assumed to reside.

#

Returns:

  • (Boolean)


50
51
52
# File 'lib/bioroebe/project/project.rb', line 50

def self.project_base_dir?
  @project_base_directory
end

.project_yaml_directory?(i = @project_base_directory) ⇒ Boolean

#

Bioroebe.project_yaml_directory?

This method will return the path to the yaml-directory of the bioroebe project. It will be a dynamic result rather than make use of the above constant.

#

Returns:

  • (Boolean)


63
64
65
66
67
68
69
70
71
72
73
# File 'lib/bioroebe/project/project.rb', line 63

def self.project_yaml_directory?(i = @project_base_directory)
  # ========================================================================= #
  # The following code allows us to default to the HOME directory of the
  # user.
  # ========================================================================= #
  use_this_as_the_project_base_directory = i
  unless File.directory? use_this_as_the_project_base_directory
    use_this_as_the_project_base_directory = File.expand_path('~')
  end
  return "#{use_this_as_the_project_base_directory}yaml/"
end

.pwdObject

#

Bioroebe.pwd (pwd tag)

Feedback the current working directory (it will be returned, as a String).

#


1103
1104
1105
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1103

def self.pwd
  "#{Dir.pwd}/".squeeze('/')
end

.quaternary_encoding_DNA_to_numbers(i = 'TACATCTTTCGATCGATCGG', hash = { A: 0, T: 1, C: 2, G: 3 }) ⇒ Object

#

Bioroebe.quaternary_encoding_DNA_to_numbers

You can pass in another hash as the second argument to this method, if you’d like to.

Usage example:

Bioroebe.quaternary_encoding_DNA_to_numbers('TACATCTTTCGATCGATCGG') # => "10201211123012301233"
#


2539
2540
2541
2542
2543
2544
2545
2546
2547
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2539

def self.quaternary_encoding_DNA_to_numbers(
    i    = 'TACATCTTTCGATCGATCGG',
    hash = { A: 0, T: 1, C: 2, G: 3 }
  )
  i = i.chars unless i.is_a? Array
  return i.map {|entry|
    hash[entry.to_sym]
  }.join
end

.quaternary_encoding_letter_to_number(letter, use_this_hash = { '0000': :A, '1000': :B, '2000': :C, '3000': :D, '0100': :E, '0200': :F, '0300': :G, '0010': :H, '0020': :I, '0030': :J, '0001': :K, '0002': :L, '0003': :M, '1100': :N, '1200': :O, '1300': :P, '1110': :Q, '1120': :R, '1130': :S, '1210': :T, '1220': :U, '1230': :V, '1231': :W }) ⇒ Object

#

Bioroebe.quaternary_encoding_letter_to_number

#


2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2677

def self.quaternary_encoding_letter_to_number(
  letter,
  use_this_hash = {
    '0000': :A,
    '1000': :B,
    '2000': :C,
    '3000': :D,
    '0100': :E,
    '0200': :F,
    '0300': :G,
    '0010': :H,
    '0020': :I,
    '0030': :J,
    '0001': :K,
    '0002': :L,
    '0003': :M,
    '1100': :N,
    '1200': :O,
    '1300': :P,
    '1110': :Q,
    '1120': :R,
    '1130': :S,
    '1210': :T,
    '1220': :U,
    '1230': :V,
    '1231': :W
  })
  use_this_hash = use_this_hash.invert
  return use_this_hash[letter.to_sym].to_s
end

.quaternary_encoding_number_to_letter(number, use_this_hash = { '0000': :A, '1000': :B, '2000': :C, '3000': :D, '0100': :E, '0200': :F, '0300': :G, '0010': :H, '0020': :I, '0030': :J, '0001': :K, '0002': :L, '0003': :M, '1100': :N, '1200': :O, '1300': :P, '1110': :Q, '1120': :R, '1130': :S, '1210': :T, '1220': :U, '1230': :V, '1231': :W }) ⇒ Object

#

Bioroebe.quaternary_encoding_number_to_letter

#


2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2711

def self.quaternary_encoding_number_to_letter(
  number,
  use_this_hash = {
    '0000': :A,
    '1000': :B,
    '2000': :C,
    '3000': :D,
    '0100': :E,
    '0200': :F,
    '0300': :G,
    '0010': :H,
    '0020': :I,
    '0030': :J,
    '0001': :K,
    '0002': :L,
    '0003': :M,
    '1100': :N,
    '1200': :O,
    '1300': :P,
    '1110': :Q,
    '1120': :R,
    '1130': :S,
    '1210': :T,
    '1220': :U,
    '1230': :V,
    '1231': :W
  })
  return use_this_hash[number.to_s].to_s
end

.quaternary_encoding_numbers_to_DNA(i = '10201211123012301233', hash = { A: 0, T: 1, C: 2, G: 3 }) ⇒ Object

#

Bioroebe.quaternary_encoding_numbers_to_DNA

#


2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2744

def self.quaternary_encoding_numbers_to_DNA(
    i    = '10201211123012301233',
    hash = { A: 0, T: 1, C: 2, G: 3 }
  )
  i = i.chars unless i.is_a? Array
  inverted_hash = hash.invert
  return i.map {|number|
    inverted_hash[number.to_i]
  }.join
end

.quaternary_encoding_translate_from_alphabet_string_into_the_corresponding_DNA_sequence(this_string = 'Hello world') ⇒ Object

#

Bioroebe.quaternary_encoding_translate_from_alphabet_string_into_the_corresponding_DNA_sequence

Usage example:

Bioroebe.quaternary_encoding_translate_from_alphabet_string_into_the_corresponding_DNA_sequence('OTTO')
#


1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1029

def self.quaternary_encoding_translate_from_alphabet_string_into_the_corresponding_DNA_sequence(
    this_string = 'Hello world'
  )
  _ = ''.dup
  chars = this_string.chars
  chars.each {|this_char|
    case chars
    when ' ','!','?'
      # pass through in this case.
    else
      this_char = this_char.upcase
      _ << Bioroebe.quaternary_encoding_letter_to_number(this_char)
    end
  }
  return _
end

.random_aminoacid?(optional_return_n_aminoacids = 1) ⇒ Boolean

#

Bioroebe.random_aminoacid?

This method will return a random aminoacid.

A number can be passed to this method, which specifies how many random aminoacids are to be returned, e. g. 20 as argument refers to 20 aminoacids that will be generated here.

Usage example:

Bioroebe.random_aminoacid? 20 # => "UAVHYQQESWUYAOVESEIY"
#

Returns:

  • (Boolean)


1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
# File 'lib/bioroebe/constants/constants.rb', line 1094

def self.random_aminoacid?(optional_return_n_aminoacids = 1)
  case optional_return_n_aminoacids
  when 1
    AMINO_ACIDS.keys.sample # This should be a bit faster.
  else
    optional_return_n_aminoacids.to_i.times.map {
      AMINO_ACIDS.keys.sample
    }.join.strip
  end
end

.rds(i) ⇒ Object

#

Bioroebe.rds

rds is an abbreviation and is short for “remove double slashes”.

We will thus get rid of too many ‘/’ tokens in a given string, via this method.

This is mostly used in order to sanitize local file paths, as “foo//bar” entries look quite ugly.

#


382
383
384
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 382

def self.rds(i)
  i.squeeze('/')
end

.readline_is_available?Boolean

#

Bioroebe.readline_is_available?

Check whether readline is available.

#

Returns:

  • (Boolean)


26
27
28
# File 'lib/bioroebe/readline/readline.rb', line 26

def self.readline_is_available?
  @readline_is_available
end

.regex_with_startcodons(use_this_start_codon = ::Bioroebe.start_codon?) ⇒ Object

#

Bioroebe.regex_with_startcodons

This toplevel-method will return the regex for a start codon.

Usually this means that we will return /ATG|AUG/ so we also match towards the mRNA variant. It was created precisely because the user may often wish to identify any start codon, no matter if it is kept in RNA or in DNA.

#


19
20
21
22
23
24
25
26
27
# File 'lib/bioroebe/regexes/regexes.rb', line 19

def self.regex_with_startcodons(
    use_this_start_codon = ::Bioroebe.start_codon?
  )
  require 'bioroebe/codons/start_codons.rb'
  start_codon_as_mRNA = use_this_start_codon.
                        tr('T','U') 
  regex = /(#{use_this_start_codon}|#{start_codon_as_mRNA})/i
  return regex # Return the regex here.
end

.remove_file(i, be_verbose = false) ⇒ Object

#

Bioroebe.remove_file

Use this method to remove a file.

#


4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4166

def self.remove_file(
    i,
    be_verbose = false
  )
  if File.exist? i
    File.delete(i)
    if be_verbose
      this_file = "#{return_pwd}#{i}"
      e 'File '+sfile(this_file)+' exists, '\
        'we will thus remove it now.'
    end
  end
end

.remove_invalid_aminoacids(from_this_string) ⇒ Object

#

Bioroebe.remove_invalid_aminoacids

This method will filter away invalid aminoacids such as “U”. “U” is not a valid aminoacid. It requires the data stored in the yaml file at:

"/home/Programs/Ruby/3.1.2/lib/ruby/site_ruby/3.1.0/bioroebe/yaml/aminoacids/amino_acids.yml"

Note that U is a valid aminoacid - it is selenocysteine.

Usage example:

Bioroebe.remove_invalid_aminoacids('LKLSUSURZZZ')
#


1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1669

def self.remove_invalid_aminoacids(
    from_this_string
  )
  if from_this_string.is_a? Array
    from_this_string = from_this_string.first
  end
  all_valid_aminoacids = YAML.load_file(Bioroebe.file_amino_acids).keys
  new_result = ''.dup
  from_this_string.chars.each {|entry|
    new_result << entry if all_valid_aminoacids.include?(entry)
  }
  return new_result
end

.remove_numbers(i = ARGV) ⇒ Object

#

Bioroebe.remove_numbers

This method will simply remove numbers from the given input at hand.

Usage example:

Bioroebe.remove_numbers("abc123def")
#


788
789
790
791
792
793
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 788

def self.remove_numbers(i = ARGV)
  if i.is_a? Array
    i = i.join
  end
  i.gsub(/[0-9]/,'')
end

.remove_subsequence(subsequence, from) ⇒ Object

#

Bioroebe.remove_subsequence

This method will remove one or more subsequences from a given String at hand. The String that you wish to modify, should be given as the second argument to this method, called ‘from`.

The first argument to this method can be an Array or a String - in either case, if the variable ‘from` contains this sequence, it will be removed.

Note that only the FIRST occurence found will be removed - the others will be ignored, if they exist.

The second argument to this method must be a String.

Usage example:

Bioroebe.remove_subsequence(["ATCGGTCGAA", "ATCGGTCGAGCGTGT"], 'ATGGTCTACATAGCTGACAAACAGCACGTAGCAATCGGTCGAATCTCGAGAGGCATATGGTCACATGATCGGTCGAGCGTGTTTCAAAGTTTGCGCCTAG')
Bioroebe.remove_subsequence(array, main_sequence)
#


842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 842

def self.remove_subsequence(
    subsequence,
    from # ← Must be a String.
  )
  unless from.is_a? String
    raise 'Please input a String as second argument to this method.'
  end
  unless subsequence.is_a? Array
    subsequence = [subsequence].flatten
  end
  from = from.dup if from.frozen?
  subsequence.each {|this_subsequence|
    from.sub!(/#{this_subsequence}/,'')
  }
  from # Return the, possibly modified, String here.
end

.report_base_composition(i = '52%GC') ⇒ Object

#

Bioroebe.report_base_composition

This is the convenience-method for reporting the base composition at hand.

#


4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4012

def self.report_base_composition(
    i = '52%GC'
  )
  if i.is_a? Array
    if i.empty?
      i = '52%GC' # Default value.
    else
      i = i.join(' ').strip
    end
  end
  hash = ::Bioroebe.base_composition(i)
  a = hash['A']
  t = hash['T']
  c = hash['C']
  g = hash['G']
  erev 'The base composition frequencies of this sequence '\
       '(length: '+i.size.to_s+') is as follows:'
  e
  e '  '\
    ' A: '+steelblue(a.to_s+'%')+rev+
    ' T: '+steelblue(t.to_s+'%')+rev+
    ' C: '+steelblue(c.to_s+'%')+rev+
    ' G: '+steelblue(g.to_s+'%')+rev
  e
end

.require_all_aminoacids_files(from_this_dir = AMINOACIDS_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_aminoacids_files

Use this to require all aminoacids.

#


16
17
18
19
20
21
22
23
24
# File 'lib/bioroebe/requires/require_all_aminoacids_files.rb', line 16

def self.require_all_aminoacids_files(
    from_this_dir = AMINOACIDS_DIRECTORY
  )
  _ = Dir["#{from_this_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/aminoacids/#{File.basename(file)}"
    require file
  }
end

.require_all_calculate_filesObject

#

Bioroebe.require_all_calculate_files

Use this to require all files in the calculate/ directory.

#


16
17
18
19
20
21
22
# File 'lib/bioroebe/requires/require_all_calculate_files.rb', line 16

def self.require_all_calculate_files
  _ = Dir["#{CALCULATE_DIRECTORY}*.rb"]
  _.each {|file|
    file = "bioroebe/calculate/#{File.basename(file)}"
    require file
  }
end

.require_all_cleave_and_digest_files(i = CLEAVE_AND_DIGEST_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_cleave_and_digest_files

#


14
15
16
17
18
19
20
21
22
# File 'lib/bioroebe/requires/require_cleave_and_digest.rb', line 14

def self.require_all_cleave_and_digest_files(
    i = CLEAVE_AND_DIGEST_DIRECTORY
  )
  _ = Dir["#{i}*.rb"]
  _.each {|file|
    file = "bioroebe/cleave_and_digest/#{File.basename(file)}"
    require file
  }
end

.require_all_codon_filesObject

#

Bioroebe.require_all_codon_files

Use this to require all codon/ files.

#


16
17
18
19
20
21
22
# File 'lib/bioroebe/requires/require_all_codon_files.rb', line 16

def self.require_all_codon_files
  _ = Dir["#{CODONS_DIRECTORY}*.rb"]
  _.each {|file|
    file = "bioroebe/codons/#{File.basename(file)}"
    require file
  }
end

.require_all_count_filesObject

#

Bioroebe.require_all_count_files

Use this to require all count/ files.

#


16
17
18
19
20
21
22
# File 'lib/bioroebe/requires/require_all_count_files.rb', line 16

def self.require_all_count_files
  _ = Dir["#{COUNT_DIRECTORY}*.rb"]
  _.each {|file|
    file = "bioroebe/count/#{File.basename(file)}"
    require file
  }
end

.require_all_dotplot_files(i = DOTPLOTS_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_dotplot_files

Use this to require all dotplot/ files.

#


16
17
18
19
20
21
22
23
24
# File 'lib/bioroebe/requires/require_all_dotplot_files.rb', line 16

def self.require_all_dotplot_files(
    i = DOTPLOTS_DIRECTORY
  )
  _ = Dir["#{i}*.rb"]
  _.each {|file|
    file = "bioroebe/dotplots/#{File.basename(file)}"
    require file
  }
end

.require_all_electron_microscopy_files(from_this_dir = ELECTRON_MICROSCOPY_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_electron_microscopy_files

#


14
15
16
17
18
19
20
21
22
# File 'lib/bioroebe/requires/require_all_electron_microscopy_files.rb', line 14

def self.require_all_electron_microscopy_files(
    from_this_dir = ELECTRON_MICROSCOPY_DIRECTORY
  ) 
  _ = Dir["#{from_this_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/electron_microscopy/#{File.basename(file)}"
    require file
  }
end

.require_all_enzymes_files(from_this_dir = ENZYMES_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_enzymes_files

Use this to require all enzymes/ files.

#


16
17
18
19
20
21
22
23
24
# File 'lib/bioroebe/requires/require_all_enzymes_files.rb', line 16

def self.require_all_enzymes_files(
    from_this_dir = ENZYMES_DIRECTORY
  ) 
  _ = Dir["#{from_this_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/enzymes/#{File.basename(file)}"
    require file
  }
end

.require_all_fasta_and_fastq_filesObject

#

Bioroebe.require_all_fasta_and_fastq_files

Use this to require all fasta and fastq files.

#


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bioroebe/requires/require_all_fasta_and_fastq_files.rb', line 16

def self.require_all_fasta_and_fastq_files
  _ = Dir["#{FASTA_AND_FASTQ_DIRECTORY}*.rb"]
  _.each {|file|
    file = "bioroebe/fasta_and_fastq/#{File.basename(file)}"
    require file
  }
  # ======================================================================= #
  # Next, add other fasta-related files residing elsewhere.
  # ======================================================================= #
  require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
  require 'bioroebe/fasta_and_fastq/parse_fastq/parse_fastq.rb'
  require 'bioroebe/fasta_and_fastq/compact_fasta_file/compact_fasta_file.rb'
end

.require_all_nucleotides_files(from_this_dir = NUCLEOTIDES_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_nucleotides_files

Use this to require all nucleotides/ files.

#


16
17
18
19
20
21
22
23
24
# File 'lib/bioroebe/requires/require_all_nucleotides_files.rb', line 16

def self.require_all_nucleotides_files(
    from_this_dir = NUCLEOTIDES_DIRECTORY
  ) 
  _ = Dir["#{from_this_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/nucleotides/#{File.basename(file)}"
    require file
  }
end

.require_all_palindromes_files(from_this_dir = PALINDROMES_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_palindromes_files

Use this method in order to require all palindromes/ files.

#


16
17
18
19
20
21
22
23
24
25
# File 'lib/bioroebe/requires/require_all_palindromes_files.rb', line 16

def self.require_all_palindromes_files(
    from_this_dir = PALINDROMES_DIRECTORY
  ) 
  _ = Dir["#{from_this_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/palindromes/#{File.basename(file)}"

    require file
  }
end

.require_all_parser_files(i = PARSERS_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_parser_files

Use this to require all parsers/ files.

#


16
17
18
19
20
21
22
23
24
# File 'lib/bioroebe/requires/require_all_parser_files.rb', line 16

def self.require_all_parser_files(
    i = PARSERS_DIRECTORY
  ) 
  _ = Dir["#{i}*.rb"]
  _.each {|file|
    file = "bioroebe/parsers/#{File.basename(file)}"
    require file
  }
end

.require_all_pattern_files(from_this_dir = PATTERN_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_pattern_files

Use this method in order to require all pattern/ files.

#


16
17
18
19
20
21
22
23
24
25
# File 'lib/bioroebe/requires/require_all_pattern_files.rb', line 16

def self.require_all_pattern_files(
    from_this_dir = PATTERN_DIRECTORY
  ) 
  _ = Dir["#{from_this_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/pattern/#{File.basename(file)}"

    require file
  }
end

.require_all_pdb_files(pdb_dir = PDB_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_pdb_files

#


14
15
16
17
18
19
20
21
22
# File 'lib/bioroebe/requires/require_all_pdb_files.rb', line 14

def self.require_all_pdb_files(
    pdb_dir = PDB_DIRECTORY
  )
  _ = Dir["#{pdb_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/pdb_and_protein_structure/#{File.basename(file)}"
    require file
  }
end

.require_all_sequence_files(i = SEQUENCE_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_sequence_files

#


14
15
16
17
18
19
20
21
22
# File 'lib/bioroebe/requires/require_all_sequence_files.rb', line 14

def self.require_all_sequence_files(
    i = SEQUENCE_DIRECTORY
  )
  _ = Dir["#{i}*.rb"]
  _.each {|file|
    file = "bioroebe/sequence/#{File.basename(file)}"
    require file
  }
end

.require_all_string_matching_files(string_matching_dir = STRING_MATCHING_DIRECTORY) ⇒ Object

#

Bioroebe.require_all_string_matching_files

Use this to require all string_matching files.

#


16
17
18
19
20
21
22
23
24
# File 'lib/bioroebe/requires/require_all_string_matching_files.rb', line 16

def self.require_all_string_matching_files(
    string_matching_dir = STRING_MATCHING_DIRECTORY
  )
  _ = Dir["#{string_matching_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/string_matching/#{File.basename(file)}"
    require file
  }
end

.require_all_taxonomy_files(target = taxonomy_directory? ) ⇒ Object

#

Bioroebe.require_all_taxonomy_files

#


23
24
25
26
27
28
29
30
31
# File 'lib/bioroebe/requires/require_all_taxonomy_files.rb', line 23

def self.require_all_taxonomy_files(
    target = taxonomy_directory?
  )
  _ = Dir["#{target}*.rb"]
  _.each {|file|
    file = "bioroebe/taxonomy/#{File.basename(file)}"
    require file
  }
end

.require_all_utility_scripts_files(this_dir = "#{project_base_dir?}utility_scripts/") ⇒ Object

#

Bioroebe.require_all_utility_scripts_files

Use this to require all utility_scripts.

#


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bioroebe/requires/require_all_utility_scripts_files.rb', line 16

def self.require_all_utility_scripts_files(
    this_dir = "#{project_base_dir?}utility_scripts/"
  )
  _ = Dir["#{this_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/utility_scripts/#{File.basename(file)}"
    require file
  }
  require 'bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb'
  require 'bioroebe/utility_scripts/compseq/compseq.rb'
  require 'bioroebe/utility_scripts/showorf/showorf.rb'
  require 'bioroebe/utility_scripts/display_open_reading_frames/display_open_reading_frames.rb'
  require 'bioroebe/utility_scripts/pathways/pathways.rb'
  require 'bioroebe/utility_scripts/download_files_from_rebase/download_files_from_rebase.rb'
  require 'bioroebe/utility_scripts/punnet/punnet.rb'
  require 'bioroebe/utility_scripts/permutations/permutations.rb'
  require 'bioroebe/utility_scripts/mirror_repeat/mirror_repeat.rb'
  require 'bioroebe/utility_scripts/parse_taxonomy/parse_taxonomy.rb'
  require 'bioroebe/utility_scripts/consensus_sequence/consensus_sequence.rb'
  require 'bioroebe/utility_scripts/show_this_dna_sequence/show_this_dna_sequence.rb'
  require 'bioroebe/utility_scripts/create_batch_entrez_file/create_batch_entrez_file.rb'
  require 'bioroebe/utility_scripts/fetch_data_from_uniprot/fetch_data_from_uniprot.rb'
end

.require_the_toplevel_methods(from_this_dir = TOPLEVEL_METHODS_DIRECTORY) ⇒ Object

#

Bioroebe.require_the_toplevel_methods

This method can be used to require all toplevel_method files.

#


16
17
18
19
20
21
22
23
24
25
# File 'lib/bioroebe/requires/require_the_toplevel_methods.rb', line 16

def self.require_the_toplevel_methods(
    from_this_dir = TOPLEVEL_METHODS_DIRECTORY
  )
  require 'bioroebe/project/project.rb'
  _ = Dir["#{from_this_dir}*.rb"]
  _.each {|file|
    file = "bioroebe/toplevel_methods/#{File.basename(file)}"
    require file
  }
end

.restriction_enzyme(i) ⇒ Object

#

Bioroebe.restriction_enzyme

This will simply return the raw format.

To test this, try:

result = Bioroebe.restriction_enzyme 'EcoRI.site' # => "GAATTC"
#


171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/bioroebe/enzymes/restriction_enzyme.rb', line 171

def self.restriction_enzyme(i)
  i = i.downcase # Trying this since July 2015.
  i.sub!(/\.site/,'') if i.include? '.site'
  _ = {}
  ::Bioroebe.restriction_enzymes?.each_pair {|key, value|
    # ===================================================================== #
    # We discard the trailing part after ' ' since as of November 2014.
    # ===================================================================== #
    if value.include? ' '
      value = value.split(' ').first
    end
    _[key.downcase] = value
  }
  _[i]
end

.restriction_enzymes(what_format_type = :hash_format) ⇒ Object

#

Bioroebe.restriction_enzymes

This method will either return a Hash, or an ordered Array.

In the event that it returns an Array, this Array will be sorted.

Usage examples:

pp Bioroebe.restriction_enzymes
pp Bioroebe.restriction_enzymes(:hash)
x = Bioroebe.restriction_enzymes; x.class
#


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/bioroebe/enzymes/restriction_enzymes_file.rb', line 50

def self.restriction_enzymes(
    what_format_type = :hash_format
  )
  sorted = restriction_enzymes?.sort_by {|key, value| key }
  case what_format_type
  when :array_format, :array
  # ======================================================================= #
  # === :hash_format
  # ======================================================================= #
  when :hash_format,
       :hash
    if sorted.is_a? Array
      sorted = Hash[*sorted.flatten]
    end
  end
  return sorted
end

.restriction_enzymes?Boolean

#

Bioroebe.restriction_enzymes?

#

Returns:

  • (Boolean)


32
33
34
# File 'lib/bioroebe/enzymes/restriction_enzymes_file.rb', line 32

def self.restriction_enzymes?
  YAML.load_file(restriction_enzymes_file)
end

.restriction_enzymes_fileObject

#

Bioroebe.restriction_enzymes_file

This tiny method just returns where we keep the restriction enzymes.

Is a “class” method (toplevel-method).

Use it like this:

Bioroebe.restriction_enzymes_file # => "/home/Programs/Ruby/2.7.1/lib/ruby/site_ruby/2.7.0/bioroebe/yaml/restriction_enzymes/restriction_enzymes.yml"

The RESTRICTION_ENZYMES file is now a part of the Bioroebe project.

#


25
26
27
# File 'lib/bioroebe/enzymes/restriction_enzymes_file.rb', line 25

def self.restriction_enzymes_file
  FILE_RESTRICTION_ENZYMES # This keeps the location of the yaml file.
end

.restriction_sites?(i) ⇒ Boolean

#

Bioroebe.restriction_sites?

Usage examples:

x = Bioroebe.restriction_sites?('EcoRI') # => "GAATTC"
x = Bioroebe.restriction_sites?('SacI')  # => "GAGCTC"
x = Bioroebe.restriction_sites?('KpnI')  # => "GGTACC"
x = Bioroebe.restriction_sites?('XmaI')  # => "CCCGGG"
x = Bioroebe.restriction_sites?('BamHI') # => "GGATCC"
x = Bioroebe.restriction_sites?('XbaI')  # => "TCTAGA"
x = Bioroebe.restriction_sites?('SalI')  # => "GTCGAC"
#

Returns:

  • (Boolean)


201
202
203
204
205
206
207
# File 'lib/bioroebe/enzymes/restriction_enzyme.rb', line 201

def self.restriction_sites?(i)
  if i.is_a? Array
    i = i.join(' ').strip
  end
  i = i.dup if i.frozen?
  return restriction_enzyme(i)
end

.return_all_open_reading_frames_from_this_sequence(i = 'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG', check_reverse_complement_as_well = true, start_codon = ::Bioroebe.start_codon?, stop_codons = ::Bioroebe.stop_codons?) ⇒ Object

#

Bioroebe.return_all_open_reading_frames_from_this_sequence

This method will return an Array of all open reading frames from the given input-sequence.

The second argument to this method, called ‘check_reverse_complement_as_well`, can be used to find the reverse complement.

Usage examples:

x = Bioroebe.return_all_open_reading_frames_from_this_sequence('AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG', true)

Bioroebe.return_all_open_reading_frames_from_this_sequence # => 

  ["ATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAG", "ATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGA", "ATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGA", "ATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAG", "ATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGA", "ATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAA", "ATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAA", "ATGTAGCTAACTCAGGTTACATGGGGATGA", "ATGTAG"]
#


1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1431

def self.return_all_open_reading_frames_from_this_sequence(
    i                                =
      'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG',
    check_reverse_complement_as_well = true,
    start_codon                      = ::Bioroebe.start_codon?,
    stop_codons                      = ::Bioroebe.stop_codons? # ← This method will yield an Array.
  )
  if i.is_a? Array
    # ===================================================================== #
    # Only handle the first entry in the event that an Array was given.
    # ===================================================================== #
    i = i.first
  end
  array = [] # ← We will return this Array.
  if stop_codons.empty?
    # ===================================================================== #
    # In this case we will use a hardcoded approach and define all
    # valid stop codons, referring to the eukaryotic genome.
    # ===================================================================== #
    stop_codons = %w(
      TAG TGA TAA
    )
  end
  # ======================================================================= #
  # Find all positions for start codons next; it will be stored in
  # an Array that contains all indices thereof.
  # ======================================================================= #
  all_start_codons = (0 ... i.length).find_all { |entry|
    i[entry, 3] == start_codon # First three must equal the start_codon.
  }
  array_all_subsequences = []
  all_start_codons.each {|start_index|
    subsequence = i[start_index .. -1]
    array_all_subsequences << subsequence
  }
  # ======================================================================= #
  # Now that we have all subsequences (stored in array_all_subsequences)
  # we can now match all subsequences that end with a stop codon.
  # ======================================================================= #
  array_all_subsequences.each {|sequence|
    # ===================================================================== #
    # We know that these sequences must begin with 'ATG'. Now we must
    # determine all remaining sequences with a stop-sequence here,
    # but only if they are in-frame (aka can be divided by 3).
    #
    # In order to simplify this, we will group these sequences
    # in pairs of three.
    # ===================================================================== #
    scanned = sequence.scan(/.../)
    scanned.each_with_index {|codon, index| index += 1
      if stop_codons.include? codon # In this case it is a valid stop-codon.
        array << sequence[0 .. ((index * 3)-1)]
      end
    }
  }
  # ======================================================================= #
  # The next check will also include the reverse complement as well.
  # ======================================================================= #
  if check_reverse_complement_as_well
    array << return_all_open_reading_frames_from_this_sequence(i.reverse, false)
  end
  array.flatten!
  # ======================================================================= #
  # Sort by size next - longest substring is returned first.
  # ======================================================================= #
  array = array.sort_by {|entry| entry.size }.reverse
  return array
end

.return_all_positions_of_this_nucleotide(input_string = 'AUGCUUCAGAAAGGUCUUACG', this_nucleotide = 'U') ⇒ Object

#

Bioroebe.return_all_positions_of_this_nucleotide

This method will return all positions of a given nucleotide in a larger subsequence, as an Array. Thus, the returned value will be an Array.

For example: if the input String is ‘AUGCUUCAGAAAGGUCUUACG’ and we search for ‘U’ then this method must return an Array that holds [2, 5, 6, 15, 17, 18].

#


3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3571

def self.return_all_positions_of_this_nucleotide(
    input_string    = 'AUGCUUCAGAAAGGUCUUACG',
    this_nucleotide = 'U'
  )
  # ======================================================================= #
  # Setting the default for this_nucleotide next:
  # ======================================================================= #
  this_nucleotide = 'U' if this_nucleotide.nil?
  if input_string
    array = (0 ... input_string.length).find_all {|position|
      input_string[position, 1] == this_nucleotide
    }.map {|line| line += 1 } # This line is for dealing with nucleotides.
    return array
  end
end

.return_all_substring_matches(this_string, use_this_as_substring = ::Bioroebe.start_codon?) ⇒ Object

#

Bioroebe.return_all_substring_matches

This method will give us back an Array that contains all matching substrings.

By default, the method will search for start codons such as ATG or GTG.

#


3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3433

def self.return_all_substring_matches(
    this_string,
    use_this_as_substring = ::Bioroebe.start_codon?
  )
  # ======================================================================= #
  # We will search for both ATG and AUG though, respectively the
  # input variants given to us. If the following regex appears to
  # be complicated to you, here is the old variant for the regex:
  #
  #   use_this_regex = /(ATG|AUG)/i
  #
  # =================================================================== #
  if use_this_as_substring.include? 'T'
    use_this_regex = /(#{use_this_as_substring}|#{use_this_as_substring.tr('T','U')})/i
  else
    use_this_regex = /#{use_this_as_substring}/i
  end
  result = this_string.to_enum(:scan, use_this_regex).map { |match|
    [$`.size + 1, match] # +1 because we refer to the nucleotide positions.
  }
  return result
end

.return_aminoacid_sequence_from_this_pdb_file(i = ARGV) ⇒ Object

#

Bioroebe.return_aminoacid_sequence_from_this_pdb_file

This variant will (silently) return the aminoacid sequence. The input must be a file that exists locally; if you already have a String that you wish to just parse, use the method defined below instead.

Invocation example:

Bioroebe.return_aminoacid_sequence_from_this_pdb_file "1VII.pdb" # => "MLSDEDFKAVFGMTRSAFANLPLWKQQNLKKEKGLF"
#


1060
1061
1062
# File 'lib/bioroebe/pdb_and_protein_structure/parse_pdb_file.rb', line 1060

def self.return_aminoacid_sequence_from_this_pdb_file(i = ARGV)
  Bioroebe::ParsePdbFile.new(i) { :be_silent }.aminoacid_sequence?
end

.return_aminoacid_sequence_from_this_string(i = ARGV) ⇒ Object

#

Bioroebe.return_aminoacid_sequence_from_this_string

#


1067
1068
1069
1070
1071
1072
# File 'lib/bioroebe/pdb_and_protein_structure/parse_pdb_file.rb', line 1067

def self.return_aminoacid_sequence_from_this_string(i = ARGV)
  _ = Bioroebe::ParsePdbFile.new(i, :do_not_run_yet) { :be_silent }
  dataset = i.split("\n")
  _.set_header_title_and_body(dataset)
  _.aminoacid_sequence?
end

.return_array_from_tryptic_digest(of_this_sequence = ARGV) ⇒ Object

#

Bioroebe.return_array_from_tryptic_digest

#


233
234
235
236
237
238
239
240
# File 'lib/bioroebe/cleave_and_digest/trypsin.rb', line 233

def self.return_array_from_tryptic_digest(
    of_this_sequence = ARGV
  )
  if of_this_sequence.is_a? Array
    of_this_sequence = of_this_sequence.first
  end
  Bioroebe::Trypsin.new(of_this_sequence) { :be_quiet }
end

.return_array_of_common_aminoacidsObject

#

Bioroebe.return_array_of_common_aminoacids

#


1109
1110
1111
# File 'lib/bioroebe/constants/constants.rb', line 1109

def self.return_array_of_common_aminoacids
  AMINO_ACIDS.keys - ['O'] - ['U']
end

.return_array_of_sequence_matches(main_sequence, subsequence) ⇒ Object

#

Bioroebe.return_array_of_sequence_matches

This method can be used to return an Array of subsequence matches.

This method will always return an Array - an empty Array if no subsequence match has been found; and an Array with integer numbers as indices, to denote which indices contain the subsequence. These numbers store the start position of the subsequence.

Keep in mind that for nucleotides we will start at +1, not 0, so if you see an Array such as [3, 7] as result then this refers to the nucleotide at position 3 and the nucleotide at position 7.

Arguments to this method:

The first argument to this method should be the main sequence.

The second argument to this method should be the subsequence that we assume to be part of the main sequence (that is, to occur within that main sequence at the least once).

Specific invocation examples, with the last example showing how an empty Array will be returned:

Bioroebe.return_array_of_sequence_matches('ACGTACGTAACG','GTA')   # => [3, 7]
Bioroebe.return_array_of_sequence_matches('ACGTACGTAACG','GTAAA') # => []
Bioroebe.return_array_of_sequence_matches('ATGGTGGTGGTGATGATGTGCACTCGGTTCCAGGGGGGTCGTAGGAATTGAGCTAGGACCTCCACTAGGCATCTGGGTTCGAAATTATAAAGGTCAAACGCTACTACCCTGTGTGCTAGCTTTGAAGGGCTGACGCTAGAATTGACGTCGCCGGTGACATTTGCGTCGAGGTGGTAGTAATGTTCCAAGGATGCCGGACGAACGGTACTTACCCTCGTTAGTCAGATCGCCAACCCGAGTCGTCCATGAGGAAAGCGTAATGGAAGAGACCGGGACAGCCCTCCTCAAATGTGCCTGGATACGAGTGATTTACCA','ATG')
#


3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3402

def self.return_array_of_sequence_matches(
    main_sequence,
    subsequence # ← The subsequence that you wish to match onto the main sequence.
  )
  if main_sequence
    array = []
    chars = main_sequence.chars
    if main_sequence.is_a? ::Bioroebe::Sequence
      main_sequence = main_sequence.sequence?
    end
    chars.each_with_index.select {|char, index|
      if main_sequence[index, subsequence.length] == subsequence
        array << index+1
      end
    }
    return array
  else
    []
  end
end

.return_chunked_display(i, group_together_n_nucleotides = 10) ⇒ Object

#

Bioroebe.return_chunked_display

The second argument to this method tells us how many nucleotides shall be grouped together (and then displayed as such).

#


4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4092

def self.return_chunked_display(
    i,
    group_together_n_nucleotides = 10
  )
  i = i.first if i.is_a? Array
  chunks = i.split(/(.{#{group_together_n_nucleotides}})/).reject(&:empty?)
  sliced = chunks.each_slice(6).to_a
  _ = ''.dup # We need a dynamic String.
  sliced.each {|array|
    # ===================================================================== #
    # First, add the number to the beginning.
    # ===================================================================== #
    nucleotide_position = (
      _.strip.tr(' ','').tr(N,'').gsub(/\d/,'').strip.size + 1
    ).to_s
    _ << nucleotide_position.rjust(9)+' '
    _ << array.join(' ')
    _ << N
  }
  return _
end

.return_composition_from_this_aminoacid_sequence(i = ARGV) ⇒ Object

#

Bioroebe.return_composition_from_this_aminoacid_sequence

This method will return a Hash, containing the number of aminoacids in the given aminoacid sequence.

Usage example:

x = Bioroebe.return_composition_from_this_aminoacid_sequence('HSLOEVCKWUCKFLVNUYWYGPNRAQMDCITKM')
#


332
333
334
335
336
337
338
339
# File 'lib/bioroebe/count/count_amount_of_aminoacids.rb', line 332

def self.return_composition_from_this_aminoacid_sequence(
    i = ARGV
  )
  if i.is_a? Array
    i = i.join(' ').strip
  end
  return Bioroebe::CountAmountOfAminoacids.return_composition_hash(i) { :be_quiet }
end

.return_consensus_sequence_of(*i) ⇒ Object

#

Bioroebe.return_consensus_sequence_of

This is a simpler module-method. It will just return the consensus sequence of the given input sequence.

It can be used like this:

Bioroebe.return_consensus_sequence_of(%w( ACTCC CACCA AGCCA AACGC CGCAT CGACC ACCGC GGCCG GGCGT GGCGT ))
#


374
375
376
# File 'lib/bioroebe/utility_scripts/consensus_sequence/consensus_sequence.rb', line 374

def self.return_consensus_sequence_of(*i)
  ::Bioroebe::ConsensusSequence.new(i) { :be_quiet }.consensus_sequence?
end

.return_current_day_month_yearObject

#

Bioroebe.return_current_day_month_year

#


4916
4917
4918
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4916

def self.return_current_day_month_year
  Time.now.strftime('%d.%m.%Y') # => "15.12.2020"
end

.return_current_hours_minutes_secondsObject

#

Bioroebe.return_current_hours_minutes_seconds

This method would return a String such as “21:03:32”.

#


4938
4939
4940
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4938

def self.return_current_hours_minutes_seconds
  Time.now.strftime('%H:%M:%S')
end

.return_DNA_composition_hash(of_this_sequence) ⇒ Object

#

Bioroebe.return_DNA_composition_hash

#


2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2889

def self.return_DNA_composition_hash(
    of_this_sequence
  )
  of_this_sequence = of_this_sequence.first if of_this_sequence.is_a? Array
  hash = {}
  array1 = %w( A T C G )
  array2 = Array.new(array1.size, 0)
  array = array1.zip(array2) # Zip it up with 0-values here.
  hash = Hash[array]
  of_this_sequence.chars.each {|this_char|
    hash[this_char] += 1
  }
  sorted_hash = Hash[*hash.sort_by {|key, value|
    key
  }.flatten]
  # ======================================================================= #
  # The hash may then look like this:
  #
  #   {"A"=>7, "T"=>6, "C"=>7, "G"=>6}
  #
  # ======================================================================= #
  return sorted_hash
end

.return_DNA_nucleotidesObject

#

Bioroebe.return_DNA_nucleotides

#


529
530
531
# File 'lib/bioroebe/constants/constants.rb', line 529

def self.return_DNA_nucleotides
  return DNA_NUCLEOTIDES
end

.return_every_substring_from_this_sequence(i) ⇒ Object

#

Bioroebe.return_every_substring_from_this_sequence

#


4965
4966
4967
4968
4969
4970
4971
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4965

def self.return_every_substring_from_this_sequence(i)
  result = []
  i.chars.each_with_index {|entry, index|
    result << i[0, (index+1)] 
  }
  return result
end

.return_fasta_entry_with_the_highest_gc_content(this_fasta_file) ⇒ Object

#

Bioroebe.return_fasta_entry_with_the_highest_gc_content

The first argument should be a locally existing FASTA file that contains different sequences.

Usage example:

x = Bioroebe.return_fasta_entry_with_the_highest_gc_content('/rosalind_gc.txt')
#


1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
# File 'lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb', line 1399

def self.return_fasta_entry_with_the_highest_gc_content(this_fasta_file)
  if File.exist? this_fasta_file
    dataset = File.read(this_fasta_file)
    dataset = parse_fasta(dataset) { :be_quiet }
    hash = dataset.hash?
    hash.transform_values! {|this_value|
      ::Bioroebe.gc_content(this_value).to_f
    }
    return hash.max_by {|key, value| value }
  else
    erev "No file exists at #{sfile(this_fasta_file)}#{rev}."
  end
end

.return_fasta_sequence_from_this_pdb_file(i = ARGV) ⇒ Object

#

Bioroebe.return_fasta_sequence_from_this_pdb_file

This variant will (silently) return the aminoacid sequence.

Invocation example:

x = Bioroebe.return_fasta_sequence_from_this_pdb_file "2bts" # => "MLSDEDFKAVFGMTRSAFANLPLWKQQNLKKEKGLF"
#


140
141
142
143
144
145
146
147
148
149
150
# File 'lib/bioroebe/pdb_and_protein_structure/fetch_fasta_sequence_from_pdb.rb', line 140

def self.return_fasta_sequence_from_this_pdb_file(i = ARGV)
  require 'bioroebe/pdb_and_protein_structure/parse_pdb_file.rb'
  sequence = Bioroebe::FetchFastaSequenceFromPdb.new(i) { :be_silent }.aminoacid_sequence?
  if sequence.start_with? '>'
    sequence = sequence.split("\n")[1..-1]
  end
  if sequence.is_a? Array
    sequence = sequence.first
  end
  return sequence
end

.return_fasta_subsection_of_this_file(i = nil, extra_options = :default) ⇒ Object

#

Bioroebe.return_fasta_subsection_of_this_file

This method will parse an existing fasta file into its constituent header and body parts, stored as an Array in an Array.

The second argument to this method can be used to flatten the inner Array keeping track of the FASTA content; or to keep it separate. Keeping it separate is the default behaviour.

Invocation examples:

Bioroebe.return_fasta_subsection_of_this_file("foobar.fa")
Bioroebe.return_fasta_subsection_of_this_file("foobar.fa", :keep_it_flat)
Bioroebe.return_fasta_subsection_of_this_file("/home/Temp/bioroebe/fasta/alu_elements.fasta", :keep_it_flat)
#


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/bioroebe/fasta_and_fastq/return_fasta_subsection_of_this_file.rb', line 29

def self.return_fasta_subsection_of_this_file(
    i             = nil,
    extra_options = :default # The two values can be :keep_it_flat or :keep_body_together
  )
  case extra_options
  when :default
    extra_options = :keep_it_flat
  end
  array = []
  i = i.first if i.is_a? Array
  if i.nil?
    e 'Please provide the file path to a locally '\
      'existing fasta file, as argument.'
    return
  end
  if File.exist? i
    dataset = File.readlines(i)
pp 'DEBUG'
pp dataset
    inner_array = []
    size = dataset.size
    dataset.each_with_index {|line, index|
      if line.start_with? '>'
        # ================================================================= #
        # Store it in that case - this will be a fasta header section.
        # ================================================================= #
        unless inner_array.empty?
          array << inner_array
          inner_array = [] # And reset it here as well.
        end
        inner_array.prepend(line)
      else
        # ================================================================= #
        # This will be a FASTA body section.
        # ================================================================= #
        case extra_options
        # ================================================================= #
        # === :keep_body_together
        # ================================================================= #
        when :keep_body_together, # the default
             :keep_it_flat
          inner_array << line
        else
          # =============================================================== #
          # Else we have to append it.
          # =============================================================== #
          previous_line = inner_array.last
          if previous_line and previous_line.start_with?('>')
            inner_array << line
          else
            inner_array.last.strip!
            inner_array.last << line
          end
        end
      end
      if (index + 1) == size
        # Store the last entry as well.
        array << inner_array
        inner_array = [] # And reset it here as well.
      end
    }
    array
  else
    e "No file exists at `#{i}`."
  end
end

.return_illumina_offset(_ = FILE_FASTQ_QUALITY_SCHEMES) ⇒ Object

#

Bioroebe.return_illumina_offset

#


107
108
109
110
111
112
113
114
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 107

def self.return_illumina_offset(
    _ = FILE_FASTQ_QUALITY_SCHEMES
  )
  dataset = YAML.load_file(_)
  entry = dataset['fastq-illumina']
  offset = entry['offset']
  return offset
end

.return_long_aminoacid_name(short_name_of_the_aminoacid) ⇒ Object

#

Bioroebe.return_long_aminoacid_name

Use this method to translate a one-letter aminoacid to the long name of the given aminoacid.

We also have to consider Stop-Codons as input.

Usage examples:

Bioroebe.return_long_aminoacid_name 'M' # => "Methionin"
Bioroebe.return_long_aminoacid_name 'T' # => "Threonine"
#


2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2029

def self.return_long_aminoacid_name(
    short_name_of_the_aminoacid
  )
  aminoacid = AMINO_ACIDS_ENGLISH[short_name_of_the_aminoacid].dup
  if aminoacid
    aminoacid = aminoacid.select {|key,value|
      key.size == 3
    }.flatten[1]
  else
    aminoacid = short_name_of_the_aminoacid
    aminoacid = 'Translation Stop' if aminoacid == '*'
  end unless aminoacid.is_a? String
  return aminoacid
end

.return_longest_ORF_from_this_sequence(i = 'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGC'\ 'GACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATC'\ 'CGAGTAGCATCTCAG', check_reverse_complement_as_well = true, start_codon = ::Bioroebe.start_codon?, stop_codons = ::Bioroebe.stop_codons?) ⇒ Object

#

Bioroebe.return_longest_ORF_from_this_sequence

This method will return the longest ORF from the given input sequence. By default it will assume that the input sequence is meant to have derived from a dsDNA sequence, so the reverse complement is evaluated as well. If you do not need or want that behaviour then simply pass “false” as the second argument to this method.

Usage example:

x = Bioroebe.return_longest_ORF_from_this_sequence; puts x
#


1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1395

def self.return_longest_ORF_from_this_sequence(
    i                                =
      'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGC'\
      'GACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATC'\
      'CGAGTAGCATCTCAG',
    check_reverse_complement_as_well = true,
    start_codon                      = ::Bioroebe.start_codon?,
    stop_codons                      = ::Bioroebe.stop_codons? # ← This method will yield an Array.
  )
  results = Bioroebe.return_all_open_reading_frames_from_this_sequence(
    i, check_reverse_complement_as_well, start_codon, stop_codons
  ).sort_by {|entry| entry.size }.reverse
  longest_result = results.first
  return longest_result
end

.return_longest_substring_via_LCS_algorithm(sequence1 = ARGV, sequence2 = nil) ⇒ Object

#

Bioroebe.return_longest_substring_via_LCS_algorithm

This method will return the longest substring between two different sequences. It will ignore gaps and will thus not be as sophisticated as other algorithms.

This method will return a String.

Usage example in plain ruby:

Bioroebe.return_longest_substring_via_LCS_algorithm 'ATGAAA','ATGCAT' # => 'ATGA'
#


3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3355

def self.return_longest_substring_via_LCS_algorithm(
    sequence1 = ARGV,
    sequence2 = nil
  )
  begin
    require 'diff/lcs' # Require the gem here.
  rescue LoadError; end
  if sequence1.is_a? Array
    if sequence1.size > 1
      sequence2 = sequence1[1]
      sequence1 = sequence1[0]
    end
  end 
  lcs_object = Diff::LCS.LCS(sequence1, sequence2)
  return lcs_object.join # Must return a String.
end

.return_n_ORFs_in_this_sequence(i = 'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG', start_codon = Bioroebe.to_aa(::Bioroebe.start_codon?)) ⇒ Object

#

Bioroebe.return_n_ORFs_in_this_sequence

Return how many ORFs are in a given sequence.

#


1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1505

def self.return_n_ORFs_in_this_sequence(
      i           =
        'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG',
      start_codon = Bioroebe.to_aa(::Bioroebe.start_codon?)
    )
  if i.is_a? Array
    i = i.join
  end
  if i.is_a? String
    i = i.chars
  end
  n_ORFs_in_this_sequence = 0
  all_start_codons = (0 ... i.length).find_all {|index|
    i[index] == start_codon
  }
  stop_codons_are_at_that_position = (0 ... i.length).find_all {|index|
    i[index] == '*'
  }
  all_start_codons.each {|this_start_codon_position|
    stop_codons_are_at_that_position.each {|this_stop_codon_position|
      if this_start_codon_position < this_stop_codon_position
        n_ORFs_in_this_sequence += 1
        break
      end 
    }
  }
  return n_ORFs_in_this_sequence
end

.return_n_repeats(i = ARGV, use_this_as_the_repeat_pattern = 'ATG') ⇒ Object

#

Bioroebe.return_n_repeats

This willy not output anything but simply return the number of matches matches.

#


138
139
140
141
142
143
144
145
146
# File 'lib/bioroebe/patterns/scan_for_repeat.rb', line 138

def self.return_n_repeats(
    i                              = ARGV,
    use_this_as_the_repeat_pattern = 'ATG'
  )
  return Bioroebe::ScanForRepeat.new(i) {{
    pattern: use_this_as_the_repeat_pattern,
    verbose: :be_quiet
  }}.n_patterns?
end

.return_new_filename_based_on_fasta_identifier(i) ⇒ Object

#

Bioroebe.return_new_filename_based_on_fasta_identifier

This method will give us a new filename suggestion, which we can use to then rename a FASTA file (.fa).

Usage example:

Bioroebe.return_new_filename_based_on_fasta_identifier "NC_008253.fna" # => "NC_008253.1_Escherichia_coli_536.fasta"
Bioroebe.return_new_filename_based_on_fasta_identifier ">NC_000866.4 Enterobacteria phage T4, complete genome" # => "NC_008253.1_Escherichia_coli_536.fasta"
#


161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 161

def self.return_new_filename_based_on_fasta_identifier(i)
  if i.is_a? Array
    i.flatten!
    i.compact!
    i = i.first
  end
  fasta_identifier = File.readlines(i).first
  if fasta_identifier
    if fasta_identifier.include? '|'
      splitted = fasta_identifier.split('|')
    elsif fasta_identifier.start_with?('>') # else may look like ">NC_000866.4 Enterobacteria phage T4, complete genome\n"
      splitted = fasta_identifier.delete('>,').split(' ')
      nm_identifier = splitted[0]
      name_of_the_sequence = splitted[1 .. -1].join(' ').strip
    end
    if fasta_identifier.include? '|'
      case splitted.size
      when 3
        nm_identifier = splitted[1]
        name_of_the_sequence = splitted[2]
      else
        nm_identifier = splitted[3] # Such as "NM_007315.3"
        name_of_the_sequence = splitted[4] # Such as "Homo sapiens signal transducer and activator of transcription 1 (STAT1)"
      end
    end
    if nm_identifier
      nm_identifier.strip!
      name_of_the_sequence.strip!
      if name_of_the_sequence.include? ','
        name_of_the_sequence = name_of_the_sequence[0 .. name_of_the_sequence.index(',')].strip
      end
      name_of_the_sequence.tr!(' ()/','_')
      name_of_the_sequence.tr!(',','')
      name_of_the_sequence.tr!('.','')   # We need no '.' characters.
      name_of_the_sequence.squeeze!('_') # We want only one '_'.
      name_of_the_sequence.squeeze!('-')
      name_of_the_sequence.chop! if name_of_the_sequence.end_with? '_'
      new_filename = nm_identifier+'_'+name_of_the_sequence+'.fasta'
      # =================================================================== #
      # Next, prepend the target directory.
      # =================================================================== #
      new_filename.prepend(log_dir?)
      # =================================================================== #
      # And get rid of any possible dual '//'.
      # =================================================================== #
      new_filename = rds(new_filename)
    else
      e swarn('Something went wrong - we did not find a valid NCBI entry.') 
      return nil
    end
  else
    erev "No FASTA identifier could be found for #{sfile(i)}#{rev}."
  end
end

.return_nucleotide_sequence_as_ten_nucleotides_chunks(i) ⇒ Object

#

Bioroebe.return_nucleotide_sequence_as_ten_nucleotides_chunks

#


4082
4083
4084
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4082

def self.return_nucleotide_sequence_as_ten_nucleotides_chunks(i)
  i.split(/(.{10})/).reject(&:empty?)
end

.return_random_aminoacid_from_this_prosite_pattern(i) ⇒ Object

#

Bioroebe.return_random_aminoacid_from_this_prosite_pattern

If no match was found, the original input will be returned.

Usage examples:

Bioroebe.return_random_aminoacid_from_this_prosite_pattern()
Bioroebe.return_random_aminoacid_from_this_prosite_pattern('[GSTNE]')
Bioroebe.return_random_aminoacid_from_this_prosite_pattern('{ANW}')
Bioroebe.return_random_aminoacid_from_this_prosite_pattern('x(2)')
#


1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1803

def self.return_random_aminoacid_from_this_prosite_pattern(i)
  if i.include?('(') and i.include?(')') and i.include?('x')
    n_aminoacids = i.scan(REGEX_PROSITE_FOR_ANY_AMINOACID).flatten.first.to_i
    result = n_aminoacids.times.map { return_random_aminoacid }.join
    return result
  end
  if i.include?('[') and i.include?(']')
    splitted = i.delete('[]').split(//)
    return splitted.sample
  end
  if i.include?('{') and i.include?('}')
    # ===================================================================== #
    # In this case we will return a random aminoacid
    # without any of the specified aminoacids.
    # ===================================================================== #
    forbidden_aminoacids = i.delete('{}').split(//)
    all_aminoacids = Bioroebe.aminoacids?.keys
    filtered_aminoacids = all_aminoacids.reject {|this_aminoacid|
      forbidden_aminoacids.include? this_aminoacid
    }
    return filtered_aminoacids.sample
  end
  return i # Return the original input in this case.
end

.return_random_codon_sequence_for_this_aminoacid_sequence(i = 'KKKA') ⇒ Object

#

Bioroebe.return_random_codon_sequence_for_this_aminoacid_sequence

This method will return a random linear codon sequence, as an Array, for the given input aminoacid sequence.

Usage examples:

Bioroebe.return_random_codon_sequence_for_this_aminoacid_sequence('KKKA') # => ["AAA", "AAA", "AAA", "GCG"]
Bioroebe.return_random_codon_sequence_for_this_aminoacid_sequence('KKKA') # => ["AAA", "AAA", "AAG", "GCC"]
#


419
420
421
422
423
424
425
# File 'lib/bioroebe/codons/codons.rb', line 419

def self.return_random_codon_sequence_for_this_aminoacid_sequence(i = 'KKKA')
  _ = decode_this_aminoacid_sequence(i)
  _.map {|array|
    sample = array.sample
    sample
  }
end

.return_random_nucleotideObject

#

Bioroebe.return_random_nucleotide

This method will randomly return either ‘A’, ‘T’, ‘C’ or ‘G’.

#


513
514
515
# File 'lib/bioroebe/constants/constants.rb', line 513

def self.return_random_nucleotide
  (POSSIBLE_DNA_NUCLEOTIDES - ['N']).sample # This constant holds A T G and C.
end

.return_restriction_enzyme_sequence_and_cut_position(i) ⇒ Object

#

Bioroebe.return_restriction_enzyme_sequence_and_cut_position

This method will return an Array.

The format of this Array is as follows:

- The first entry is the target sequence that is recognized for
  cutting.

- The second entry will be the target position where the cut will
  occur, as an Integer.

The input to this method should be the name of the restriction enzyme.

Since as of August 2016, we may also return the type, e. g. “blunt” for a blunt-end cutter, or “sticky” for a sticky-end cutter.

Usage example:

result = Bioroebe.return_restriction_enzyme_sequence_and_cut_position 'EcoRI'
result = Bioroebe.return_restriction_enzyme_sequence_and_cut_position 'MvnI'
#


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/bioroebe/enzymes/return_restriction_enzyme_sequence_and_cut_position.rb', line 36

def self.return_restriction_enzyme_sequence_and_cut_position(i)
  i = i.dup if i.frozen?
  i.downcase! # Trying to downcase since as of July 2015.
  i.sub!(/\.site/,'') if i.include? '.site'
  _ = {}
  dataset = ::Bioroebe.restriction_enzymes?
  dataset.each_pair {|key, value|
    _[key.downcase] = value
  }
  if _
    result = _[i] # result could be: "GAATTC 1"
    if result
      splitted = result.split(' ')
      # =================================================================== #
      # Next, build-up our Array.
      # =================================================================== #
      cuts_at_this_site = splitted.first
      cuts_at_this_internal_position = splitted.last.to_i # Return an Integer.
      produces_blunt_ends_or_sticky_ends = :sticky
      # =================================================================== #
      # Determine restriction enzymes that are blunt. If not then they
      # will be sticky.
      # =================================================================== #
      if ((cuts_at_this_site.size % cuts_at_this_internal_position.to_i) == 0)
        produces_blunt_ends_or_sticky_ends = :blunt
      end
      return [
        cuts_at_this_site,
        cuts_at_this_internal_position,
        produces_blunt_ends_or_sticky_ends
      ]
    else
      nil
    end
  else
    _
  end
end

.return_sanger_offset(_ = FILE_FASTQ_QUALITY_SCHEMES) ⇒ Object

#

Bioroebe.return_sanger_offset

#


95
96
97
98
99
100
101
102
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 95

def self.return_sanger_offset(
    _ = FILE_FASTQ_QUALITY_SCHEMES
  )
  dataset = YAML.load_file(_)
  entry = dataset['fastq-sanger']
  offset = entry['offset']
  return offset
end

.return_sequence_from_this_file(this_file = 'bla.fasta') ⇒ Object

#

Bioroebe.return_sequence_from_this_file

This is mostly an ad-hoc method to quickly read data from a local fasta file.

Usage example:

x = Bioroebe.return_sequence_from_this_file('viruses.fa')
#


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 74

def self.return_sequence_from_this_file(
    this_file = 'bla.fasta'
  )
  if File.exist? this_file
    dataset = File.readlines(this_file).select {|line|
      line.start_with? '     '
    }.map(&:strip).map {|line|
      Bioroebe.remove_numbers(
        line.upcase.delete(' ')
      )
    }
    if dataset.is_a? Array
      dataset = dataset.join
    end
    return dataset
  end
end

.return_sequence_that_is_cut_via_restriction_enzyme(i, use_colours = use_colours? ) ⇒ Object

#

Bioroebe.return_sequence_that_is_cut_via_restriction_enzyme

This method will return a string such as “G|AATTC”. This is the restriction recognition site for EcoRI.

This method prefers an Array as input. This Array should have two entries.

Usage examples:

x = Bioroebe.return_sequence_that_is_cut_via_restriction_enzyme('EcoRI', :no_colours) # => "G|AATTC"
x = Bioroebe.return_sequence_that_is_cut_via_restriction_enzyme('MvnI', :no_colours)
#


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bioroebe/enzymes/return_sequence_that_is_cut_via_restriction_enzyme.rb', line 27

def self.return_sequence_that_is_cut_via_restriction_enzyme(
    i,
    use_colours = use_colours?
  )
  case use_colours
  when :no_colours
    use_colours = false
  end
  unless i.is_a? Array
    i = return_restriction_enzyme_sequence_and_cut_position(i)
  end
  if i
    # ======================================================================= #
    # Ok, now we assume that everything is fine.
    # ======================================================================= #
    first  = i.first
    second = i[1] # Can not be i.last because as of August 2016 we may also return "blunt" or "overhang".
    result = ''.dup
    result << rev if use_colours
    result << first[0, second.to_i]
    if use_colours
      result << swarn('|')
    else
      result << '|' # We like to return '|' tokens.
    end
    result << rev if use_colours
    result << first[second.to_i .. -1]
    return result
  else
    return nil
  end
end

.return_short_aminoacid_letter_from_long_aminoacid_name(i) ⇒ Object

#

Bioroebe.return_short_aminoacid_letter_from_long_aminoacid_name

This will turn input such as “lysine” into “K”.

Invocation example:

Bioroebe.return_short_aminoacid_letter_from_long_aminoacid_name('lysine') # => "K"

Commandline invocation example:

short_aminoacid_letter_from_long_aminoacid_name lysine
#


1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1629

def self.return_short_aminoacid_letter_from_long_aminoacid_name(
    i
  )
  if i.nil?
    e "Please provide some input to the method #{__method__.to_s}."
    return nil
  end
  aminoacids = AMINO_ACIDS_ENGLISH
  inverted_table = aminoacids.invert
  i = [i].flatten.compact.map(&:capitalize)
  if i.first.include? '-'
    i = i.join.strip.split('-').map {|entry|
      entry.capitalize!
      if inverted_table.has_key? entry
        entry = inverted_table[entry]
      else
        e "The given input `#{entry}` does not appear to be "\
          "a valid long-letter aminoacid."
      end
      entry
    }
  end
end

.return_sizeseq(i) ⇒ Object

#

Bioroebe.return_sizeseq

This is as Bioroebe.sizeseq(), but it will just return the result, rather than output it.

#


1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
# File 'lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb', line 1432

def self.return_sizeseq(i)
  if i.is_a? Array
    i = i.first
  end
  _ = Bioroebe.parse_fasta(i) { :be_quiet }
  hash = _.return_size_sorted_hash
  result = ''.dup
  hash.each_pair {|key, sequence|
    result << '> ID '+sequence.size.to_s+' AA.; DE: '+key.to_s+
         ' SQ '+sequence.size.to_s+' AA'+N
    result << sequence+N+N
  }
  return result
end

.return_solexa_offset(_ = FILE_FASTQ_QUALITY_SCHEMES) ⇒ Object

#

Bioroebe.return_solexa_offset

#


119
120
121
122
123
124
125
126
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 119

def self.return_solexa_offset(
    _ = FILE_FASTQ_QUALITY_SCHEMES
  )
  dataset = YAML.load_file(_)
  entry = dataset['fastq-solexa']
  offset = entry['offset']
  return offset
end

.return_source_code_of_this_method(i) ⇒ Object

#

Bioroebe.return_source_code_of_this_method

This method will return the source code of a particular method.

Note that the method will stop at the first ‘end’ encountered.

#


1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1720

def self.return_source_code_of_this_method(i)
  if i.is_a? Array
    i = i.first
  end
  content = i.source_location
  full_content = File.readlines(
    content[0].to_s
  )[ (content[1]-1) .. -1 ].join.to_s
  if full_content.include? 'end'
    full_content = full_content[0 .. full_content.index('end')+2]
  end
  return full_content  
end

.return_subsequence_based_on_indices(i, *array_of_indices) ⇒ Object

#

Bioroebe.return_subsequence_based_on_indices

This method will return a subsequence that was sliced out from the given input array of indices (the second argument to this method).

This method here also allows us to read from an existing File. The format of that file has to be simple, though - the first line must be the sequence; and the second line will constitute the array of indices.

For a usage example, see the end of this file here please. It has been written primarily to solve a specific task at Rosalind.

#


2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2275

def self.return_subsequence_based_on_indices(
    i, *array_of_indices
  )
  if array_of_indices.is_a? Array
    array_of_indices.map! {|entry| entry.to_i }
  end
  result = ''.dup
  if i and i.is_a?(String) and File.exist?(i)
    dataset = File.readlines(i).reject {|line| line.strip.empty? }
    i = dataset.first
    array_of_indices = dataset.last.split(' ').map(&:to_i)
  end
  array_of_indices.each_slice(2).each {|a, b|
    result << i[a .. b]+' '
  }
  result.strip
end

.return_the_most_likely_codon_sequence_for_this_aminoacid_sequence(i = 'KKKA', use_this_codon_tables_frequencies = :homo_sapiens) ⇒ Object

#

Bioroebe.return_the_most_likely_codon_sequence_for_this_aminoacid_sequence

This method will (quietly) return the most likely codon sequence (in DNA) from a particular aminoacid sequence.

Presently this method will use the Homo sapiens codon table as default input (the second parameter).

Numeric values such as 1 or 2 can also be provided as first argument to this method.

A String will be returned by this method.

Invocation examples:

Bioroebe.return_the_most_likely_codon_sequence_for_this_aminoacid_sequence 'KKKA'              # => "AAGAAGAAGGCC"
Bioroebe.return_the_most_likely_codon_sequence_for_this_aminoacid_sequence 'KKKA', :yeast      # => "AAAAAAAAAGCU"
Bioroebe.return_the_most_likely_codon_sequence_for_this_aminoacid_sequence 'AWKT', :drosophila # => "GCCUGGAAGACC"
#


165
166
167
168
169
170
171
172
173
# File 'lib/bioroebe/nucleotides/most_likely_nucleotide_sequence_for_this_aminoacid_sequence.rb', line 165

def self.return_the_most_likely_codon_sequence_for_this_aminoacid_sequence(
    i                                 = 'KKKA',
    use_this_codon_tables_frequencies = :homo_sapiens
  )
  if i.is_a? Array
    i = i.reject {|entry| entry.start_with?('--') }.join.strip
  end
  return Bioroebe::MostLikelyNucleotideSequenceForThisAminoacidSequence.new(i, use_this_codon_tables_frequencies) { :be_quiet }.sequence?
end

.return_ubiquitin_sequence(i = 'MQIFVKTLTGKTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLHLVLRLRGG') ⇒ Object

#

Bioroebe.return_ubiquitin_sequence

This method will simply return the Ubiquitin sequence. We may also colourize some aminoacids, if we have enabled this.

#


2797
2798
2799
2800
2801
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2797

def self.return_ubiquitin_sequence(
    i = 'MQIFVKTLTGKTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLHLVLRLRGG'
  )
  colourize_aa(i) # Consider colourizing it.
end

.revObject

#

Bioroebe.rev (rev tag)

The general pointer towards using the default colour.

This will, however had, only be in use if we do not use colours.

#


47
48
49
50
51
52
53
54
55
# File 'lib/bioroebe/colours/colours.rb', line 47

def self.rev
  if @use_colours
    unless Object.const_defined?(:Colours)
      require 'colours/html_colours'
    end
    return ::Colours::GREEN # Default colour goes in here.
  end
  return ''
end

.reverse_complement(i = ARGV) ⇒ Object

#

Bioroebe.reverse_complement

Invocation examples:

Bioroebe.reverse_complement 'AT'
Bioroebe.reverse_complement 'AAAACCCGGT' # => "ACCGGGTTTT"
#


137
138
139
140
# File 'lib/bioroebe/sequence/reverse_complement.rb', line 137

def self.reverse_complement(i = ARGV)
  result = ::Bioroebe::ReverseComplement.new(i) { :be_quiet }.result?
  return result
end

.reverse_sequence(i) ⇒ Object

#

Bioroebe.reverse_sequence

#


2806
2807
2808
2809
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2806

def self.reverse_sequence(i)
  i = i.first if i.is_a? Array
  i.reverse
end

.rna_sequence(i) ⇒ Object

#

Bioroebe.rna_sequence

Usage example:

dna = Bioroebe.rna_sequence('ATTCGGU')
#


208
209
210
211
212
# File 'lib/bioroebe/sequence/rna.rb', line 208

def self.rna_sequence(i)
  i = i.first if i.is_a? Array
  i.delete!('T') # Reject Thymine there.
  ::Bioroebe::RNA.new(i)
end

.rna_splicing(i) ⇒ Object

#

Bioroebe.rna_splicing

This is a VERY primitive method that has been written primarily to solve a specific question on Rosalind.

This is NOT how splicing normally works - but it works to solve the given question at Rosalind.

Invocation example:

Bioroebe.rna_splicing('/SPLICING.md')
#


2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2345

def self.rna_splicing(i)
  require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
  if i and File.exist?(i)
    # ===================================================================== #
    # Read in the file should it exist.
    # ===================================================================== #
    i = File.read(i).strip
  end
  if i.is_a?(String) and i.include?('>')
    _ = ::Bioroebe::ParseFasta.new(i) { :be_quiet }
    sequences = _.sequences?
    main_sequence = sequences.first
    array_subsequences = sequences[1 .. -1]
    result = ::Bioroebe.remove_subsequence(array_subsequences, main_sequence)
    return result
  end
end

.rnalfold(i = :use_all_fasta_files_in_the_current_directory) ⇒ Object

#

Bioroebe.rnalfold

This method allows us to make use of RNALfold. By default the method will attempt to obtain all .fa files in the current directory; this should simplify batch-processing.

Otherwise, the first input argument to this method should be the file(s) that you wish to manipulate.

A typical usage example may be:

Bioroebe.rnalfold { '--zscore=-3 -L 200' }
#


741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 741

def self.rnalfold(
    i = :use_all_fasta_files_in_the_current_directory
  )
  # ======================================================================= #
  # RNALfold will be used (as command).
  # ======================================================================= #
  use_this_command = 'RNALfold'.dup
  case i
  when :default,
       :use_all_fasta_files_in_the_current_directory
    i = Dir['**.fa']
  end
  if block_given?
    yielded = yield
    # ===================================================================== #
    # Simply append these block-commands in that case:
    # ===================================================================== #
    use_this_command << " #{yielded}"
  end
  # ======================================================================= #
  # We assume that our input is an Array past this point.
  # ======================================================================= #
  i.each {|this_file|
    e "Working on `#{sfancy(this_file)}` next."
    new_filename = this_file.dup
    regex_to_use = /-L (\d+)/
    use_this_command =~ regex_to_use
    new_filename << '.'+$1.to_s.dup
    new_filename << '.lfold'
    _ = use_this_command+' < '+this_file+' > '+new_filename
    esystem _
    if File.exist? new_filename
      e "A new file has been created at `#{sfile(new_filename)}`."
    end
  }
end

.ruler(i, group_together_n_nucleotides = 70) ⇒ Object

#

Bioroebe.ruler

Simpler toplevel-API for when you may want to use a ruler.

#


203
204
205
206
207
208
209
# File 'lib/bioroebe/misc/ruler.rb', line 203

def self.ruler(
      i, group_together_n_nucleotides = 70
    )
  ::Bioroebe::Ruler.new(
    i, group_together_n_nucleotides
  ).result?
end

.ruler_return_as_string(i, group_together_n_nucleotides = 70) ⇒ Object

#

Bioroebe.ruler_return_as_string

This will return the ruler as a String; it exists mostly for convenience reasons.

Invocation examples:

puts Bioroebe.ruler_return_as_string 'ATGCTGACAGGGGGGGEEEEEE'
puts Bioroebe.return_ruler('ATGCTGACAGGGGGGGEEEEEE')
#


223
224
225
# File 'lib/bioroebe/misc/ruler.rb', line 223

def self.ruler_return_as_string(i, group_together_n_nucleotides = 70)
  ::Bioroebe::Ruler.new(i, group_together_n_nucleotides).result_as_string
end

.ruler_return_as_string_without_colours(i, group_together_n_nucleotides = 70) ⇒ Object

#

Bioroebe.ruler_return_as_string_without_colours

This is like Bioroebe.ruler_return_as_string(), as defined above in this file, but without any colours.

Invocation example:

puts Bioroebe.ruler_return_as_string_without_colours 'ATGCTGACAGGGGGGGEEEEEE'
#


238
239
240
# File 'lib/bioroebe/misc/ruler.rb', line 238

def self.ruler_return_as_string_without_colours(i, group_together_n_nucleotides = 70)
  ::Bioroebe::Ruler.new(i, group_together_n_nucleotides) { :no_colours }.result_as_string
end

.run_gtk_controllerObject

#

Bioroebe.run_gtk_controller

#


466
467
468
# File 'lib/bioroebe/gui/universal_widgets/controller/controller.rb', line 466

def self.run_gtk_controller
  Bioroebe::GUI::Gtk::Controller.run
end

.run_sql_query(i, be_verbose = true, optional_append_this = '') ⇒ Object

#

Bioroebe.run_sql_query

This method will run a SQL query using –command.

It will return the result as well.

The second argument determines whether we will be verbose or not.

The result, however, will always be displayed.

#


647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 647

def self.run_sql_query(
    i,
    be_verbose           = true,
    optional_append_this = ''
  )
  set_pgpassword
  i = i.to_s
  _ = ''
  if is_on_roebe?
    _ << POSTGRE_LOGIN_COMMAND_HOME
  else
    _ << POSTGRE_LOGIN_COMMAND
  end
  case be_verbose
  when :silent
    be_verbose = false
  end
  case optional_append_this
  # ======================================================================= #
  # === :bare
  # ======================================================================= #
  when :bare,
       :tuples
    optional_append_this = ' --tuples-only'
  end
  _ << optional_append_this.to_s
  _ << ' --command="'
  _ << i
  _ << '"' unless _.end_with? '"'
  result = `#{_}`.chomp
  erev _      if be_verbose
  erev result if be_verbose
  return result
end

.salt_adjusted_tm(i = 'CCGTGTCGTACATCG') ⇒ Object

#

Bioroebe.salt_adjusted_tm

This method will just return the Tm value, as a float (number).

The input to this method should be your DNA sequence at hand,

    1. the PCR-primer.

Invocation example:

result = Bioroebe.salt_adjusted_tm # => 48.836
#


286
287
288
289
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 286

def self.salt_adjusted_tm(i = 'CCGTGTCGTACATCG')
  _ = ::Bioroebe::CalculateMeltingTemperatureForMoreThanThirteenNucleotides.new(i) { :do_not_report_anything }
  _.tm_value?
end

.sanitize_nucleotide_sequence(i) ⇒ Object

#

Bioroebe.sanitize_nucleotide_sequence

Usage example:

Bioroebe.sanitize_nucleotide_sequence  "1 ATCCG\n30 TTACG\n50 AAATTTG" # => "ATCCGTTACGAAATTTG"
#


165
166
167
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 165

def self.sanitize_nucleotide_sequence(i)
  SanitizeNucleotideSequence.new(i).result?
end

.sanitize_this_fasta_file(i) ⇒ Object

#

Bioroebe.sanitize_this_fasta_file

This method will modify a .fasta file’s sequence header, by appending the number of aminoacids to this header.

Usage example:

Bioroebe.sanitize_this_fasta_file('/root/Bioroebe/fasta/IFNB1-P01574.fasta')
#


1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
# File 'lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb', line 1535

def self.sanitize_this_fasta_file(i)
  if File.exist? i
    dataset = File.readlines(i).map(&:strip)
    header = dataset.first.dup
    aminoacid_sequence = Bioroebe::ParseFasta.new(i) { :be_silent }.return_n_aminoacids
    header << ", #{aminoacid_sequence} aminoacids"
    dataset[0] = header
    # ===================================================================== #
    # Now we can save it again.
    # ===================================================================== #
    e 'Storing the modified data into '+sfile(i)+'.'
    write_what_into(dataset.join(N), i)
  end
end

.scan_for_rgg_motifs(i) ⇒ Object

#

Bioroebe.scan_for_rgg_motifs

#


154
155
156
# File 'lib/bioroebe/patterns/rgg_scanner.rb', line 154

def self.scan_for_rgg_motifs(i)
  Bioroebe::RGG_Scanner.new(i)
end

.scan_this_input_for_startcodons(input, regex = ::Bioroebe.regex_with_startcodons) ⇒ Object

#

Bioroebe.scan_this_input_for_startcodons

The first argument to this method should be the DNA sequence that you wish to scan for.

The second input is optional - it should be the regex to apply in order to find all matches.

The method will then return an Array that may look like this:

[[1, ["ATG"]], [12, ["ATG"]], [18, ["ATG"]]]

So it starts at 1, rather than 0, as there is no nucleotide 0.

#


102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/bioroebe/codons/codons.rb', line 102

def self.scan_this_input_for_startcodons(
    input,
    regex = ::Bioroebe.regex_with_startcodons
  )
  if input.is_a? Array
    input = input.first
  end
  array = []
  # ======================================================================= #
  # We will search for both ATG and AUG though, respectively what
  # the above regex will return.
  # ======================================================================= #
  input.to_enum(:scan, regex).map { |match|
    array << [$`.size + 1, match] # +1 because we refer to the nucleotide positions.
  }
  return array
end

.sdir(i = '') ⇒ Object

#

Bioroebe.sdir

#


86
87
88
89
90
91
# File 'lib/bioroebe/colours/colours.rb', line 86

def self.sdir(i = '')
  if @use_colours
    i = Colours.sdir(i)
  end
  return i
end

.sequence?Boolean

#

Bioroebe.sequence?

Will return the sequence.

#

Returns:

  • (Boolean)


717
718
719
# File 'lib/bioroebe/sequence/sequence.rb', line 717

def self.sequence?
  @sequence.sequence
end

.sequence_based_on_these_restriction_enzymes(*i) ⇒ Object

#

Bioroebe.sequence_based_on_these_restriction_enzymes

Usage example:

x = Bioroebe.sequence_based_on_these_restriction_enzymes(%w( EcoRI SacI KpnI XmaI BamHI XbaI SalI )); 'GAATTCGAGCTCGGTACCCCCGGGGGATCCTCTAGAGTCGAC'
#


3075
3076
3077
3078
3079
3080
3081
3082
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3075

def self.sequence_based_on_these_restriction_enzymes(*i)
  require 'bioroebe/enzymes/restriction_enzyme.rb'
  _ = ''.dup
  i.flatten.each {|this_restriction_enzyme|
    _ << ::Bioroebe.restriction_sites?(this_restriction_enzyme)
  }
  return _
end

.set_codon_table_in_use(i = :default, be_verbose = false) ⇒ Object

#

Bioroebe.set_codon_table_in_use

This method can set which codon table is in use. Note that it does not have to do any sanitizing, as this will be done in another method anyway.

Example:

::Bioroebe.set_codon_table :human
#


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/bioroebe/codons/codon_table.rb', line 55

def self.set_codon_table_in_use(
    i          = :default,
    be_verbose = false
  )
  case i
  when :default, 1
    i = 1 # :human
  end
  case be_verbose
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  when :be_verbose
    be_verbose = :be_verbose
  end
  if be_verbose
    e 'We will use this codon table next:'
    p use_this_codon_table
  end
  @codon_table_in_use = i
end

.set_default_colour(i) ⇒ Object

#

Bioroebe.set_default_colour

This is primarily used by the Bioroebe::Shell.

#


114
115
116
# File 'lib/bioroebe/colours/colours.rb', line 114

def self.set_default_colour(i)
  @default_colour = i
end

.set_log_directory(i = :default) ⇒ Object

#

Bioroebe.set_log_dir

This method will set the log-directory for the Bioroebe project.

Usually this will be in the user’s home directory, and then a ‘Bioroebe/’ suffix appended onto it. The default input-value is the symbol :default.

The user can set to use another log-directory through this method.

By default this method will append the name “bioroebe/” to the target directory, if :default is given as argument to this method - which is also the default argument, hence the name. If you do not want this behaviour then you have to call Bioroebe.set_base_directory() on your own by yourself, with the desired base directory to use.

#


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/bioroebe/log_directory/log_directory.rb', line 73

def self.set_log_directory(
    i = :default
  )
  # ======================================================================= #
  # We may need YAML support in this method.
  # ======================================================================= #
  require 'bioroebe/requires/require_yaml.rb'
  require 'bioroebe/project/project.rb'        # ← For Bioroebe.project_yaml_directory?
  require 'bioroebe/toplevel_methods/roebe.rb' # ← For Bioroebe.is_on_roebe?
  case i # case tag
  # ======================================================================= #
  # === :default
  #
  # This is the default value, aka the primary entry point into this
  # method.
  # ======================================================================= #
  when :default
    user_home_directory = user_home_directory?
    unless File.directory? user_home_directory
      # =================================================================== #
      # === Expand the file path
      #
      # Enter this clause for regular systems that do not have a
      # /Depot/Temp/ directory. Such systems will store output
      # into the home directory of the user.
      # =================================================================== #
      i = "#{File.expand_path('~')}/"
    end
    # ===================================================================== #
    # Query the default path to be used, as stored in the configuration
    # file.
    # ===================================================================== #
    file_temp_dir = "#{Bioroebe.project_yaml_directory?}configuration/temp_dir.yml"
    if File.exist?(file_temp_dir) and !File.empty?(file_temp_dir)
      i = YAML.load_file(file_temp_dir)
    else
      i = "#{user_home_directory}bioroebe/"
    end
    # ===================================================================== #
    # Modify the path a little on my home setup.
    # ===================================================================== #
    if is_on_roebe?
      i << 'bioroebe/' unless i.include? 'bioroebe'
    end
  end
  # ======================================================================= #
  # Keep a trailing '/' for this variable, at all times.
  # ======================================================================= #
  unless i.end_with? '/'
    i = i.dup if i.frozen?
    i << '/'
  end
  @log_directory = i
end

.set_pgpassword(new_password = Bioroebe::Postgresql::POSTGRE_PASSWORD) ⇒ Object

#

Bioroebe.set_pgpassword (password tag)

Set the password for Postgresql here. As input to this method you can pass the password for the postgreSQL database.

#


630
631
632
633
634
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 630

def self.set_pgpassword(
    new_password = Bioroebe::Postgresql::POSTGRE_PASSWORD
  )
  ENV['PGPASSWORD'] = new_password
end

.set_start_codon(i = 'ATG') ⇒ Object

#

Bioroebe.set_start_codon

This will designate the most important start codon.

#


36
37
38
39
40
# File 'lib/bioroebe/codons/start_codons.rb', line 36

def self.set_start_codon(
    i = 'ATG'
  )
  @start_codon = i
end

.set_start_codons(i = @start_codon) ⇒ Object

#

Bioroebe.set_start_codons

This method can be used to designate the start-codons.

It will be called automatically from code within codon_table.rb as well, so that we always have the corect start-codons ready for use.

#


51
52
53
54
55
56
57
58
59
# File 'lib/bioroebe/codons/start_codons.rb', line 51

def self.set_start_codons(
    i = @start_codon
  )
  if i.is_a? String and i.include? '|'
    i = i.split('|').map(&:strip)
  end
  i = [i].flatten # Will always be an Array.
  @start_codons = i
end

.set_stop_codons(*i) ⇒ Object

#

Bioroebe.set_stop_codons

#


263
264
265
266
# File 'lib/bioroebe/codons/codons.rb', line 263

def self.set_stop_codons(*i)
  i = [i].flatten.compact
  @stop_codons = i
end

.set_use_this_codon_table(i = :humans) ⇒ Object

#

Bioroebe.set_use_this_codon_table

This method combines three other methods - it will first set the codon table in use, and then load the codon table dataset at once and additionally determine the stop codons from the codon table.

It is the most complete method for properly using the correct codon table. I recommend that you use this method - it is more convenient than the other methods.

#


357
358
359
360
361
362
363
364
# File 'lib/bioroebe/codons/codon_table.rb', line 357

def self.set_use_this_codon_table(
    i = :humans
  )
  require 'bioroebe/codons/codons.rb'
  set_codon_table_in_use(i)
  load_the_codon_table_dataset(i)
  determine_stop_codons_from_the_codon_table
end

.set_use_this_yaml_engine=(i = :default) ⇒ Object

#

Bioroebe.use_which_yaml_engine?

Query method to determine which yaml engine is in use for the Bioroebe project.

#


47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bioroebe/requires/require_yaml.rb', line 47

def self.set_use_this_yaml_engine=(
    i = :default
  )
  case i # case tag
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    i = :psych
  end
  @use_this_yaml_engine = i
end

.sfancy(i = '') ⇒ Object

#

Bioroebe.sfancy

#


76
77
78
79
80
81
# File 'lib/bioroebe/colours/colours.rb', line 76

def self.sfancy(i = '')
  if @use_colours
    return Colours.sfancy(i)
  end
  return i
end

.sfile(i = '') ⇒ Object

#

Bioroebe.sfile

#


158
159
160
161
162
163
# File 'lib/bioroebe/colours/colours.rb', line 158

def self.sfile(i = '')
  if @use_colours
    return Colours.sfile(i)
  end
  return i
end

.shell(i = ARGV) ⇒ Object

#

Bioroebe.shell

This is the main method to instantiate the Shell component of the Bioroebe component.

#


11928
11929
11930
# File 'lib/bioroebe/shell/shell.rb', line 11928

def self.shell(i = ARGV)
  ::Bioroebe::Shell.new(i)
end

.show_aminoacids_mass_tableObject

#

Bioroebe.show_aminoacids_mass_table

#


112
113
114
# File 'lib/bioroebe/aminoacids/aminoacids_mass_table.rb', line 112

def self.show_aminoacids_mass_table
  Bioroebe::AminoacidsMassTable.show
end

.show_atomic_composition(of = 'GGGGA') ⇒ Object

#

Bioroebe.show_atomic_composition

This method will output the above.

Display style is similar to ExPASY output.

Atomic composition:

Carbon      C	        11
Hydrogen    H	        19
Nitrogen    N	         5
Oxygen      O	         6
Sulfur      S	         0
#


2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2229

def self.show_atomic_composition(
    of = 'GGGGA'
  )
  if of.is_a? Array
    of = of.join(' ').strip
  end
  padding_to_use = '  '
  hash = ::Bioroebe.atomic_composition(of)
  _ = ''.dup
  _ << "#{rev}Atomic composition of #{steelblue(of)}#{rev}:\n\n"
  n_atoms_in_total = hash.values.sum
  array = %w( C H N O S )
  array.each {|this_atom|
    case this_atom
    when 'C'
      _ << "#{padding_to_use}#{rev}Carbon    C  #{hash[this_atom].to_s.rjust(4)}\n"
    when 'H'
      _ << "#{padding_to_use}#{rev}Hydrogen  H  #{hash[this_atom].to_s.rjust(4)}\n"
    when 'N'
      _ << "#{padding_to_use}#{rev}Nitrogen  N  #{hash[this_atom].to_s.rjust(4)}\n"
    when 'O'
      _ << "#{padding_to_use}#{rev}Oxygen    O  #{hash[this_atom].to_s.rjust(4)}\n"
    when 'S'
      _ << "#{padding_to_use}#{rev}Sulfur    S  #{hash[this_atom].to_s.rjust(4)}\n"
    end
  }
  _ << "  "+("-" * 18)
  _ << "\n"
  _ << "  Total:          #{n_atoms_in_total}\n\n"
  puts _
end

.show_codon_tables(how = :headers) ⇒ Object

#

Bioroebe.show_codon_tables

Here, the default input argument is reversed.

#


117
118
119
# File 'lib/bioroebe/codons/show_codon_tables.rb', line 117

def self.show_codon_tables(how = :headers)
  ShowCodonTables.new(how)
end

.show_complementary_dna_strand(i = ARGV) ⇒ Object

#

Bioroebe.show_complementary_dna_strand

#


136
137
138
139
# File 'lib/bioroebe/nucleotides/complementary_dna_strand.rb', line 136

def self.show_complementary_dna_strand(i = ARGV)
  complementary_dna_strand = Bioroebe::ComplementaryDnaStrand.new(ARGV)
  complementary_dna_strand.report
end

.show_exon_statistics(these_files) ⇒ Object

#

Bioroebe.show_exon_statistics

This is mostly “throw-away” code; it will quickly tell us how many exons may span over some junction.

It was specifically created to analyze a .gtf file.

Invocation example:

bioroebe --show-exon-statistics-for=/tmp/praktikum/Mouse/chromosome_8/parsed/cdna.8.L100.global.gtf
#


460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 460

def self.show_exon_statistics(these_files)
  [these_files].flatten.compact.each {|this_file|
    if File.exist? this_file
      result = `cat #{this_file} | awk '{print $12}' | sort | uniq -c | sort -k1n | awk '{print $1}' | sort | uniq -c | less`
      e gold('        n exons')
      splitted = result.split("\n")
      # =================================================================== #
      # splitted may look like this:
      #
      #   ["  89839 1", "  26031 2", "   1136 3", "     24 4"]
      #
      # =================================================================== #
      splitted.each {|line|
        e line.sub(/( \d+)$/, gold('\1'))
      }
    else
      no_file_exists_at(this_file)
    end
  }
end

.show_fasta_header(of_this_file) ⇒ Object

#

Bioroebe.show_fasta_header

This ad-hoc method can be used to quickly show the first line of an assumed .fasta file.

#


326
327
328
329
330
331
332
333
# File 'lib/bioroebe/toplevel_methods/fasta_and_fastq.rb', line 326

def self.show_fasta_header(
    of_this_file
  )
  if of_this_file.is_a? Array
    of_this_file = of_this_file.first
  end
  e File.readlines(of_this_file).first
end

.show_fasta_statistics(i = ARGV) ⇒ Object

#

Bioroebe.show_fasta_statistics

#


180
181
182
# File 'lib/bioroebe/fasta_and_fastq/show_fasta_statistics.rb', line 180

def self.show_fasta_statistics(i = ARGV)
  ::Bioroebe::ShowFastaStatistics.new(i)
end

.show_n_glycosylation_motifs(from_this_file = 'foobar.fasta') ⇒ Object

#

Bioroebe.show_n_glycosylation_motifs

The argument to this method should be a local file, which stores the IDs of the proteins. Only use one ID per given line, though.

This method has been inspired by this Rosalind task:

http://rosalind.info/problems/mprt/
#


3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3468

def self.show_n_glycosylation_motifs(
    from_this_file = 'foobar.fasta'
  )
  require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
  if from_this_file.is_a? Array
    from_this_file = from_this_file.first
  end
  from_this_file = from_this_file.to_s
  if File.exist? from_this_file
    result = ''.dup
    dataset = File.readlines(from_this_file).reject {|entry| entry.strip.empty? }
    index = 0
    dataset.each {|this_id_for_the_protein| index += 1
      this_id_for_the_protein.strip!
      # =================================================================== #
      # Fetch the remote dataset from uniprot.
      # =================================================================== #
      e
      e royalblue(
          index.to_s.rjust(2)+') '
        )
      file_location         = ::Bioroebe.fetch_data_from_uniprot(this_id_for_the_protein)
      parsed_fasta_sequence = ::Bioroebe::ParseFasta.new(file_location) { :be_quiet }.first_value
      array_of_indices      = ::Bioroebe.determine_n_glycosylation_matches(parsed_fasta_sequence)
      # =================================================================== #
      # Next, this is the output that Rosalind wants to have.
      # =================================================================== #
      unless array_of_indices.empty?
        result << this_id_for_the_protein+"\n"
        result << array_of_indices.join(' ')+"\n"
      end
    }
    e result # And display that result finally.
  else
    no_file_exists_at(from_this_file)
  end
end

.show_restriction_enzymesObject

#

Bioroebe.show_restriction_enzymes

Use this method if you wish to show all restriction enzymes.

#


111
112
113
# File 'lib/bioroebe/enzymes/show_restriction_enzymes.rb', line 111

def self.show_restriction_enzymes
  ::Bioroebe::ShowRestrictionEnzymes.new # bl $BIOROEBE/show_restriction_enzymes.rb
end

.show_time_now(be_verbose = be_verbose? ) ⇒ Object

#

Bioroebe.show_time_now

This method will show the current time. It will do so only if the verbosity-variable has been set to true.

#


4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4948

def self.show_time_now(
    be_verbose = be_verbose?
  )
  require 'bioroebe/colours/colours.rb'
  @time = return_current_hours_minutes_seconds
  case be_verbose
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  when :be_verbose, true
    e "#{rev}Showing the current time: #{simp(@time)}"
  end
end

.showorf(i = ARGV) ⇒ Object

#

Bioroebe.showorf

#


874
875
876
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 874

def self.showorf(i = ARGV)
  Bioroebe::ShowOrf.new(i, :all_frames)
end

.shuffleseq(i = ARGV) ⇒ Object

#

Bioroebe.shuffleseq

This method simulates the Emboss shuffleseq-functionality. It will take the input string, such as an assumed DNA sequence, and simply re-arrange it as-is.

You can read this here:

https://www.bioinformatics.nl/cgi-bin/emboss/shuffleseq

Usage example:

Bioroebe.shuffleseq 'ATCGATCG' # => "AGTTACGC"
#


1242
1243
1244
1245
1246
1247
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1242

def self.shuffleseq(i = ARGV)
  if i.is_a? Array
    i = i.join(' ').strip
  end
  return i.chars.shuffle.join
end

.simp(i = '') ⇒ Object

#

Bioroebe.simp

#


148
149
150
151
152
153
# File 'lib/bioroebe/colours/colours.rb', line 148

def self.simp(i = '')
  if @use_colours
    return Colours.simp(i)
  end
  return i
end

.simplify_fasta_header(of_this_file = ARGV, &block) ⇒ Object

#

Bioroebe.simplify_fasta_header

#


78
79
80
81
82
83
# File 'lib/bioroebe/fasta_and_fastq/simplify_fasta_header/simplify_fasta_header.rb', line 78

def self.simplify_fasta_header(
    of_this_file = ARGV,
    &block
  )
  Bioroebe::SimplifyFastaHeader.new(of_this_file, &block)
end

.sizeseq(i) ⇒ Object

#

Bioroebe.sizeseq

This method will “size-sequence compare”, typically on a .fasta file.

#


1418
1419
1420
1421
1422
1423
1424
# File 'lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb', line 1418

def self.sizeseq(i)
  if i.is_a? Array
    i = i.first
  end
  _ = Bioroebe.parse_fasta(i) { :be_quiet }
  _.do_sort_by_size
end

.sort_aminoacid_based_on_its_hydrophobicity(i = 'FDMS') ⇒ Object

#

Bioroebe.sort_aminoacid_based_on_its_hydrophobicity

This method can sort aminoacids based on their hydrophobicity.

The input to this method MUST happen in the form of the one-aminoacid letter code, as the input will be upcased, as-is.

The preferred input “type” should be a String.

The output of this method will be a String, such as ‘D < F < P’ or something similar. This output is then already sorted by hydrophobicity, e. g. D being not as hydrophobic as F, and so forth.

This method was created primarily because of a Rosalind challenge, but the functionality seems sufficiently useful to retain in general, as it may be useful for other code elements.

Usage example:

Bioroebe.sort_aminoacid_based_on_its_hydrophobicity('TAMS')
Bioroebe.sort_aminoacid_based_on_its_hydrophobicity('TAMS') # => T < G < A
#


1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1348

def self.sort_aminoacid_based_on_its_hydrophobicity(
    i = 'FDMS'
  )
  dataset_from_the_hydropathy_table_file = YAML.load_file(
    FILE_HYDROPATHY_TABLE
  )
  i = i.first if i.is_a? Array
  i = 'FDMS' if i.nil?
  i = i.chars.uniq # Obtain the characters.
  hash = {}
  i.each {|entry|
    # ===================================================================== #
    # Find the entry in our main dataset next.
    # ===================================================================== #
    hash[entry] = dataset_from_the_hydropathy_table_file[entry]
  }
  sorted_hash = hash.sort_by {|key, hydrophobicity_value|
    hydrophobicity_value
  }
  # ======================================================================= #
  # We will return a String as a result.
  # ======================================================================= #
  result = ''.dup
  sorted_hash.each {|a,b|
    result << "#{a} < "
  }
  result.strip!
  result.chop! if result.end_with? '<'
  result.strip!
  return result
end

.start_codon?Boolean

#

Bioroebe.start_codon?

#

Returns:

  • (Boolean)


27
28
29
# File 'lib/bioroebe/codons/start_codons.rb', line 27

def self.start_codon?
  @start_codon
end

.start_codons?Boolean

#

Bioroebe.start_codons?

#

Returns:

  • (Boolean)


69
70
71
# File 'lib/bioroebe/codons/start_codons.rb', line 69

def self.start_codons?
  @start_codons
end

.start_sinatra_interfaceObject

#

Bioroebe::SinatraWrapper.start_sinatra_interface

This method can be used to start the sinatra interface.

#


1091
1092
1093
1094
1095
1096
1097
1098
1099
# File 'lib/bioroebe/sinatra/sinatra_wrapper.rb', line 1091

def self.start_sinatra_interface
  erev 'Trying to start the sinatra-interface of Bioroebe next.'
  e
  erev 'This should use the following URL:'
  e
  erev "  #{sfancy(Bioroebe::EmbeddableInterface.localhost_to_use?)}"
  e
  ::Bioroebe::SinatraWrapper.run!
end

.stop_codons?Boolean

#

Bioroebe.stop_codons?

This method will return the three regular stop codons that can be “found” in DNA.

Usually, the Stop Codons will be saved in DNA-form simply because the yaml files that keep the codon tables also use DNA.

This method will return the Stop Codons that are valid for the respective organism at hand (if you selected the right codon table before).

The default codon table in use will be for humans (mammals rather), which is valid for most eukaryotes as well.

#

Returns:

  • (Boolean)


205
206
207
# File 'lib/bioroebe/codons/codons.rb', line 205

def self.stop_codons?
  @stop_codons
end

.strict_filter_away_invalid_aminoacids(i = :default) ⇒ Object

#

Bioroebe.strict_filter_away_invalid_aminoacids

This method, named ‘Bioroebe.strict_filter_away_invalid_aminoacids()`, is a strict filter for aminoacids. That is, if an invalid aminoacid is passed to this method, that aminoacid will simply be discarded.

Only 20 aminoacids are valid, in regards to this filter here - the canonical aminoacids.

The following behaviour is valid for this method:

  • Any String passed into this method will be converted to an Array.

  • Any Array passed into this method will be turned into an Array“ of Strings” if it contains at the least one String.

Note that this method will return an Array as a result. This Array will retain only valid aminoacids (e. g. from the 20 that are possible).

Usage example:

Bioroebe.strict_filter_away_invalid_aminoacids('ABCDEFGHIJKLMNOPQRSTUVWXYZ') # => 'ACDEFGHIKLMNOPQRSTUVWY'
#


1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1854

def self.strict_filter_away_invalid_aminoacids(
    i = :default
  )
  case i
  when :default
    # Assign a default in this case.
    i = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  # In the past, the above entry also handled nil, '',
  # but I realized that this makes no sense, so it was
  # disabled as of 06.12.2020.
  end
  if i.is_a? String
    i = i.chars
  elsif i.is_a?(Array) and i.first.is_a?(String)
    i = i.first.chars
  end
  # ======================================================================= #
  # We should now have an Array, hopefully. Next we can apply a filter on
  # that Array.
  # ======================================================================= #
  valid_aminoacids = AMINO_ACIDS.keys
  i.select! {|this_aminoacid|
    valid_aminoacids.include? this_aminoacid
  }
  if i.is_a? Array
    i = i.join
  end
  i
end

.sum_of_odd_integers(starting_point = 100, end_point = 200) ⇒ Object

#

Bioroebe.sum_of_odd_integers

This method was primarily written to solve a specific problem at Rosalind.

This method will probably not be hugely important for every-day tasks, but I will leave it here nonetheless in the event that others want to solve problems at Rosalind and may find this method useful.

The method will calculate the “sum of odd integers”. A local file can be provided - see the code at File.read() in the method. For more use cases, see the end of this .rb file.

#


3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3731

def self.sum_of_odd_integers(
    starting_point = 100,
    end_point      = 200
  )
  if starting_point and File.file?(starting_point)
    case end_point
    # ===================================================================== #
    # === :default
    # ===================================================================== #
    when :default,
         nil
      dataset = File.read(starting_point).strip
      splitted = dataset.split(' ')
      starting_point = splitted.first
      end_point      = splitted.last
    end
  end
  result = 0
  # ======================================================================= #
  # We need our start and end point to be Integers past this point:
  # ======================================================================= #
  starting_point = starting_point.to_i
  end_point      = end_point.to_i
  (starting_point .. end_point).each {|number|
    result += number if number.odd?
  }
  result
end

.swarn(i = '', use_colours = @use_colours) ⇒ Object

#

Bioroebe.swarn

#


210
211
212
213
214
215
# File 'lib/bioroebe/colours/colours.rb', line 210

def self.swarn(
    i = '', use_colours = @use_colours
  )
  return Colours.swarn(i) if use_colours
  return i
end

.taxonomy_directory?Boolean

#

Bioroebe.taxonomy_directory?

#

Returns:

  • (Boolean)


16
17
18
# File 'lib/bioroebe/requires/require_all_taxonomy_files.rb', line 16

def self.taxonomy_directory?
  "#{project_base_dir?}taxonomy/"
end

.taxonomy_download_directory?Boolean

#

Bioroebe.taxonomy_download_directory?

#

Returns:

  • (Boolean)


171
172
173
# File 'lib/bioroebe/toplevel_methods/taxonomy.rb', line 171

def self.taxonomy_download_directory?
  ::Bioroebe::Taxonomy.taxonomy_download_directory?
end

.taxonomy_ncbi_database_last_update_log_fileObject

#

Bioroebe.taxonomy_ncbi_database_last_update_log_file

This constant is used specifically for the taxonomy-component of the Bioroebe project.

#


282
283
284
# File 'lib/bioroebe/constants/constants.rb', line 282

def self.taxonomy_ncbi_database_last_update_log_file
  "#{::Bioroebe.log_dir?}taxonomy_ncbi_database_last_update.log"
end

.this_aminoacid_has_n_codons(i) ⇒ Object

#

Bioroebe.this_aminoacid_has_n_codons

This method must return a Number at all times, either 0, or any other positive number. 0 will be returned if the aminoacid at hand does not exist as well, so it should be ensure that the aminoacid exists.

Otherwise the number will be a positive integer, showing how many codons this aminoacid has.

Since 22.03.2020 the method will also honour the specified codon-table.

#


281
282
283
284
285
286
287
288
289
290
# File 'lib/bioroebe/codons/codons.rb', line 281

def self.this_aminoacid_has_n_codons(i)
  if i.is_a? Array
    i.map {|entry| this_aminoacid_has_n_codons(entry) }.sum # Recursive call.
  else
    result = 0
    array = codons_for_this_aminoacid?(i)
    result += array.size if array
    return result
  end
end

.this_nucleotide_pairs_with?(i) ⇒ Boolean

#

Bioroebe.this_nucleotide_pairs_with?

#

Returns:

  • (Boolean)


485
486
487
# File 'lib/bioroebe/constants/constants.rb', line 485

def self.this_nucleotide_pairs_with?(i)
  HASH_DNA_NUCLEOTIDES[i.to_s.upcase]
end

.thousand_percentage(this_codon_n_times = 1, total_n_elements = 1000) ⇒ Object

#

Bioroebe.thousand_percentage

This method is solely a helper-method for Bioroebe.frequency_per_thousand().

#


941
942
943
944
945
946
947
948
949
950
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 941

def self.thousand_percentage(
    this_codon_n_times =   1,
    total_n_elements  = 1000
  )
  result = (
    (this_codon_n_times * 1000.0) / total_n_elements.to_f
  ).round(1)
  padded_result = result.to_s.rjust(5, ' ')
  return padded_result
end

.three_delimiter(array) ⇒ Object

#

Bioroebe.three_delimiter

This method will, applied onto an Array of Strings, add the ‘|’ token after 3 positions.

The argument to this method should be an Array.

Example:

Bioroebe.three_delimiter('ATGGGGATGTAGGTA','ATGTAGGTA') # => ["ATG|GGG|ATG|TAG|GTA", "ATG|TAG|GTA"]
#


399
400
401
402
403
404
405
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 399

def self.three_delimiter(array)
  array.flatten.map {|entry|
    splitted = entry.scan(/.../)
    entry = splitted.join('|')
    entry
  } 
end

.three_to_one(i) ⇒ Object

#

Bioroebe.three_to_one

This method will convert from e. g. “THR” to “T” - aka from a three letter input, towards the one-letter abbreviation for the aminoacid threonine.

That way this method acts as the sister method to the other method that gives us three letters from ONE letter, sort of. Taken together, these two methods form a corresponding dual-pair there, yin/yang, from 3-to-1 and from 1-to-3.

Behaviour of this method:

This method will translate "Lys" into "L", and the other
corresponding aminoacids into their one-letter abbreviation.

The input to this method should be a String.

The output will not contain any ‘-’ character by default, even if the input came with ‘-’ characters. The reason why this is the default is because the most common use cases may wish to continue to work with the one-letter abbreviation instead, which is much more common than the three-letter abbreviation.

#


339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 339

def self.three_to_one(i)
  _ = ''.dup
  if i
    if i.is_a? Array
      i = i.join
    end
    if i =~ /gui/i
      require 'bioroebe/gui/gtk3/three_to_one/three_to_one.rb'
      Bioroebe::GUI::Gtk::ThreeToOne.run # three_to_one --gui
      return
    end
    if i.include? '-'
      i = i.dup if i.frozen?
      i.delete!('-')
    end
    dataset = AMINO_ACIDS_THREE_TO_ONE
    # ===================================================================== #
    # The table keeps the members in a downcase variant, hence why we
    # also apply .downcase next. The above dataset will keep the hash
    # keys in a downcased variant as-is.
    # ===================================================================== #
    scanned = i.scan(/.../).map(&:downcase)
    scanned.each {|key|
      if dataset.has_key? key
        match = dataset[key]
        _ << match
      end
    }
  end
  return _
end

.to_aminoacids(i, &block) ⇒ Object

#

Bioroebe.to_aminoacids

This method can be used to convert a String such as ‘ATG’ into the corresponding aminoacid sequence - in this example, the String ‘M’.

Invocation examples:

Bioroebe.to_aminoacids 'AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA' # => "MAMAPRTEINSTRING"
Bioroebe.to_aminoacids '/rosalind_prot.txt' # => "MAMAPRTEINSTRING"
#


175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/bioroebe/sequence/dna.rb', line 175

def self.to_aminoacids(i, &block)
  if i and File.file?(i)
    i = File.read(i).strip
  end
  result = ::Bioroebe::DNA.new.to_aminoacids(i, &block)
  if i.is_a?(String) and !result.is_a?(String)
    # ======================================================================= #
    # If the user did input a String, then we must make sure that the
    # returned value will also be a String.
    # ======================================================================= #
    result = result.join(' ').strip
  end
  result
end

.to_camelcase(i) ⇒ Object

#

Bioroebe.to_camelcase

Convert the given String (the input) into a camelcased variant.

Usage example:

Bioroebe.to_camelcase('foo_bar') # => "FooBar"
#


307
308
309
310
311
312
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 307

def self.to_camelcase(i)
  if i.is_a? Array
    i = i.first
  end
  i.split('_').map {|entry| entry.capitalize }.join
end

.to_dna(i = nil, upcase_me = true) ⇒ Object

#

Bioroebe.to_dna

This method will essentially replace all “U” with “T”, from the given input argument (which can be a String or an Array).

To test this method, do:

Bioroebe.to_dna 'ACCACACCAUUUCCCAUGGGUGUGUGG' # => "ACCACACCATTTCCCATGGGTGTGTGG"
#


4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4645

def self.to_dna(
    i         = nil,
    upcase_me = true
  )
  i = i.first if i.is_a? Array
  i = i.to_s
  i = filter_away_invalid_nucleotides(i, :preserve_uracil) # A module-method.
  i = i.upcase if upcase_me
  if upcase_me # Sanitize all U into T.
    i.tr!('U','T')
  else
    i.tr!('u','t')
  end
  return i
end

.to_rna(i = nil, upcase_me = true) ⇒ Object

#

Bioroebe.to_rna

This method will convert DNA into RNA. See the usage example below for a bit more details.

Usage example:

Bioroebe.to_rna 'ATGACCG' # => "AUGACCG"
#


4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4538

def self.to_rna(
    i         = nil,
    upcase_me = true
  )
  i = i.first if i.is_a? Array
  i = i.to_s
  i = i.dup if i.frozen?
  if i and File.exist?(i) and i.include?('.') # Assume input such as 'foobar.md'.
    i = File.read(i)
  end
  i.gsub!(/T/,'U')
  return i
end

.to_utf(i) ⇒ Object

#

Bioroebe.to_utf

This method will convert from ISO-8859-1 to UTF-8 (Unicode) encoding.

It was created in the year 2015, but it is no longer that important, simply because all .rb files in this project now make use of UTF-8 encoding by default. Since some code in the taxonomy-submodule of the bioroebe gem may still use this method, the code is retained.

Do not expect to see much use of it outside of the taxonomy submodule, though.

#


32
33
34
35
36
37
38
39
# File 'lib/bioroebe/encoding/encoding.rb', line 32

def self.to_utf(i)
  return i.encode(
    'iso-8859-1',
    'UTF-8',
    invalid: :replace,
    undef:   :replace
  ).force_encoding('utf-8')
end

.trailing_three_prime(i = '', get_rid_of_spaces = false, use_hyphen = true) ⇒ Object

#

Bioroebe.trailing_three_prime

This method will output the trailing 3’ part, like a header (or rather, a trailer).

#


4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4603

def self.trailing_three_prime(
    i                 = '', # The default to '' is important.
    get_rid_of_spaces = false,
    use_hyphen        = true
  )
  case get_rid_of_spaces
  # ======================================================================= #
  # === :no_spaces
  # ======================================================================= #
  when :no_spaces,
       :get_rid_of_spaces,
       :eliminate_spaces
    get_rid_of_spaces = true
  end
  if i.is_a? Array
    i = i.join.strip
  end
  if use_hyphen
    _ = "#{i} - 3'" # ← This here is the header-tag.
  else # This variant is a bit simpler and shorter.
    _ = "#{i} 3'"   # ← This here is the header-tag.
  end
  _.delete!(' ') if get_rid_of_spaces
  return _
end

.transitions_to_transversions_ratio(string1, string2 = nil, round_to_n_positions = 11) ⇒ Object

#

Bioroebe.transitions_to_transversions_ratio

This method will calculate the transition-to-transversion ratio between two Strings of equal length.

The second argument, called ‘string2`, can be nil, in which case we may re-set it to a value if the input to string1 is a file. The reason for this is that we may want to read both string1 and string2 from a file, if available. If it is a file then it is typically assumed to be a FASTA (.fasta or .fa) file. See the following usage examples for this.

Usage examples:

dataset = Bioroebe.transitions_to_transversions_ratio('/XXX.txt')
dataset = Bioroebe.transitions_to_transversions_ratio('/TRANSITIONS.txt')
#


2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2633

def self.transitions_to_transversions_ratio(
    string1, string2 = nil, round_to_n_positions = 11
  )
  if File.file? string1
    # ===================================================================== #
    # We can read in fasta-data here.
    # ===================================================================== #
    require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
    dataset = ::Bioroebe::ParseFasta.new(string1) { :be_quiet }.values
    if dataset.size > 1
      string1 = dataset[0]
      string2 = dataset[1]
    end
  end
  n_transitions = n_transitions(string1, string2).to_f
  ratio = ( n_transitions / n_transversions(string1, string2).to_f )
  return ratio.to_f.round(round_to_n_positions)
end

.translate_all_three_frames(i) ⇒ Object

#

Bioroebe.translate_all_three_frames

#


661
662
663
664
665
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 661

def self.translate_all_three_frames(i)
  ::Bioroebe::DnaToAminoacidSequence.new(i) { :be_verbose }
  ::Bioroebe::DnaToAminoacidSequence.new(i, :frame_two) { :be_verbose }
  ::Bioroebe::DnaToAminoacidSequence.new(i, :frame_three) { :be_verbose }
end

.truncate?Boolean

#

Bioroebe.truncate?

#

Returns:

  • (Boolean)


129
130
131
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 129

def self.truncate?
  @truncate
end

.try_to_pass_through_beautiful_url(i) ⇒ Object

#

Bioroebe.try_to_pass_through_beautiful_url

Simply pass through BeautifulUrl. If the input is registered then this method will return the remote or local file that is “pointed at” by the given input. Basically this is a shortcut: we input a few characters, and get back the full length, a bit similar to how tinyurl used to work.

#


3873
3874
3875
3876
3877
3878
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3873

def self.try_to_pass_through_beautiful_url(i)
  i = i.first if i.is_a? Array
  i = BeautifulUrl[i] if Object.const_defined? :BeautifulUrl
  i = i.first if i.is_a? Array
  return i
end

.try_to_rename_kde_konsole?Boolean

#

Bioroebe.try_to_rename_kde_konsole?

#

Returns:

  • (Boolean)


105
106
107
# File 'lib/bioroebe/configuration/configuration.rb', line 105

def self.try_to_rename_kde_konsole?
  ::Bioroebe::Configuration::TRY_TO_RENAME_KDE_KONSOLE
end

.two_dimensional_plot(dataset = '6 12 8 14 10 18 12 23 14 28 16 29 18 26 20 23 22 20', optional_hash = { width: 800, height: 640 }) ⇒ Object

#

Bioroebe.two_dimensional_plot

This method makes use of gnuplot to draw a 2D plot.

The first argument should contain your dataset, as a String.

#


2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2933

def self.two_dimensional_plot(
    dataset =  '6 12
8 14
10 18
12 23
14 28
16 29
18 26
20 23
22 20',
    optional_hash = {
      width:    800,
      height:   640
    }
  )
  # ======================================================================= #
  # Provide some generic fall-back values for width and height next:
  # ======================================================================= #
  width  = 1000
  height =  800
  _ = optional_hash
  if _.is_a? Hash
    # ===================================================================== #
    # === :width
    # ===================================================================== #
    if _.has_key? :width
      width = _.delete(:width)
    end
    # ===================================================================== #
    # === :height
    # ===================================================================== #
    if _.has_key? :height
      height = _.delete(:height)
    end
  end
  # ======================================================================= #
  # Go to a safe base directory.
  # ======================================================================= #
  cd :bioroebe_log_directory
  mkdir 'gnuplot' unless File.directory?('gnuplot')
  cd 'gnuplot'
  # ======================================================================= #
  # First save the dataset into dataset.md:
  # ======================================================================= #
  into = File.absolute_path('dataset.md')
  e 'Storing the dataset into '+sfile(into)+' next.'
  write_what_into(dataset, into)
  what = <<-EOF

set terminal png size #{width},#{height} enhanced font "Helvetica, 18"
set output 'fancy_graph.png'
plot '#{into}' with linespoints ls 1 notitle

EOF
  into = File.absolute_path('gnuplot.file')
  e 'Storing into '+into+'.'
  write_what_into(what, into)
  esystem 'gnuplot '+into
  if File.exist? 'fancy_graph.png' and is_on_roebe?
    Open.in_browser('fancy_graph.png')
  end
end

.unique_two_paired_permutations(array = %w( B E G I K L P S )) ⇒ Object

#

Bioroebe.unique_two_paired_permutations

This method will return all unique permutations of a given Array.

The method will return an Array of all possible, unique combinations, as a pair of two entries per inner array.

Invocation example:

Bioroebe.unique_two_paired_permutations # Would yield an Array of 28 members.
#


131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/bioroebe/utility_scripts/permutations/permutations.rb', line 131

def self.unique_two_paired_permutations(
    array = %w( B E G I K L P S )
  )
  # ========================================================================= #
  # Example: ["B", "E", "G", "I", "K", "L", "P", "S"]
  # ========================================================================= #
  all_permutations = array.permutation(2).to_a
  all_unique_permutations = []
  all_permutations.each {|this_array|
    all_unique_permutations << this_array unless all_unique_permutations.include?(this_array.reverse)
  }
  return all_unique_permutations
end

.upcase_this_aminoacid_sequence_and_remove_numbers(i = '1 msasasacdc lvgvptgptl astcggsafm lfmgllevfi rsqcdledpc grassrfrse 61 pdyeydfivi gggsagsvva srlsevpqwk vllieaggde pvgaqipsmf lnfigsdidy') ⇒ Object

#

Bioroebe.upcase_this_aminoacid_sequence_and_remove_numbers

This method can be used to remove numbers, upcase all entries and delete all ‘ ’ characters and newlines. It is mostly a “sanitize” method.

Invocation example:

Bioroebe.upcase_this_aminoacid_sequence_and_remove_numbers # => "MSASASA" (etc..)
#


1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1937

def self.upcase_this_aminoacid_sequence_and_remove_numbers(
    i = '1 msasasacdc lvgvptgptl astcggsafm lfmgllevfi rsqcdledpc grassrfrse
        61 pdyeydfivi gggsagsvva srlsevpqwk vllieaggde pvgaqipsmf lnfigsdidy'
  )
  if i.is_a? Array
    i = i.join(' ').strip
  end
  i = i.dup if i.frozen?
  i = i.delete(' ').delete("\n").gsub(/\d+/,'').strip.upcase
  e i
end

.upload_this_pdf_file(i) ⇒ Object

#

Bioroebe.upload_this_pdf_file

#


11911
11912
11913
# File 'lib/bioroebe/shell/shell.rb', line 11911

def self.upload_this_pdf_file(i)
  ::Bioroebe::Shell.upload_this_pdf_file(i)
end

.use_colours?Boolean

#

Bioroebe.use_colours?

Query-method to determine whether the Bioroebe gem will try to make use of colours.

#

Returns:

  • (Boolean)


23
24
25
# File 'lib/bioroebe/colours/use_colours.rb', line 23

def self.use_colours?
  @use_colours
end

.use_opn?Boolean

#

Bioroebe.use_opn?

This is the toplevel-method that should be used, ideally, for determining whether opn will be used for the bioroebe project.

#

Returns:

  • (Boolean)


98
99
100
# File 'lib/bioroebe/configuration/configuration.rb', line 98

def self.use_opn?
  ::Bioroebe::Configuration.use_opn?
end

.use_this_codon_table(i) ⇒ Object

#

Bioroebe.use_this_codon_table

This method combines setting a specific codon-table in use, and it will also load the dataset of that codon table.

Usage example:

Bioroebe.use_this_codon_table(:yeast_mitochondria)
#


340
341
342
343
# File 'lib/bioroebe/codons/codon_table.rb', line 340

def self.use_this_codon_table(i)
  set_codon_table_in_use(i)
  load_the_codon_table_dataset
end

.use_which_yaml_engine?Boolean

#

Bioroebe.use_which_yaml_engine?

Query-method to find out which yaml-engine is used for the BioRoebe project.

#

Returns:

  • (Boolean)


37
38
39
# File 'lib/bioroebe/requires/require_yaml.rb', line 37

def self.use_which_yaml_engine?
  @use_this_yaml_engine
end

.user_home_directory?Boolean

#

Bioroebe.user_home_directory?

This method will either refer to the home directory of the user at hand, or, if unavailable, simply refer to ‘/tmp/’ as hardcoded target.

The main assumption here is that the home directory is writable and readable for the user, by default.

#

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bioroebe/log_directory/log_directory.rb', line 18

def self.user_home_directory?
  begin
    # ===================================================================== #
    # Expand to find the proper directory.
    # ===================================================================== #
    return "#{File.expand_path('~')}/"
  rescue ArgumentError
    # ===================================================================== #
    # Rescued in .cgi environments, where it will default to /tmp/.
    # ===================================================================== #
    return '/tmp/'
  end
end

.version?Boolean

#

Bioroebe.version?

#

Returns:

  • (Boolean)


40
41
42
# File 'lib/bioroebe/version/version.rb', line 40

def self.version?
  ::Bioroebe::VERSION
end

.weight_of_these_aminoacids?(i, optional_round_to = nil) ⇒ Boolean

#

Bioroebe.weight_of_these_aminoacids?

The second argument allows you to specify whether you wish to round the result. By default no rounding will be performed.

Usage example:

Bioroebe.weight_of_these_aminoacids? 'SKADYEK'
Bioroebe.weight_of_these_aminoacids? 'SKADYEK',3
Bioroebe.weight_of_these_aminoacids? '/ABC.md'
#

Returns:

  • (Boolean)


350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/bioroebe/sequence/protein.rb', line 350

def self.weight_of_these_aminoacids?(
    i, optional_round_to = nil
  )
  if i and File.file?(i)
    i = File.read(i).strip
  end
  result = ::Bioroebe::Protein.new(i).weight?
  if optional_round_to
    result = result.round(optional_round_to)
  end
  result
end

.weight_of_this_aminoacid?(i, use_this_dataset = nil) ⇒ Boolean

#

Bioroebe.weight_of_this_aminoacid?

This method will return the weight of an aminoacid (that is bound in a protein, thus having a H2O group less than normally in total).

#

Returns:

  • (Boolean)


1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1154

def self.weight_of_this_aminoacid?(
    i, use_this_dataset = nil
  )
  if use_this_dataset.nil?
    use_this_dataset = YAML.load_file(FILE_AMINO_ACIDS_MASS_TABLE)
  end
  if i.is_a? Array
    i.map {|entry|
      result = weight_of_this_aminoacid?(entry, use_this_dataset)
      if result.nil?
        erev 'A nil value happened for '+steelblue(entry)+rev+
          '. Check file '+sfile(FILE_AMINO_ACIDS_MASS_TABLE)
      end
      result
    }.compact.sum
  else
    use_this_dataset[i]
  end
end

.wget_download(target) ⇒ Object

#

Bioroebe.wget_download

This variant will always use “wget” - hence the name.

#


4385
4386
4387
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4385

def self.wget_download(target)
  esystem "wget #{target}"
end

.windows_platform?Boolean

#

Bioroebe.windows_platform?

#

Returns:

  • (Boolean)


2916
2917
2918
2919
2920
2921
2922
2923
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 2916

def self.windows_platform?
  case RUBY_PLATFORM
  when /(?:mswin|bccwin|mingw|windows)(?:32|64)/i
    true
  else
    false
  end
end

.write_what_into(what = 'Hello world!', into = 'test.md') ⇒ Object

#

Bioroebe.write_what_into

This method will simply write the content of the variable ‘what` into the file called `into`.

#


4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 4145

def self.write_what_into(
    what = 'Hello world!',
    into = 'test.md'
  )
  base_directory = File.dirname(into)
  if File.directory? base_directory
    File.open(into, 'w') { |file|
      file << what
    }
  else
    e "No directory exists at #{base_directory}. Thus, "\
      "no file could be saved."
  end
end

Instance Method Details

#all_aminoacids?Boolean

#

all_aminoacids?

#

Returns:

  • (Boolean)


182
183
184
# File 'lib/bioroebe/constants/constants.rb', line 182

def all_aminoacids?
  ::Bioroebe.all_aminoacids?
end

#cat(i) ⇒ Object

#

cat

#


5072
5073
5074
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 5072

def cat(i)
  ::Bioroebe.cat(i)
end

#default_colour?Boolean Also known as: main_colour, main_col

#

default_colour?

#

Returns:

  • (Boolean)


104
105
106
# File 'lib/bioroebe/colours/colours.rb', line 104

def default_colour?
  ::Bioroebe.default_colour?
end

#ecomment(i) ⇒ Object

#

ecomment

#


175
176
177
178
# File 'lib/bioroebe/colours/colours.rb', line 175

def ecomment(i)
  return Colours.ecomment(i) if use_colours_in_general?
  return i
end

#file_restriction_enzymesObject

#

file_restriction_enzymes

#


892
893
894
# File 'lib/bioroebe/constants/constants.rb', line 892

def file_restriction_enzymes
  ::Bioroebe.file_restriction_enzymes
end

#is_on_roebe?Boolean Also known as: roebe?, on_roebe?, is_roebe?

#

on_roebe?

Whether I am at home or whether I am not.

#

Returns:

  • (Boolean)


23
24
25
# File 'lib/bioroebe/toplevel_methods/roebe.rb', line 23

def is_on_roebe?
  Bioroebe.is_on_roebe?
end

#mkdir(i) ⇒ Object

#

mkdir

#


3310
3311
3312
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 3310

def mkdir(i)
  ::Bioroebe.mkdir(i)
end

#pwdObject

#

pwd

#


1110
1111
1112
# File 'lib/bioroebe/toplevel_methods/toplevel_methods.rb', line 1110

def pwd
  ::Bioroebe.pwd
end

#revObject

#

rev

Delegate towards Bioroebe.rev() there.

#


62
63
64
# File 'lib/bioroebe/colours/colours.rb', line 62

def rev
  ::Bioroebe.rev
end

#Sequence(i) ⇒ Object Also known as: Seq

#

Sequence()

Note that Seq() also works, as an alias to this method.

Invocation example:

require 'bioroebe'; include Bioroebe; x = Seq('ATCGTCGGAATAG')
#


701
702
703
# File 'lib/bioroebe/sequence/sequence.rb', line 701

def Sequence(i)
  Bioroebe::Sequence.new(i)
end

#use_colours_in_general?Boolean

#

use_colours_in_general?

#

Returns:

  • (Boolean)


121
122
123
# File 'lib/bioroebe/colours/colours.rb', line 121

def use_colours_in_general?
  ::Bioroebe.use_colours?
end