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 639 640 641 642 643 644 645 646 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 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 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 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 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
|
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for mapping pairwise alignments."""
import os
import random
import unittest
try:
import numpy as np
except ImportError:
from Bio import MissingPythonDependencyError
raise MissingPythonDependencyError(
"Install numpy if you want to use Bio.Align.Alignment.map."
) from None
from Bio import Align
from Bio import SeqIO
from Bio.Align import Alignment
from Bio.Align import PairwiseAligner
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
class TestSimple(unittest.TestCase):
aligner = PairwiseAligner()
aligner.internal_open_gap_score = -1
aligner.internal_extend_gap_score = -0.0
aligner.match_score = +1
aligner.mismatch_score = -1
aligner.mode = "local"
def test_internal(self):
aligner = self.aligner
chromosome = Seq("AAAAAAAAAAAAGGGGGGGCCCCCGGGGGGAAAAAAAAAA")
chromosome.id = "chromosome"
transcript = Seq("GGGGGGGCCCCCGGGGGGA")
transcript.id = "transcript"
sequence = Seq("GGCCCCCGGG")
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript)
self.assertEqual(len(alignments1), 1)
alignment1 = alignments1[0]
self.assertTrue(
np.array_equal(alignment1.coordinates, np.array([[12, 31], [0, 19]]))
)
self.assertEqual(
str(alignment1),
"""\
chromosom 12 GGGGGGGCCCCCGGGGGGA 31
0 ||||||||||||||||||| 19
transcrip 0 GGGGGGGCCCCCGGGGGGA 19
""",
)
alignments2 = aligner.align(transcript, sequence)
self.assertEqual(len(alignments2), 1)
alignment2 = alignments2[0]
self.assertTrue(
np.array_equal(alignment2.coordinates, np.array([[5, 15], [0, 10]]))
)
self.assertEqual(
str(alignment2),
"""\
transcrip 5 GGCCCCCGGG 15
0 |||||||||| 10
sequence 0 GGCCCCCGGG 10
""",
)
alignment = alignment1.map(alignment2)
self.assertTrue(
np.array_equal(alignment.coordinates, np.array([[17, 27], [0, 10]]))
)
self.assertEqual(
str(alignment),
"""\
chromosom 17 GGCCCCCGGG 27
0 |||||||||| 10
sequence 0 GGCCCCCGGG 10
""",
)
line = format(alignment, "psl")
self.assertEqual(
line,
"""\
10 0 0 0 0 0 0 0 + sequence 10 0 10 chromosome 40 17 27 1 10, 0, 17,
""",
)
def test_left_overhang(self):
aligner = self.aligner
chromosome = Seq("GGGCCCCCGGGGGGAAAAAAAAAA")
chromosome.id = "chromosome"
transcript = Seq("AGGGGGCCCCCGGGGGGA")
transcript.id = "transcript"
sequence = Seq("GGGGGCCCCCGGG")
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript)
self.assertEqual(len(alignments1), 1)
alignment1 = alignments1[0]
self.assertEqual(
str(alignment1),
"""\
chromosom 0 GGGCCCCCGGGGGGA 15
0 ||||||||||||||| 15
transcrip 3 GGGCCCCCGGGGGGA 18
""",
)
alignments2 = aligner.align(transcript, sequence)
self.assertEqual(len(alignments2), 1)
alignment2 = alignments2[0]
self.assertEqual(
str(alignment2),
"""\
transcrip 1 GGGGGCCCCCGGG 14
0 ||||||||||||| 13
sequence 0 GGGGGCCCCCGGG 13
""",
)
alignment = alignment1.map(alignment2)
self.assertTrue(
np.array_equal(alignment.coordinates, np.array([[0, 11], [2, 13]]))
)
self.assertEqual(
str(alignment),
"""\
chromosom 0 GGGCCCCCGGG 11
0 ||||||||||| 11
sequence 2 GGGCCCCCGGG 13
""",
)
line = format(alignment, "psl")
self.assertEqual(
line,
"""\
11 0 0 0 0 0 0 0 + sequence 13 2 13 chromosome 24 0 11 1 11, 2, 0,
""",
)
def test_right_overhang(self):
aligner = self.aligner
chromosome = Seq("AAAAAAAAAAAAGGGGGGGCCCCCGGG")
chromosome.id = "chromosome"
transcript = Seq("GGGGGGGCCCCCGGGGGGA")
transcript.id = "transcript"
sequence = Seq("GGCCCCCGGGGG")
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript)
self.assertEqual(len(alignments1), 1)
alignment1 = alignments1[0]
self.assertEqual(
str(alignment1),
"""\
chromosom 12 GGGGGGGCCCCCGGG 27
0 ||||||||||||||| 15
transcrip 0 GGGGGGGCCCCCGGG 15
""",
)
alignments2 = aligner.align(transcript, sequence)
self.assertEqual(len(alignments2), 1)
alignment2 = alignments2[0]
self.assertEqual(
str(alignment2),
"""\
transcrip 5 GGCCCCCGGGGG 17
0 |||||||||||| 12
sequence 0 GGCCCCCGGGGG 12
""",
)
alignment = alignment1.map(alignment2)
self.assertTrue(
np.array_equal(alignment.coordinates, np.array([[17, 27], [0, 10]]))
)
self.assertEqual(
str(alignment),
"""\
chromosom 17 GGCCCCCGGG 27
0 |||||||||| 10
sequence 0 GGCCCCCGGG 10
""",
)
line = format(alignment, "psl")
self.assertEqual(
line,
"""\
10 0 0 0 0 0 0 0 + sequence 12 0 10 chromosome 27 17 27 1 10, 0, 17,
""",
)
def test_reverse_transcript(self):
aligner = self.aligner
chromosome = Seq("AAAAAAAAAAAAGGGGGGGCCCCCGGGGGGAAAAAAAAAA")
chromosome.id = "chromosome"
transcript = Seq("TCCCCCCGGGGGCCCCCCC")
transcript.id = "transcript"
sequence = Seq("GGCCCCCGGG")
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript, strand="-")
self.assertEqual(len(alignments1), 1)
alignment1 = alignments1[0]
self.assertTrue(
np.array_equal(alignment1.coordinates, np.array([[12, 31], [19, 0]]))
)
self.assertEqual(
str(alignment1),
"""\
chromosom 12 GGGGGGGCCCCCGGGGGGA 31
0 ||||||||||||||||||| 19
transcrip 19 GGGGGGGCCCCCGGGGGGA 0
""",
)
alignments2 = aligner.align(transcript, sequence, strand="-")
self.assertEqual(len(alignments2), 1)
alignment2 = alignments2[0]
self.assertTrue(
np.array_equal(alignment2.coordinates, np.array([[4, 14], [10, 0]]))
)
self.assertEqual(
str(alignment2),
"""\
transcrip 4 CCCGGGGGCC 14
0 |||||||||| 10
sequence 10 CCCGGGGGCC 0
""",
)
alignment = alignment1.map(alignment2)
self.assertTrue(
np.array_equal(alignment.coordinates, np.array([[17, 27], [0, 10]]))
)
self.assertEqual(
str(alignment),
"""\
chromosom 17 GGCCCCCGGG 27
0 |||||||||| 10
sequence 0 GGCCCCCGGG 10
""",
)
line = format(alignment, "psl")
self.assertEqual(
line,
"""\
10 0 0 0 0 0 0 0 + sequence 10 0 10 chromosome 40 17 27 1 10, 0, 17,
""",
)
def test_reverse_sequence(self):
aligner = self.aligner
chromosome = Seq("AAAAAAAAAAAAGGGGGGGCCCCCGGGGGGAAAAAAAAAA")
chromosome.id = "chromosome"
transcript = Seq("GGGGGGGCCCCCGGGGGGA")
transcript.id = "transcript"
sequence = Seq("CCCGGGGGCC")
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript)
self.assertEqual(len(alignments1), 1)
alignment1 = alignments1[0]
self.assertTrue(
np.array_equal(alignment1.coordinates, np.array([[12, 31], [0, 19]]))
)
self.assertEqual(
str(alignment1),
"""\
chromosom 12 GGGGGGGCCCCCGGGGGGA 31
0 ||||||||||||||||||| 19
transcrip 0 GGGGGGGCCCCCGGGGGGA 19
""",
)
alignments2 = aligner.align(transcript, sequence, "-")
self.assertEqual(len(alignments2), 1)
alignment2 = alignments2[0]
self.assertTrue(
np.array_equal(alignment2.coordinates, np.array([[5, 15], [10, 0]]))
)
self.assertEqual(
str(alignment2),
"""\
transcrip 5 GGCCCCCGGG 15
0 |||||||||| 10
sequence 10 GGCCCCCGGG 0
""",
)
alignment = alignment1.map(alignment2)
self.assertTrue(
np.array_equal(alignment.coordinates, np.array([[17, 27], [10, 0]]))
)
self.assertEqual(
str(alignment),
"""\
chromosom 17 GGCCCCCGGG 27
0 |||||||||| 10
sequence 10 GGCCCCCGGG 0
""",
)
line = format(alignment, "psl")
self.assertEqual(
line,
"""\
10 0 0 0 0 0 0 0 - sequence 10 0 10 chromosome 40 17 27 1 10, 0, 17,
""",
)
def test_reverse_transcript_sequence(self):
aligner = self.aligner
chromosome = Seq("AAAAAAAAAAAAGGGGGGGCCCCCGGGGGGAAAAAAAAAA")
chromosome.id = "chromosome"
transcript = Seq("TCCCCCCGGGGGCCCCCCC")
transcript.id = "transcript"
sequence = Seq("CCCGGGGGCC")
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript, "-")
self.assertEqual(len(alignments1), 1)
alignment1 = alignments1[0]
self.assertTrue(
np.array_equal(alignment1.coordinates, np.array([[12, 31], [19, 0]]))
)
self.assertEqual(
str(alignment1),
"""\
chromosom 12 GGGGGGGCCCCCGGGGGGA 31
0 ||||||||||||||||||| 19
transcrip 19 GGGGGGGCCCCCGGGGGGA 0
""",
)
alignments2 = aligner.align(transcript, sequence)
self.assertEqual(len(alignments2), 1)
alignment2 = alignments2[0]
self.assertTrue(
np.array_equal(alignment2.coordinates, np.array([[4, 14], [0, 10]]))
)
self.assertEqual(
str(alignment2),
"""\
transcrip 4 CCCGGGGGCC 14
0 |||||||||| 10
sequence 0 CCCGGGGGCC 10
""",
)
alignment = alignment1.map(alignment2)
self.assertTrue(
np.array_equal(alignment.coordinates, np.array([[17, 27], [10, 0]]))
)
self.assertEqual(
str(alignment),
"""\
chromosom 17 GGCCCCCGGG 27
0 |||||||||| 10
sequence 10 GGCCCCCGGG 0
""",
)
line = format(alignment, "psl")
self.assertEqual(
line,
"""\
10 0 0 0 0 0 0 0 - sequence 10 0 10 chromosome 40 17 27 1 10, 0, 17,
""",
)
class TestComplex(unittest.TestCase):
aligner = PairwiseAligner()
aligner.internal_open_gap_score = -1
aligner.internal_extend_gap_score = -0.0
aligner.match_score = +1
aligner.mismatch_score = -1
aligner.mode = "local"
def test1(self):
aligner = self.aligner
chromosome = Seq(
"GCCTACCGTATAACAATGGTTATAATACAAGGCGGTCATAATTAAAGGGAGTGCAGCAACGGCCTGCTCTCCAAAAAAACAGGTTTTATGAAAAGAAAGTGCATTAACTGTTAAAGCCGTCATATCGGTGGGTTCTGCCAGTCACCGGCATACGTCCTGGGACAAAGACTTTTTACTACAATGCCAGGCGGGAGAGTCACCCGCCGCGGTGTCGACCCAGGGGACAGCGGGAAGATGTCGTGGTTTCCTTGTCATTAACCAACTCCATCTTAAAAGCTCCTCTAGCCATGGCATGGTACGTTGCGCGCACCCTTTTATCGGTAAGGCGCGGTGACTCTCTCCCAAAACAGTGCCATAATGGTTCGCTTCCTACCTAAGGCACTTACGGCCAATTAATGCGCAAGCGAGCGGAAGGTCTAACAGGGCACCGAATTCGATTA"
)
chromosome.id = "chromosome"
transcript = Seq(
"GGAATTTTAGCAGCCAAAGGACGGATCCTCCAAGGGGCCCCAGCACAGCACATTTTTAACGCGAACTAAGCGGGAGCGCATGTGGGACAGTTGATCCCATCCGCCTCAAAATTTCTCGCAATATCGGTTGGGGCACAGGTCCACTTTACGAATTCATACCGTGGTAGAGACCTTTATTAGATAGATATGACTGTTTGATTGCGGCATAGTACGACGAAGCAAGGGGATGGACGTTTCGGTTGCATTCGACCGGGTTGGGTCGAAAAACAGGTTTTATGAAAAGAAAGTGCATTAACTGTTAAAGCCGTCATATCGGTGGGTTC"
)
transcript.id = "transcript"
sequence = Seq(
"TCCAAGGGGCCCCAGCACAGCACATTTTTAACGCGGGGACAGTTGATCCCATCCGCCTTTTACGAATTCATACCGTGGTAGGCGGCATAGTACGACGAAGCGGTTGGGTCGAAAAACAGGTTGCCGTCATATCGGTGGGTTC"
)
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript)
alignment1 = alignments1[0]
self.assertEqual(alignment1.coordinates.shape[1], 164)
self.assertEqual(
str(alignment1),
"""\
chromosom 14 AATGGTTATA------ATACAAGG-CGG----TCATAATTAAAGGGAGTG---CAGCAAC
0 |||--||-||------|---||||-|||----||------.|||||---|---|||||--
transcrip 2 AAT--TT-TAGCAGCCA---AAGGACGGATCCTC------CAAGGG---GCCCCAGCA--
chromosom 60 GGCCTGCTCTCCAAAAAAACAGGTTTTATGAAAAGAAAGTGCATTAACTGTTAAAGC---
60 ---|.||-----------|||--||||-|------||.|.|----||||----||||---
transcrip 45 ---CAGC-----------ACA--TTTT-T------AACGCG----AACT----AAGCGGG
chromosom 117 --CGTCATATCGGTGG----GTTCTGCCAGTCACCGGCATACGTCCTGGGACAAAGACTT
120 --||-|||----||||----||--||--|-|--||--|||.||-|||----||||-|---
transcrip 74 AGCG-CAT----GTGGGACAGT--TG--A-T--CC--CATCCG-CCT----CAAA-A---
chromosom 171 TTTACT-ACAATGCCAGGCGGGAGAGTCACCCGCCGCGGTGTCGACCCAGGGG-ACAGCG
180 |||-||-.||||------------|-|---------||||-|-------||||-||||--
transcrip 111 TTT-CTCGCAAT------------A-T---------CGGT-T-------GGGGCACAG--
chromosom 229 GGAAGATGTCGTGGTTTC-CTT---G---TCATTAACC-------A-ACTCCATCTTA--
240 -------|||-------|-|||---|---||||--|||-------|-|--||-|-|||--
transcrip 138 -------GTC-------CACTTTACGAATTCAT--ACCGTGGTAGAGA--CC-T-TTATT
chromosom 272 AAAGCTCCTCTAGCCATGGCATG---GT---ACGTTGCGCGCACCCTTTTA-T----CG-
300 |.|-------|||--||---|||---||---|--|||||-|||------||-|----||-
transcrip 178 AGA-------TAG--AT---ATGACTGTTTGA--TTGCG-GCA------TAGTACGACGA
chromosom 320 -GTAAGG-------CG---CGGT-------GACTCTC--------TCCCAAAACAGTGCC
360 -|.||||-------||---||||-------|||---|--------||..||||||-----
transcrip 217 AGCAAGGGGATGGACGTTTCGGTTGCATTCGAC---CGGGTTGGGTCGAAAAACA-----
chromosom 354 ATAATGGTTCGCTTCCTACCT-------AAG-GCACTT-ACGGCCAATTAATGCGCAAGC
420 -----|||----||--||--|-------|||-|||-||-||.|----|||------||||
transcrip 269 -----GGT----TT--TA--TGAAAAGAAAGTGCA-TTAACTG----TTA------AAGC
chromosom 405 GAGCGGAAGGTC-TAACAG-GGCACCGAATTC 435
480 ---|-----|||-||.|.|-||----|--||| 512
transcrip 305 ---C-----GTCATATCGGTGG----G--TTC 323
""",
)
alignments2 = aligner.align(transcript, sequence)
alignment2 = alignments2[0]
self.assertEqual(alignment2.coordinates.shape[1], 12)
self.assertEqual(
str(alignment2),
"""\
transcrip 28 TCCAAGGGGCCCCAGCACAGCACATTTTTAACGCGAACTAAGCGGGAGCGCATGTGGGAC
0 |||||||||||||||||||||||||||||||||||--------------------|||||
sequence 0 TCCAAGGGGCCCCAGCACAGCACATTTTTAACGCG--------------------GGGAC
transcrip 88 AGTTGATCCCATCCGCCTCAAAATTTCTCGCAATATCGGTTGGGGCACAGGTCCACTTTA
60 ||||||||||||||||||--------------------------------------||||
sequence 40 AGTTGATCCCATCCGCCT--------------------------------------TTTA
transcrip 148 CGAATTCATACCGTGGTAGAGACCTTTATTAGATAGATATGACTGTTTGATTGCGGCATA
120 |||||||||||||||||||---------------------------------||||||||
sequence 62 CGAATTCATACCGTGGTAG---------------------------------GCGGCATA
transcrip 208 GTACGACGAAGCAAGGGGATGGACGTTTCGGTTGCATTCGACCGGGTTGGGTCGAAAAAC
180 ||||||||||||--------------------------------||||||||||||||||
sequence 89 GTACGACGAAGC--------------------------------GGTTGGGTCGAAAAAC
transcrip 268 AGGTTTTATGAAAAGAAAGTGCATTAACTGTTAAAGCCGTCATATCGGTGGGTTC 323
240 |||||------------------------------|||||||||||||||||||| 295
sequence 117 AGGTT------------------------------GCCGTCATATCGGTGGGTTC 142
""",
)
alignment = alignment1.map(alignment2)
self.assertEqual(alignment.coordinates.shape[1], 76)
self.assertEqual(
str(alignment),
"""\
chromosom 35 TCATAATTAAAGGGAGTG---CAGCAACGGCCTGCTCTCCAAAAAAACAGGTTTTATGAA
0 ||------.|||||---|---|||||-----|.||-----------|||--||||-|---
sequence 0 TC------CAAGGG---GCCCCAGCA-----CAGC-----------ACA--TTTT-T---
chromosom 92 AAGAAAGTGCATTAACTGTTAAAGCCGTCATATCGGTGG----GTTCTGCCAGTCACCGG
60 ---||.|.|----------------------------||----||--||--|-|--||--
sequence 29 ---AACGCG----------------------------GGGACAGT--TG--A-T--CC--
chromosom 148 CATACGTCCTGGGACAAAGACTTTTTACTACAATGCCAGGCGGGAGAGTCACCCGCCGCG
120 |||.||-|||--------------------------------------------------
sequence 49 CATCCG-CCT--------------------------------------------------
chromosom 208 GTGTCGACCCAGGGGACAGCGGGAAGATGTCGTGGTTTCCTT---G---TCATTAACCAA
180 ----------------------------------------||---|---||||--|||--
sequence 58 ----------------------------------------TTTACGAATTCAT--ACC--
chromosom 262 CTCCATCTTAAAAGCTCCTCTAGCCATGGCATGGTACGTT-------GCGCGCACCCTTT
240 -----------------------------------------------|||-|||------
sequence 74 ----------------------------------------GTGGTAGGCG-GCA------
chromosom 315 TA-T----CG--GTAAGGCGCGGTGACTCTC-------TCCCAAAACAGTGCCATAATGG
300 ||-|----||--|.------------------------||..||||||----------||
sequence 87 TAGTACGACGAAGC-----------------GGTTGGGTCGAAAAACA----------GG
chromosom 361 TTCGCTTCCTACCTAAGGCACTTACGGCCAATTAATGCGCAAGCGAGCGGAAGGTC-TAA
360 |----|------------------------------------||---|-----|||-||.
sequence 120 T----T------------------------------------GC---C-----GTCATAT
chromosom 420 CAG-GGCACCGAATTC 435
420 |.|-||----|--||| 436
sequence 132 CGGTGG----G--TTC 142
""",
)
line = format(alignment, "psl")
self.assertEqual(
line,
"""\
96 10 0 0 11 36 27 294 + sequence 142 0 142 chromosome 440 35 435 37 2,6,1,5,4,3,4,1,6,2,2,2,1,1,2,6,3,2,1,4,3,3,3,2,1,2,2,10,3,1,2,1,3,6,2,1,3, 0,2,8,12,17,21,24,28,29,35,41,43,45,46,47,49,55,58,63,67,71,81,84,87,90,95,99,108,118,121,122,124,125,129,136,138,139, 35,43,52,53,63,78,83,88,95,129,131,135,139,141,144,148,155,248,250,251,257,302,306,315,317,318,320,339,359,366,403,408,414,417,423,429,432,
""",
)
def test2(self):
aligner = self.aligner
chromosome = Seq(
"CTAATGCGCCTTGGTTTTGGCTTAACTAGAAGCAACCTGTAAGATTGCCAATTCTTCAGTCGAAGTAAATCTTCAATGTTTTGGACTCTTAGCGGATATGCGGCTGAGAAGTACGACATGTGTACATTCATACCTGCGTGACGGTCAGCCTCCCCCGGGACCTCATTGGGCGAATCTAGGTGTGATAATTGACACACTCTTGGTAAGAAGCACTCTTTACCCGATCTCCAAGTACCGACGCCAAGGCCAAGCTCTGCGATCTAAAGCTGCCGATCGTAGATCCAAGTCCTCAGCAAGCTCGCACGAATACGCAGTTCGAAGGCTGGGTGTTGTACGACGGTACGGTTGCTATAGCACTTTCGCGGTCTCGCTATTTTCAGTTTGACTCACCAGTCAGTATTGTCATCGACCAACTTGGAATAGTGTAACGCAGCGCTTGA"
)
chromosome.id = "chromosome"
transcript = Seq(
"CACCGGCGTCGGTACCAGAGGGCGTGAGTACCTTGTACTAGTACTCATTGGAATAATGCTCTTAGAAGTCATCTAAAAGTGACAACGCCTGTTTGGTTATGACGTTCACGACGCGTCTTAACAGACTAGCATTAGACCGACGGGTTGAGGCGTCTGGGTTGATACAGCCGTTTGCATCAGTGTATCTAACACTCTGAGGGATAATTGATGAACCGTGTTTTCCGATAGGTATGTACAGTACCACCACGCACGACTAAGGACCATTTTCTGCGTGCGACGGTTAAAATAACCTCAATCACT"
)
transcript.id = "transcript"
sequence = Seq(
"TCCCCTTCTAATGGAATCCCCCTCCGAAGGTCGCAGAAGCGGCCACGCCGGAGATACCAGTTCCACGCCTCAGGTTGGACTTGTCACACTTGTACGCGAT"
)
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript)
alignment1 = alignments1[0]
self.assertEqual(alignment1.coordinates.shape[1], 126)
self.assertEqual(
str(alignment1),
"""\
chromosom 5 GCGCCTTGGTTTTGGCTTAACTAGA-------AGCAACC-TGTAAGATTGCCAATTCTTC
0 |||--|.|||---------||.|||-------||-.|||-||||------------||--
transcrip 5 GCG--TCGGT---------ACCAGAGGGCGTGAG-TACCTTGTA------------CT--
chromosom 57 AGTCGAAGTAAATCTTCAATGTTTTGGA------CTCTTAG----CGGATATGCGGCTGA
60 ------||||---|-|||-----|||||------|||||||----|----||----||-|
transcrip 39 ------AGTA---C-TCA-----TTGGAATAATGCTCTTAGAAGTC----AT----CT-A
chromosom 107 GAAGTACGACA-----TGT---GT----ACATTCATAC--CTGCGT-------GACGGTC
120 .||||--||||-----|||---||----||.|||--||--|-||||-------|||--|-
transcrip 75 AAAGT--GACAACGCCTGTTTGGTTATGACGTTC--ACGAC-GCGTCTTAACAGAC--T-
chromosom 146 AGCCT----CCCCCGGGACCTCATTG-GGCGAATCTAGGTGTGATA-A-----TTGACA-
180 |||.|----||..||||------|||-||||--|||.|||-|||||-|-----|||-||-
transcrip 127 AGCATTAGACCGACGGG------TTGAGGCG--TCTGGGT-TGATACAGCCGTTTG-CAT
chromosom 194 CA----CTCTTGGTAAGAAGCACTCT---------TTACCCGATCTCCAAGTACCGACGC
240 ||----.|||-------||-||||||---------||----|||------|.||||----
transcrip 177 CAGTGTATCT-------AA-CACTCTGAGGGATAATT----GAT------GAACCG----
chromosom 241 CAAGGCCAAGCTCTG-----CGATCTAAAGCTGCCGATCGTAGATCCAAGTCCTCAGCAA
300 -------------||-----||||----||.|----||-|||----|-|||.|-||.||-
transcrip 215 -------------TGTTTTCCGAT----AGGT----AT-GTA----C-AGTAC-CACCA-
chromosom 296 GCTCGCACGAATACGCAG-------TTCGAAGGCTGGGTGTTGTACGACGGTACGGTTGC
360 ---|||||||.||---||-------||------|||.|||-----|||||||--------
transcrip 246 ---CGCACGACTA---AGGACCATTTT------CTGCGTG-----CGACGGT--------
chromosom 349 TATAGCACTTTCGCGGTCTCGCTATTTTCAGTTTGACTCACCAGTCAGTATTGTCATCGA
420 ||-|--|----------------||----------|---|||--|||--------|||--
transcrip 281 TA-A--A----------------AT----------A---ACC--TCA--------ATC--
chromosom 409 CCAACT 415
480 ---||| 486
transcrip 297 ---ACT 300
""",
)
alignments2 = aligner.align(transcript, sequence)
alignment2 = alignments2[0]
self.assertEqual(alignment2.coordinates.shape[1], 66)
self.assertEqual(
str(alignment2),
"""\
transcrip 8 TCGGTACCAGAGGGCGTGAGTACCTTGTACTAGTACTCATTGGAATAATGCTCTTAGAAG
0 ||------------|-------||||---|||------|-||||||--------------
sequence 0 TC------------C-------CCTT---CTA------A-TGGAAT--------------
transcrip 68 TCATCTAAAAGTGACAACGCCTGTTTGGTTATGACGTTCACGACGCGTCTTAACAGACTA
60 -----------------|.||-------------|--||-|||.|-|||---.||||--|
sequence 17 -----------------CCCC-------------C--TC-CGAAG-GTC---GCAGA--A
transcrip 128 GCATTAGACCGACG--GGTTGAGGCGTCTGGGTTGATACAGCCGTTTGCATCAGTGTATC
120 ||----|.||-|||--|---||------------|||||------------||||---||
sequence 38 GC----GGCC-ACGCCG---GA------------GATAC------------CAGT---TC
transcrip 186 TAACA---CTCTGAGGGATAATTGATGAACCGTGTTTTCCGATAGGTATGTACAGTACCA
180 ---||---|||--|||-----|||--||--|-----||----------------||----
sequence 63 ---CACGCCTC--AGG-----TTG--GA--C-----TT----------------GT----
transcrip 243 CCACGCACGACTAAGGACCATTTTCTG--CGTGCGA 277
240 -----|||-|||-------------||--|--|||| 276
sequence 84 -----CAC-ACT-------------TGTAC--GCGA 99
""",
)
alignment = alignment1.map(alignment2)
self.assertEqual(alignment.coordinates.shape[1], 78)
self.assertEqual(
str(alignment),
"""\
chromosom 10 TTGGTTTTGGCTTAACTAGAAGCAA-CC-TGTAAGATTGCCAATTCTTCAGTCGAAGTAA
0 |.------------------------||-|---------------||--------|----
sequence 0 TC-----------------------CCCTT---------------CT--------A----
chromosom 68 ATCTTCAATGTTTTGGACTCTTAGCGGATATGCGGCTGAGAAGTACGACATGTGTA----
60 ------|------||||-------------------------------------------
sequence 10 ------A------TGGA---------------------------------------ATCC
chromosom 124 --CATTCATAC--CTGCGT----GACGGTCAGCCT--CCCCCG--GGACCTCATTGGGCG
120 --|--||---|--.-|-||----||-----|||----||-.||--|---------|----
sequence 19 CCC--TC---CGAA-G-GTCGCAGA-----AGC--GGCC-ACGCCG---------G----
chromosom 172 AATCTAGGTGT-GATAATTGACA-CAC--TCTTGGTAAGAAGCA---CTCT---TTACCC
180 ------------||||--------||---||-----------||---|||----||----
sequence 51 -----------AGATA-------CCA-GTTC-----------CACGCCTC-AGGTT----
chromosom 222 GATCTCCAAGTACCGACGCCAAGGCCAAGCTCTGCGATCTAAAGCTGCCGATCGTAGATC
240 |--------|.--|----------------------------------------------
sequence 76 G--------GA--C----------------------------------------------
chromosom 282 CAA--GTCCTCAGCAAGCTCGCACGAATACGCAGTTCGAAGGCTG--GGTGTTGTACGA
300 -----||--------------|||-|.|---------------||--.--|-----|||
sequence 80 ---TTGT--------------CAC-ACT---------------TGTAC--G-----CGA
chromosom 337
359
sequence 99
""",
)
line = format(alignment, "psl")
self.assertEqual(
line,
"""\
61 6 0 0 14 32 28 260 + sequence 100 0 99 chromosome 440 10 337 35 2,2,1,2,1,1,4,1,2,1,1,1,2,2,3,2,3,1,1,4,2,2,2,3,2,1,2,1,2,3,3,2,1,1,3, 0,3,6,7,9,10,11,21,22,24,27,28,29,35,37,42,44,49,50,52,57,61,63,68,74,76,77,79,82,84,87,90,94,95,96, 10,35,37,53,63,74,81,124,127,132,133,135,137,139,146,151,154,157,167,183,194,197,210,212,216,222,231,235,285,301,305,323,325,328,334,
""",
)
def map_check(alignment1, alignment2):
line1 = format(alignment1, "psl")
handle = open("transcript.psl", "w")
handle.write(line1)
handle.close()
line2 = format(alignment2, "psl")
handle = open("sequence.psl", "w")
handle.write(line2)
handle.close()
stdout = os.popen("pslMap sequence.psl transcript.psl stdout")
line = stdout.read()
os.remove("transcript.psl")
os.remove("sequence.psl")
return line
def test_random(aligner, nBlocks1=1, nBlocks2=1, strand1="+", strand2="+"):
chromosome = "".join(["ACGT"[random.randint(0, 3)] for i in range(1000)])
nBlocks = nBlocks1
transcript = ""
position = 0
for i in range(nBlocks):
position += random.randint(60, 80)
blockSize = random.randint(60, 80)
transcript += chromosome[position : position + blockSize]
position += blockSize
nBlocks = nBlocks2
sequence = ""
position = 0
for i in range(nBlocks):
position += random.randint(20, 40)
blockSize = random.randint(20, 40)
sequence += transcript[position : position + blockSize]
position += blockSize
chromosome = Seq(chromosome)
transcript = Seq(transcript)
sequence = Seq(sequence)
if strand1 == "-":
chromosome = chromosome.reverse_complement()
if strand2 == "-":
sequence = sequence.reverse_complement()
chromosome.id = "chromosome"
transcript.id = "transcript"
sequence.id = "sequence"
alignments1 = aligner.align(chromosome, transcript, strand=strand1)
alignment1 = alignments1[0]
alignments2 = aligner.align(transcript, sequence, strand=strand2)
alignment2 = alignments2[0]
alignment = alignment1.map(alignment2)
line_check = map_check(alignment1, alignment2)
line = format(alignment, "psl")
assert line == line_check
print("Randomized test %d, %d, %s, %s OK" % (nBlocks1, nBlocks2, strand1, strand2))
def test_random_sequences(aligner, strand1="+", strand2="+"):
chromosome = "".join(["ACGT"[random.randint(0, 3)] for i in range(1000)])
transcript = "".join(["ACGT"[random.randint(0, 3)] for i in range(300)])
sequence = "".join(["ACGT"[random.randint(0, 3)] for i in range(100)])
chromosome = Seq(chromosome)
transcript = Seq(transcript)
sequence = Seq(sequence)
chromosome.id = "chromosome"
transcript.id = "transcript"
sequence.id = "sequence"
alignments = aligner.align(chromosome, transcript, strand=strand1)
alignment1 = alignments[0]
alignments = aligner.align(transcript, sequence, strand=strand2)
alignment2 = alignments[0]
line_check = map_check(alignment1, alignment2)
alignment = alignment1.map(alignment2)
line_check = line_check.split()
line = format(alignment, "psl")
line = line.split()
assert line[8:] == line_check[8:]
line1 = format(alignment1, "psl")
words = line1.split()
nBlocks1 = int(words[17])
line2 = format(alignment2, "psl")
words = line2.split()
nBlocks2 = int(words[17])
print(
"Randomized sequence test %d, %d, %s, %s OK"
% (nBlocks1, nBlocks2, strand1, strand2)
)
def perform_randomized_tests(n=1000):
"""Perform randomized tests and compare to pslMap.
Run this function to perform 8 x n mappings for alignments of randomly
generated sequences, get the alignment in PSL format, and compare the
result to that of pslMap.
"""
aligner = PairwiseAligner()
aligner.internal_open_gap_score = -1
aligner.internal_extend_gap_score = -0.0
aligner.match_score = +1
aligner.mismatch_score = -1
aligner.mode = "local"
for i in range(n):
nBlocks1 = random.randint(1, 10)
nBlocks2 = random.randint(1, 10)
test_random(aligner, nBlocks1, nBlocks2, "+", "+")
test_random(aligner, nBlocks1, nBlocks2, "+", "-")
test_random(aligner, nBlocks1, nBlocks2, "-", "+")
test_random(aligner, nBlocks1, nBlocks2, "-", "-")
test_random_sequences(aligner, "+", "+")
test_random_sequences(aligner, "+", "-")
test_random_sequences(aligner, "-", "+")
test_random_sequences(aligner, "-", "-")
class TestZeroGaps(unittest.TestCase):
def test1(self):
coordinates = np.array([[0, 3, 6, 9], [0, 3, 6, 9]])
sequences = [
SeqRecord(Seq(None, 9), id="genome"),
SeqRecord(Seq(None, 9), id="mRNA"),
]
alignment1 = Alignment(sequences, coordinates)
coordinates = np.array([[0, 9], [0, 9]])
sequences = [
SeqRecord(Seq(None, 9), id="mRNA"),
SeqRecord(Seq(None, 9), id="tag"),
]
alignment2 = Alignment(sequences, coordinates)
alignment = alignment1.map(alignment2)
self.assertTrue(
np.array_equal(
alignment.coordinates, np.array([[0, 3, 6, 9], [0, 3, 6, 9]])
)
)
def test2(self):
coordinates = np.array([[0, 69], [0, 69]])
sequences = [
SeqRecord(Seq(None, 69), id="genome"),
SeqRecord(Seq(None, 69), id="mRNA"),
]
alignment1 = Alignment(sequences, coordinates)
coordinates = np.array([[0, 24, 24, 69], [0, 24, 24, 69]])
sequences = [
SeqRecord(Seq(None, 69), id="mRNA"),
SeqRecord(Seq(None, 68), id="tag"),
]
alignment2 = Alignment(sequences, coordinates)
alignment = alignment1.map(alignment2)
# fmt: off
self.assertTrue(
np.array_equal(alignment.coordinates,
np.array([[0, 24, 69], # noqa: E128
[0, 24, 69]]))
)
# fmt: on
def test3(self):
coordinates = np.array([[0, 69], [0, 69]])
sequences = [
SeqRecord(Seq(None, 69), id="genome"),
SeqRecord(Seq(None, 69), id="mRNA"),
]
alignment1 = Alignment(sequences, coordinates)
coordinates = np.array([[0, 24, 24, 69], [0, 24, 23, 68]])
sequences = [
SeqRecord(Seq(None, 69), id="mRNA"),
SeqRecord(Seq(None, 68), id="tag"),
]
alignment2 = Alignment(sequences, coordinates)
alignment = alignment1.map(alignment2)
# fmt: off
self.assertTrue(
np.array_equal(alignment.coordinates,
np.array([[0, 24, 24, 69], # noqa: E128
[0, 24, 23, 68]]))
)
# fmt: on
def test4(self):
coordinates = np.array([[0, 210], [0, 210]])
sequences = [
SeqRecord(Seq(None, 210), id="genome"),
SeqRecord(Seq(None, 210), id="mRNA"),
]
alignment1 = Alignment(sequences, coordinates)
coordinates = np.array([[0, 18, 18, 102, 102, 210], [0, 18, 17, 101, 100, 208]])
sequences = [
SeqRecord(Seq(None, 210), id="mRNA"),
SeqRecord(Seq(None, 208), id="tag"),
]
alignment2 = Alignment(sequences, coordinates)
alignment = alignment1.map(alignment2)
# fmt: off
self.assertTrue(
np.array_equal(alignment.coordinates,
np.array([[0, 18, 18, 102, 102, 210],
[0, 18, 17, 101, 100, 208]]))
)
# fmt: on
def test5(self):
coordinates = np.array([[0, 210], [0, 210]])
sequences = [
SeqRecord(Seq(None, 210), id="genome"),
SeqRecord(Seq(None, 210), id="mRNA"),
]
alignment1 = Alignment(sequences, coordinates)
coordinates = np.array([[0, 51, 51, 210], [0, 51, 49, 208]])
sequences = [
SeqRecord(Seq(None, 210), id="mRNA"),
SeqRecord(Seq(None, 208), id="tag"),
]
alignment2 = Alignment(sequences, coordinates)
alignment = alignment1.map(alignment2)
# fmt: off
self.assertTrue(
np.array_equal(alignment.coordinates,
np.array([[0, 51, 51, 210],
[0, 51, 49, 208]]))
)
# fmt: on
class TestLiftOver(unittest.TestCase):
def test_chimp(self):
chain = Align.read("Blat/panTro5ToPanTro6.over.chain", "chain")
alignment = Align.read("Blat/est.panTro5.psl", "psl")
self.assertEqual(chain.target.id, alignment.target.id)
self.assertEqual(len(chain.target.seq), len(alignment.target.seq))
chain = chain[::-1]
record = SeqIO.read("Blat/est.fa", "fasta")
self.assertEqual(record.id, alignment.query.id)
self.assertEqual(len(record.seq), len(alignment.query.seq))
alignment.query = record.seq
record = SeqIO.read("Blat/panTro5.fa", "fasta")
chromosome, start_end = record.id.split(":")
start, end = start_end.split("-")
start = int(start)
end = int(end)
data = {start: str(record.seq)}
length = len(alignment.target.seq)
seq = Seq(data, length=length)
record = SeqRecord(seq, id="chr1")
alignment.target = record
text = """^\
chr1 122835789 AGAGATTATTTTGCAGAGGATGATGGGGAGATGGTACCCAGAACGAGTCACACAGCAGGT
0 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::--
query 32 AGAGATTATTTTGCAGAGGATGATGGGGAGATGGTACCCAGAACGAGTCACACAGCAG--
chr1 122835849 AAGGATGCTGTGGGCCTTGCCTTGTTAAATTCTTTGtttcttttgtttattcatttggtt
60 ------------------------------------------------------------
query 90 ------------------------------------------------------------
((.|\n)*)
chr1 122840889 TTGTATTTTGCAGAAACTGAATTCTGCTGGAATGTGCCAGTTAGAATGATCCTAGTGCTG
5100 ------------------------------------------------------------
query 90 ------------------------------------------------------------
chr1 122840949 TTATTATATAAACCTTTTTTGTTGTTGTTCTGTTTCATTGACAGCTTTTCTTAGTGACAC
5160 --------------------------------------------::::::::::::::::
query 90 --------------------------------------------CTTTTCTTAGTGACAC
chr1 122841009 TAAAGATCGAGGCCCTCCAGTGCAGTCACAGATCTGGAGAAGTGGTGAAAAGGTCCCGTT
5220 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::X:
query 106 TAAAGATCGAGGCCCTCCAGTGCAGTCACAGATCTGGAGAAGTGGTGAAAAGGTCCCGNT
chr1 122841069 TGTGCAGACATATTCCTTGAGAGCATTTGAGAAACCCCCTCAGGTACAGACCCAGGCTCT
5280 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
query 166 TGTGCAGACATATTCCTTGAGAGCATTTGAGAAACCCCCTCAGGTACAGACCCAGGCTCT
chr1 122841129 TCGAGACTTTGAGAAGGTAAGTCATGTGAGTGGATAATTGTTATCCCAATTAGAAGCAGT
5340 ::::::::::::::::--------------------------------------------
query 226 TCGAGACTTTGAGAAG--------------------------------------------
chr1 122841189 ACTATGGAATAGTGATGCCTGATAAAAATATGACCCATGGATTGGTCCGGATTATGGATG
5400 ------------------------------------------------------------
query 242 ------------------------------------------------------------
((.|\n)*)
chr1 122907129 GTTCTTGGGTTGAGGGGGCAATCGGGCACGCTCCTCCCCATGGGTTGCCCATCATGTCTA
71340 ------------------------------------------------------------
query 242 ------------------------------------------------------------
chr1 122907189 ATGGATATCGCACTCTGTCCCAGCACCTCAATGACCTGAAGAAGGAGAACTTCAGCCTCA
71400 -----------------------:::::::::::::::::::::::::::::::::::::
query 242 -----------------------CACCTCAATGACCTGAAGAAGGAGAACTTCAGCCTCA
chr1 122907249 AGCTGCGCATCTACTTCCTGGAGGAGCGCATGCAACAGAAGTATGAGGCCAGCCGGGAGG
71460 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
query 279 AGCTGCGCATCTACTTCCTGGAGGAGCGCATGCAACAGAAGTATGAGGCCAGCCGGGAGG
chr1 122907309 ACATC 122907314
71520 ::::: 71525
query 339 ACATC 344
$"""
self.assertRegex(str(alignment).replace("|", ":").replace(".", "X"), text)
lifted_alignment = chain.map(alignment)
# fmt: off
self.assertTrue(
np.array_equal(lifted_alignment.coordinates,
np.array([[111982717, 111982775, 111987921,
111988073, 112009200, 112009302],
[ 32, 90, 90,
242, 242, 344]])
)
)
# fmt: on
record = SeqIO.read("Blat/panTro6.fa", "fasta")
chromosome, start_end = record.id.split(":")
start, end = start_end.split("-")
start = int(start)
end = int(end)
data = {start: str(record.seq)}
length = len(alignment.target.seq)
seq = Seq(data, length=length)
record = SeqRecord(seq, id="chr1")
lifted_alignment.target = record
text = """^\
chr1 111982717 AGAGATTATTTTGCAGAGGATGATGGGGAGATGGTACCCAGAACGAGTCACACAGCAGGT
0 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::--
query 32 AGAGATTATTTTGCAGAGGATGATGGGGAGATGGTACCCAGAACGAGTCACACAGCAG--
chr1 111982777 AAGGATGCTGTGGGCCTTGCCTTGTTAAATTCTTTGtttcttttgtttattcatttggtt
60 ------------------------------------------------------------
query 90 ------------------------------------------------------------
((.|\n)*)
chr1 111987817 TTGTATTTTGCAGAAACTGAATTCTGCTGGAATGTGCCAGTTAGAATGATCCTAGTGCTG
5100 ------------------------------------------------------------
query 90 ------------------------------------------------------------
chr1 111987877 TTATTATATAAACCTTTTTTGTTGTTGTTCTGTTTCATTGACAGCTTTTCTTAGTGACAC
5160 --------------------------------------------::::::::::::::::
query 90 --------------------------------------------CTTTTCTTAGTGACAC
chr1 111987937 TAAAGATCGAGGCCCTCCAGTGCAGTCACAGATCTGGAGAAGTGGTGAAAAGGTCCCGTT
5220 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::X:
query 106 TAAAGATCGAGGCCCTCCAGTGCAGTCACAGATCTGGAGAAGTGGTGAAAAGGTCCCGNT
chr1 111987997 TGTGCAGACATATTCCTTGAGAGCATTTGAGAAACCCCCTCAGGTACAGACCCAGGCTCT
5280 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
query 166 TGTGCAGACATATTCCTTGAGAGCATTTGAGAAACCCCCTCAGGTACAGACCCAGGCTCT
chr1 111988057 TCGAGACTTTGAGAAGGTAAGTCATGTGAGTGGATAATTGTTATCCCAATTAGAAGCAGT
5340 ::::::::::::::::--------------------------------------------
query 226 TCGAGACTTTGAGAAG--------------------------------------------
chr1 111988117 ACTATGGAATAGTGATGCCTGATAAAAATATGACCCATGGATTGGTCCGGATTATGGATG
5400 ------------------------------------------------------------
query 242 ------------------------------------------------------------
((.|\n)*)
chr1 112009117 GTTCTTGGGTTGAGGGGGCAATCGGGCACGCTCCTCCCCATGGGTTGCCCATCATGTCTA
26400 ------------------------------------------------------------
query 242 ------------------------------------------------------------
chr1 112009177 ATGGATATCGCACTCTGTCCCAGCACCTCAATGACCTGAAGAAGGAGAACTTCAGCCTCA
26460 -----------------------:::::::::::::::::::::::::::::::::::::
query 242 -----------------------CACCTCAATGACCTGAAGAAGGAGAACTTCAGCCTCA
chr1 112009237 AGCTGCGCATCTACTTCCTGGAGGAGCGCATGCAACAGAAGTATGAGGCCAGCCGGGAGG
26520 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
query 279 AGCTGCGCATCTACTTCCTGGAGGAGCGCATGCAACAGAAGTATGAGGCCAGCCGGGAGG
chr1 112009297 ACATC 112009302
26580 ::::: 26585
query 339 ACATC 344
$"""
self.assertRegex(
str(lifted_alignment).replace("|", ":").replace(".", "X"), text
)
if __name__ == "__main__":
runner = unittest.TextTestRunner(verbosity=2)
unittest.main(testRunner=runner)
|