1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 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 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 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 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 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 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 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
|
# Copyright (c) 2006, The Regents of the University of California, through
# Lawrence Berkeley National Laboratory (subject to receipt of any required
# approvals from the U.S. Dept. of Energy). All rights reserved.
# This software is distributed under the new BSD Open Source License.
# <http://www.opensource.org/licenses/bsd-license.html>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# (2) Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and or other materials provided with the distribution.
#
# (3) Neither the name of the University of California, Lawrence Berkeley
# National Laboratory, U.S. Dept. of Energy nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""
Standard data used in computational biology.
To convert a property dictionary to a list :
>>> comp = [ amino_acid_composition[k] for k in amino_acid_letters]
Resources:
Various standard data files are included in the weblogo distribution. These
may be loaded with the data_string, data_stream or data_filename methods.
A complete set of names is stored in 'resource_names'
BLOSUM Scoring Matrices
Source: ftp://ftp.ncbi.nih.gov/repository/blocks/unix/blosum
These are all new blast style with 1/3 bit scaling
- blosum35
- blosum45
- blosum62
- blosum40
- blosum50
- blosum80
- blosum100
Other substitution scoring matrices:
- dist20_comp
- pam250
- pam120
- vtml160
Description of database cross references :
- dbxref.txt (http://www.expasy.org/cgi-bin/lists?dbxref.txt)
Attributes:
- amino_acid_letters
-- Standard codes for the 20 canonical amino acids, in alphabetic
order.
- amino_acid_alternative_letters
-- Amino acid one letter codes, alphabetic by three letter codes.
- amino_acid_extended_letters
- dna_letters
- dna_extended_letters
- rna_letters
- rna_extended_letters
- dna_ambiguity
- rna_ambiguity
- amino_acid_ambiguity
- amino_acid_mass
-- Monomer isotopically averaged molecular mass
- dna_mass
- rna_mass
- one_to_three
-- Map from standard 1 letter amino acid codes to standard three
letter codes.
Ref: http://www.ebi.ac.uk/RESID/faq.html
- standard_three_to_one
-- Map from standard 3 letter amino acid codes to standard 1
letter codes.
- extended_three_to_one
-- Map between three letter amino acid codes (first letter capitalized)
and standard one letter codes. This map contains many nonstandard three
letter codes, used, for example, to specify chemically modified amino
acids in PDB files.
Ref: http://astral.berkeley.edu/
Ref: http://www.ebi.ac.uk/RESID/faq.html
- amino_acid_names
- amino_acid_composition
-- Average amino acid composition of proteins.
Ref: McCaldon P., Argos P. Proteins 4:99-122 (1988).
- kyte_doolittle_hydrophobicity
-- Kyte-Doolittle hydrophobicity scale.
Ref: Kyte J., Doolittle R.F. J. Mol. Biol. 157:105-132 (1982)
- nucleotide_names
Status: Beta (Data needs to be proof checked.)
"""
# FIXME: Proof check data
# FIXME: Add __all__
# The ExPasy ProtScale tool is a great source of amino acid properties.
# http://au.expasy.org/cgi-bin/protscale.pl
from typing import ByteString, TextIO
from . import utils
from .utils import resource_filename, resource_stream, resource_string
# Explicitly list set of available data resources. We want to be able to access
# these resources in, for example, a webapp, without inadvertently allowing
# unrestricted read access to the local file system.
resource_names = [
"blosum35",
"blosum45",
"blosum62",
"blosum40",
"blosum50",
"blosum80",
"blosum100",
"dist20_comp",
"pam250",
"pam120",
"dbxref.txt",
"vtml160",
]
_resource_filenames = {
"blosum35": "data/blosum35.mat",
"blosum45": "data/blosum45.mat",
"blosum62": "data/blosum62.mat",
"blosum40": "data/blosum40.mat",
"blosum50": "data/blosum50.mat",
"blosum80": "data/blosum80.mat",
"blosum100": "data/blosum100.mat",
"dist20_comp": "data/dist20_comp.mat",
"pam250": "data/pam250.mat",
"pam120": "data/pam120.mat",
"dbxref.txt": "data/dbxref.txt",
"vtml160": "data/vtml160",
}
# TODO: Substitution matrix parser, SeqMatrix.read
# _resource_parsers = {}
def data_string(name: str) -> ByteString:
"""Load the specified resource as a string."""
fn = _resource_filenames[name]
return resource_string(__name__, fn, __file__)
def data_stream(name: str) -> TextIO:
"""Provide an open file handle to the specified resource."""
fn = _resource_filenames[name]
return resource_stream(__name__, fn, __file__)
def data_filename(name: str) -> str:
"""Provide a filename for the given resource in the local filesystem."""
fn = _resource_filenames[name]
return resource_filename(__name__, fn, __file__)
# def data_object( name, parser = None) :
# if parser is None :
# if name in _resource_parsers :
# parser = _resource_parsers[name]
# else :
# parser = str
# return parser( data_stream(name) )
amino_acid_letters = "ACDEFGHIKLMNPQRSTVWY"
amino_acid_alternative_letters = "ARNDCQEGHILKMFPSTWYV"
amino_acid_extended_letters = "ACDEFGHIKLMNOPQRSTUVWYBJZX*-"
dna_letters = "GATC"
dna_extended_letters = "GATCRYWSMKHBVDN"
rna_letters = "GAUC"
rna_extended_letters = "GAUCRYWSMKHBVDN"
dna_ambiguity = {
"A": "A",
"C": "C",
"G": "G",
"T": "T",
"M": "AC",
"R": "AG",
"W": "AT",
"S": "CG",
"Y": "CT",
"K": "GT",
"V": "ACG",
"H": "ACT",
"D": "AGT",
"B": "CGT",
"X": "GATC",
"N": "GATC",
}
rna_ambiguity = {
"A": "A",
"C": "C",
"G": "G",
"U": "U",
"M": "AC",
"R": "AG",
"W": "AU",
"S": "CG",
"Y": "CU",
"K": "GU",
"V": "ACG",
"H": "ACU",
"D": "AGU",
"B": "CGU",
"X": "GAUC",
"N": "GAUC",
}
amino_acid_ambiguity = {
"A": "A",
"B": "ND",
"C": "C",
"D": "D",
"E": "E",
"F": "F",
"G": "G",
"H": "H",
"I": "I",
"K": "K",
"L": "L",
"M": "M",
"N": "N",
"P": "P",
"Q": "Q",
"R": "R",
"S": "S",
"T": "T",
"V": "V",
"W": "W",
"X": "ACDEFGHIKLMNPQRSTVWY",
"Y": "Y",
"Z": "QE",
"J": "IL",
"U": "U",
"O": "O",
}
# Monomer isotopically averaged molecular mass
# Data Checked GEC Nov 2006
amino_acid_mass = {
"A": 89.09,
"B": 132.66, # Averaged proportional to amino_acid_composition
"C": 121.16,
"D": 133.10,
"E": 147.13,
"F": 165.19,
"G": 75.07,
"H": 155.16,
"I": 131.18,
"J": 131.18,
"K": 146.19,
"L": 131.18,
"M": 149.21,
"N": 132.12,
# "O" : ???, # TODO
"P": 115.13,
"Q": 146.15,
"R": 174.20,
"S": 105.09,
"T": 119.12,
"U": 168.05,
"V": 117.15,
"W": 204.23,
"X": 129.15, # Averaged proportional to amino_acid_composition
"Y": 181.19,
"Z": 146.76, # Averaged proportional to amino_acid_composition
}
dna_mass = {
"A": 347.0,
"C": 323.0,
"G": 363.0,
"T": 322.0,
}
rna_mass = {
"A": 363.0,
"C": 319.0,
"G": 379.0,
"U": 340.0,
}
one_to_three = {
"A": "Ala",
"B": "Asx",
"C": "Cys",
"D": "Asp",
"E": "Glu",
"F": "Phe",
"G": "Gly",
"H": "His",
"I": "Ile",
"K": "Lys",
"L": "Leu",
"M": "Met",
"N": "Asn",
"P": "Pro",
"Q": "Gln",
"R": "Arg",
"S": "Ser",
"T": "Thr",
"V": "Val",
"W": "Trp",
"Y": "Tyr",
"Z": "Glx",
"X": "Xaa",
"U": "Sec",
"J": "Xle",
"O": "Pyl",
}
standard_three_to_one = utils.invert_dict(one_to_three)
extended_three_to_one = {
"2as": "D",
"3ah": "H",
"5hp": "E",
"Acl": "R",
"Agm": "R",
"Aib": "A",
"Ala": "A",
"Alm": "A",
"Alo": "T",
"Aly": "K",
"Arg": "R",
"Arm": "R",
"Asa": "D",
"Asb": "D",
"Ask": "D",
"Asl": "D",
"Asn": "N",
"Asp": "D",
"Asq": "D",
"Asx": "B",
"Aya": "A",
"Bcs": "C",
"Bhd": "D",
"Bmt": "T",
"Bnn": "A",
"Buc": "C",
"Bug": "L",
"C5c": "C",
"C6c": "C",
"Ccs": "C",
"Cea": "C",
"Cgu": "E",
"Chg": "A",
"Cle": "L",
"Cme": "C",
"Csd": "A",
"Cso": "C",
"Csp": "C",
"Css": "C",
"Csw": "C",
"Csx": "C",
"Cxm": "M",
"Cy1": "C",
"Cy3": "C",
"Cyg": "C",
"Cym": "C",
"Cyq": "C",
"Cys": "C",
"Dah": "F",
"Dal": "A",
"Dar": "R",
"Das": "D",
"Dcy": "C",
"Dgl": "E",
"Dgn": "Q",
"Dha": "A",
"Dhi": "H",
"Dil": "I",
"Div": "V",
"Dle": "L",
"Dly": "K",
"Dnp": "A",
"Dpn": "F",
"Dpr": "P",
"Dsn": "S",
"Dsp": "D",
"Dth": "T",
"Dtr": "W",
"Dty": "Y",
"Dva": "V",
"Efc": "C",
"Fla": "A",
"Fme": "M",
"Ggl": "E",
"Gl3": "G",
"Gln": "Q",
"Glu": "E",
"Glx": "Z",
"Gly": "G",
"Glz": "G",
"Gma": "E",
"Gsc": "G",
"Hac": "A",
"Har": "R",
"Hic": "H",
"Hip": "H",
"His": "H",
"Hmr": "R",
"Hpq": "F",
"Htr": "W",
"Hyp": "P",
"Iil": "I",
"Ile": "I",
"Iyr": "Y",
"Kcx": "K",
"Leu": "L",
"Llp": "K",
"Lly": "K",
"Ltr": "W",
"Lym": "K",
"Lys": "K",
"Lyz": "K",
"Maa": "A",
"Men": "N",
"Met": "M",
"Mhs": "H",
"Mis": "S",
"Mle": "L",
"Mpq": "G",
"Msa": "G",
"Mse": "M",
"Mva": "V",
"Nem": "H",
"Nep": "H",
"Nle": "L",
"Nln": "L",
"Nlp": "L",
"Nmc": "G",
"Oas": "S",
"Ocs": "C",
"Omt": "M",
"Paq": "Y",
"Pca": "E",
"Pec": "C",
"Phe": "F",
"Phi": "F",
"Phl": "F",
"Pr3": "C",
"Pro": "P",
"Prr": "A",
"Ptr": "Y",
"Pyl": "O",
"Sac": "S",
"Sar": "G",
"Sch": "C",
"Scs": "C",
"Scy": "C",
"Sec": "U",
"Sel": "U",
"Sep": "S",
"Ser": "S",
"Set": "S",
"Shc": "C",
"Shr": "K",
"Smc": "C",
"Soc": "C",
"Sty": "Y",
"Sva": "S",
"Ter": "*",
"Thr": "T",
"Tih": "A",
"Tpl": "W",
"Tpo": "T",
"Tpq": "A",
"Trg": "K",
"Tro": "W",
"Trp": "W",
"Tyb": "Y",
"Tyq": "Y",
"Tyr": "Y",
"Tys": "Y",
"Tyy": "Y",
"Unk": "X",
"Val": "V",
"Xaa": "X",
"Xer": "X",
"Xle": "J",
}
# Initial table is from the ASTRAL RAF release notes.
# added UNK
# Extra IUPAC: Xle, Xaa, Sec, Pyl
# The following have been seen in biopython code.
# Ter : '*' Termination
# Sel : 'U' A typo for Sec, selenocysteine?
# Xer : 'X' Another alternative for unknown?
amino_acid_names = {
"A": "alanine",
"M": "methionine",
"C": "cysteine",
"N": "asparagine",
"D": "aspartic acid",
"P": "proline",
"E": "glutamic acid",
"Q": "glutamine",
"F": "phenylalanine",
"R": "arginine",
"G": "glycine",
"S": "serine",
"H": "histidine",
"T": "threonine",
"I": "isoleucine",
"V": "valine",
"K": "lysine",
"W": "tryptophan",
"L": "leucine",
"Y": "tyrosine",
"B": "aspartic acid or asparagine",
"J": "leucine or isoleucine",
"X": "unknown",
"Z": "glutamic acid or glutamine",
"U": "selenocysteine",
"O": "pyrrolysine",
"*": "translation stop",
"-": "gap",
}
amino_acid_composition = dict(
A=0.082,
R=0.057,
N=0.044,
D=0.053,
C=0.017,
Q=0.040,
E=0.062,
G=0.072,
H=0.022,
I=0.052, # noqa: E741
L=0.090,
K=0.057,
M=0.024,
F=0.039,
P=0.051,
S=0.069,
T=0.058,
W=0.013,
Y=0.032,
V=0.066,
)
kyte_doolittle_hydrophobicity = dict(
A=1.8,
R=-4.5,
N=-3.5,
D=-3.5,
C=2.5,
Q=-3.5,
E=-3.5,
G=-0.4,
H=-3.2,
I=4.5, # noqa: E741
L=3.8,
K=-3.9,
M=1.9,
F=2.8,
P=-1.6,
S=-0.8,
T=-0.7,
W=-0.9,
Y=-1.3,
V=4.2,
)
nucleotide_names = {
"A": "Adenosine",
"C": "Cytidine",
"G": "Guanine",
"T": "Thymidine",
"U": "Uracil",
"R": "G A (puRine)",
"Y": "T C (pYrimidine)",
"K": "G T (Ketone)",
"M": "A C (aMino group)",
"S": "G C (Strong interaction)",
"W": "A T (Weak interaction)",
"B": "G T C (not A) (B comes after A)",
"D": "G A T (not C) (D comes after C)",
"H": "A C T (not G) (H comes after G)",
"V": "G C A (not T, not U) (V comes after U)",
"N": "A G C T (aNy)",
"-": "gap",
}
|