Utils
MIToS.Utils
— ModuleThe Utils
has common utils functions and types used in other modules.
using MIToS.Utils
Contents
Types
MIToS.Utils.All
— TypeAll is used instead of MIToS 1.0 "all" or "*", because it's possible to dispatch on it.
MIToS.Utils.FileFormat
— TypeFileFormat
is used for defile special parse_file
(called by read_file
) and print_file
(called by read_file
) methods for different file formats.
Constants
MIToS.Utils.THREE2ONE
— ConstantTHREE2ONE
is a dictionary that maps three-letter amino acid residue codes (String
) to their corresponding one-letter codes (Char
). The dictionary is generated by parsing components.cif
file from the Protein Data Bank.
julia> using MIToS.Utils
julia> one_letter_code = THREE2ONE["ALA"]
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
Macros
Methods and functions
MIToS.Utils.check_file
— MethodReturns the filename
. Throws an ErrorException
if the file doesn't exist, or a warning if the file is empty.
MIToS.Utils.check_pdbcode
— MethodIt checks if a PDB code has the correct format.
MIToS.Utils.download_file
— Methoddownload_file
uses Downloads.jl to download files from the web. It takes the file url as first argument and, optionally, a path to save it. Keyword arguments are are directly passed to to Downloads.download
.
julia> using MIToS.Utils
julia> download_file("https://www.uniprot.org/uniprot/P69905.fasta", "seq.fasta")
"seq.fasta"
MIToS.Utils.get_n_words
— Methodget_n_words{T <: Union{ASCIIString, UTF8String}}(line::T, n::Int)
It returns a Vector{T}
with the first n
(possibles) words/fields (delimited by space or tab). If there is more than n
words, the last word returned contains the finals words and the delimiters. The length of the returned vector is n
or less (if the number of words is less than n
). This is used for parsing the Stockholm format.
julia> using MIToS.Utils
julia> get_n_words("#=GR O31698/18-71 SS CCCHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEHHH", 3)
3-element Vector{String}:
"#=GR"
"O31698/18-71"
"SS CCCHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEHHH"
MIToS.Utils.getarray
— MethodGetter for the array
field of NamedArray
s
MIToS.Utils.hascoordinates
— Methodhascoordinates(id)
It returns true
if id
/sequence name has the format: UniProt/start-end (i.e. O83071/192-246)
MIToS.Utils.isnotemptyfile
— MethodReturns true
if the file exists and isn't empty.
MIToS.Utils.lineiterator
— MethodCreate an iterable object that will yield each line from a stream or string.
MIToS.Utils.list2matrix
— MethodReturns a square symmetric matrix from the vector vec
. side
is the number of rows/columns. The diagonal
is not included by default, set to true
if there are diagonal elements in the list.
MIToS.Utils.matrix2list
— MethodReturns a vector with the part
("upper" or "lower") of the square matrix mat
. The diagonal
is not included by default.
MIToS.Utils.read_file
— Methodread_file(pathname, FileFormat [, Type [, … ] ] ) -> Type
This function opens a file in the pathname
and calls parse_file(io, ...)
for the given FileFormat
and Type
on it. If the pathname
is an HTTP or FTP URL, the file is downloaded with download
in a temporal file. Gzipped files should end on .gz
.
MIToS.Utils.select_element
— MethodSelects the first element of the vector. This is useful for unpacking one element vectors. Throws a warning if there are more elements. element_name
is element by default, but the name can be changed using the second argument.
MIToS.Utils.write_file
— Methodwrite_file{T<:FileFormat}(filename::AbstractString, object, format::Type{T}, mode::ASCIIString="w")
This function opens a file with filename
and mode
(default: "w") and writes (print_file
) the object
with the given format
. Gzipped files should end on .gz
.