Reference
The BasicAuriclass
class
Source code in auriclass/classes.py
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 |
|
check_for_outgroup()
Check if the closest sample is defined as outgroup.
Parameters
self : object The AuriClassAnalysis object.
Returns
bool True if the closest sample is not an outgroup, False otherwise.
Notes
This function sets the following attributes of the object: - qc_other_candida: a warning message if the closest sample is defined as outgroup
The function uses the following attributes of the object: - clade: the clade of the closest reference sample - closest_sample: the closest reference sample to the current test sample
Source code in auriclass/classes.py
check_genome_size()
Compare the estimated genome size with the expected genome size range.
If the estimated genome size is outside the expected range, a warning message is logged and the
qc_genome_size
attribute is set to "WARN: genome size outside expected range".
Parameters
self : object The AuriClassAnalysis object.
Returns
None
Notes
This function sets the following attributes of the object: - qc_genome_size: a warning message if the estimated genome size is outside the expected range
The function uses the following attributes of the object: - estimated_genome_size: the estimated genome size of the current sample
Source code in auriclass/classes.py
check_high_dist()
Check if the closest sample is above high_dist_threshold distance. If it is, it may indicate a new clade.
Parameters
self : object The AuriClassAnalysis object.
Returns
None
Notes
This function sets the following attributes of the object: - qc_high_distance: a warning message if the closest sample is above self.high_dist_threshold distance
The function uses the following attributes of the object: - minimal_distance: the minimal distance between the current test sample and the closest reference sample - high_dist_threshold: the threshold above which the distance to the closest sample is considered to be a new clade
Source code in auriclass/classes.py
check_non_candida()
Check if the distance to the closest sample is higher than the non-Candida threshold.
Parameters
self : object The AuriClassAnalysis object.
Returns
bool True if the distance to the closest sample is lower than or equal to the non-Candida threshold, False otherwise.
Notes
This function sets the following attributes of the object: - qc_species: a warning message if the distance to the closest sample is higher than the non-Candida threshold
The function uses the following attributes of the object: - minimal_distance: the minimal distance between the current test sample and the closest reference sample - non_candida_threshold: the threshold above which the distance to the closest sample is considered to be non-Candida
Source code in auriclass/classes.py
compare_with_error_bounds()
Compare the distance between the current test sample and the closest reference sample with the error bound.
Parameters
self : object The AuriClassAnalysis object.
Returns
None
Notes
This function sets the following attributes of the object: - distances: the distances between the current test sample and all other reference samples - samples_within_error_bound: the number of samples within the error bound of the closest sample - qc_multiple_hits: a warning message if the number of samples within the error bound of the closest sample is higher than 0
The function uses the following attributes of the object: - mash_output: a pandas DataFrame containing the output of the Mash distance calculation - closest_sample: the closest reference sample to the current test sample - minimal_distance: the minimal distance between the current test sample and the closest reference sample - error_bound: the error bound for the current sketch size and kmer size
Source code in auriclass/classes.py
get_error_bounds()
Get error bounds for the current sketch size and kmer size.
Parameters
self : object The AuriClassAnalysis object.
Returns
str The STDOUT of the mash bounds command.
Notes
The function uses the following attributes of the object: - kmer_size: the kmer size to use for the sketch - probability: the probability to use for the mash bounds command
Source code in auriclass/classes.py
process_error_bounds(error_bounds_text)
Process the error bounds text to get the error bound for the current sketch size and kmer size.
Parameters
self : object The AuriClassAnalysis object. error_bounds_text : str The STDOUT of the mash bounds command.
Returns
None
Notes
This function sets the following attributes of the object: - error_bound: the error bound for the current sketch size and kmer size
The function uses the following attributes of the object: - sketch_size: the size of the sketch to create - minimal_distance: the minimal distance between the current test sample and the closest reference sample
Source code in auriclass/classes.py
run_mash_dist()
Run Mash dist and save results.
Parameters
self : object The AuriClassAnalysis object.
Returns
pandas.DataFrame A DataFrame containing the results of the Mash dist, including the reference and query sequences, the distance between them, the p-value, the number of matching hashes, and the predicted clade.
Notes
This function sets the following attributes of the object: - mash_output: a pandas DataFrame containing the output of the Mash distance calculation
The function uses the following attributes of the object: - reference_sketch_path: the path to the reference sketch - query_sketch_path: the path to the query sketch - clade_dict: a dictionary containing the clade information for each reference sample
Source code in auriclass/classes.py
save_report()
Save the report to a TSV file.
Parameters
self : object The AuriClassAnalysis object.
Returns
None
Notes
This function sets the following attributes of the object: - qc_decision: the QC decision based on the QC attributes
The function uses the following attributes of the object: - qc_species: a warning message if the distance to the closest sample is higher than the non-Candida threshold - qc_other_candida: a warning message if the closest sample is defined as outgroup - qc_genome_size: a warning message if the estimated genome size is outside the expected range - qc_multiple_hits: a warning message if the number of samples within the error bound of the closest sample is higher than 0 - qc_high_distance: a warning message if the closest sample is above self.high_dist_threshold distance - name: the name of the current test sample - clade: the clade of the closest reference sample - minimal_distance: the minimal distance between the current test sample and the closest reference sample - output_report_path: the path to the output report - no_qc: a boolean indicating whether to skip extended QC
Source code in auriclass/classes.py
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 |
|
select_clade()
Selects the closest reference sample and corresponding clade.
Parameters
self : object The AuriClassAnalysis object.
Returns
None
Notes
This function sets the following attributes of the object: - closest_sample: the closest reference sample to the current test sample - clade: the clade of the closest reference sample - minimal_distance: the minimal distance between the current test sample and the closest reference sample
The function uses the following attributes of the object: - mash_output: a pandas DataFrame containing the output of the Mash distance calculation - clade_dict: a dictionary containing the clade information for each reference sample
Source code in auriclass/classes.py
The FastqAuriclass
class
Bases: BasicAuriclass
Source code in auriclass/classes.py
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 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
|
sketch_fastq_query()
Sketches the query fastq files using mash.
Parameters
self : object The AuriClassAnalysis object.
Returns
None
Raises
ValueError If no sequence records are found in the specified fastq file(s).
If the estimated genome size cannot be parsed from the mash sketch STDERR.
Notes
This function sets the following attributes of the object: - stdout: the STDOUT of the mash sketch command - estimated_genome_size: the estimated genome size of the current test sample
The function uses the following attributes of the object: - minimal_kmer_coverage: the minimal kmer coverage to use for the sketch - query_sketch_path: the path to the query sketch - kmer_size: the kmer size to use for the sketch - sketch_size: the size of the sketch to create - read_paths: the paths to the fastq files to sketch
Source code in auriclass/classes.py
The FastaAuriclass
class
Bases: BasicAuriclass
Source code in auriclass/classes.py
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 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 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 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 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
|
parse_genome_size()
Parse the size of the fasta input using pyfastx.
Parameters
self : object The AuriClassAnalysis object.
Returns
None
Notes
This function sets the following attributes of the object: - estimated_genome_size: the estimated genome size of the current test sample
The function uses the following attributes of the object: - read_paths: the paths to the fasta files to parse
Source code in auriclass/classes.py
sketch_fasta_query()
Sketches the query fasta files using mash.
Parameters
self : object The AuriClassAnalysis object.
Returns
None
Raises
ValueError If no sequence records are found in the specified fasta file(s).
Notes
This function sets the following attributes of the object: - stdout: the STDOUT of the mash sketch command - estimated_genome_size: the estimated genome size of the current test sample
The function uses the following attributes of the object: - minimal_kmer_coverage: the minimal kmer coverage to use for the sketch - query_sketch_path: the path to the query sketch - kmer_size: the kmer size to use for the sketch - sketch_size: the size of the sketch to create - read_paths: the paths to the fastq files to sketch
Source code in auriclass/classes.py
General scripts
add_tag(tag, lines)
Add a tag to a string or list of strings.
Parameters
tag : str The tag to add. lines : str or list of str The string or list of strings to add the tag to.
Returns
str The string with the tag added to each line.
Source code in auriclass/general.py
check_dependencies()
Check if dependencies are installed.
Parameters
None
Returns
None
Raises
FileNotFoundError If mash is not installed.
Source code in auriclass/general.py
check_number_within_range(minimum=0, maximum=1)
Creates a function to check whether a numeric value is within a range, inclusive.
The generated function can be used by the type
parameter in argparse.ArgumentParser.
See https://stackoverflow.com/a/53446178.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
the numeric value to check. |
required | |
minimum |
float
|
minimum of allowed range, inclusive. |
0
|
maximum |
float
|
maximum of allowed range, inclusive. |
1
|
Returns:
Type | Description |
---|---|
Union[Callable[[str], str], FileType]
|
A function which takes a single argument and checks this against the range. |
Raises:
Type | Description |
---|---|
ArgumentTypeError
|
if the value is outside the range. |
ValueError
|
if the value cannot be converted to float. |
Source code in auriclass/general.py
confirm_input_type(list_of_file_paths, input_type)
Confirms that input files are of the specified type.
Parameters
list_of_file_paths : list of str The list of filepaths to check. input_type : str The input type to check.
Returns
None
Raises
None
Notes
This function does not raise any exceptions, but it does log a warning if any of the input files are not of the specified type. This is intended to run if the user specifies the input type with --fastq or --fasta.
Source code in auriclass/general.py
guess_input_type(list_of_file_paths)
Guess the input type of a list of files.
Parameters
list_of_file_paths : list of str The list of filepaths to check.
Returns
str The input type, either "fastq" or "fasta".
Raises
ValueError If any of the input files can be parsed as both fastq and fasta.
If any of the input files cannot be parsed as either fastq or fasta.
If the input files are a mix of fastq and fasta files.
If no input files were found.
Source code in auriclass/general.py
is_fasta(file)
Check if a file is a fasta file.
Parameters
filepath : str The path to the file to check.
Returns
None
Raises
RuntimeError If the file is not a fasta file.
Source code in auriclass/general.py
is_fastq(file)
Check if a file is a fastq file.
Parameters
filepath : str The path to the file to check.
Returns
None
Raises
RuntimeError If the file is not a fastq file.
Source code in auriclass/general.py
validate_argument_logic(args)
Check if arguments are valid, based on predefined logic.
Parameters
args : argparse.Namespace The arguments to check.
Returns
argparse.Namespace The arguments, if they are valid. Modified if necessary.
Raises
ValueError If the arguments are not valid.
Source code in auriclass/general.py
validate_input_files(list_of_files)
Check if files in a list exist.
Parameters
list_of_files : list of str The list of filepaths to check.
Returns
None
Raises
FileNotFoundError If any of the files do not exist.