File: test_gfapy_line_containment.py

package info (click to toggle)
gfapy 1.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,932 kB
  • sloc: python: 11,549; sh: 167; makefile: 66
file content (51 lines) | stat: -rw-r--r-- 1,929 bytes parent folder | download | duplicates (4)
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
import unittest
import gfapy

class TestLineContainment(unittest.TestCase):

  def test_from_string(self):
    fields = ["C","1","+","2","-","12","12M","MQ:i:1232","NM:i:3","ab:Z:abcd"]
    string="\t".join(fields)
    gfapy.Line(string)
    self.assertIsInstance(gfapy.Line(string), gfapy.line.edge.Containment)
    self.assertEqual(fields[0], gfapy.Line(string).record_type)
    self.assertEqual(fields[1], gfapy.Line(string).from_segment)
    self.assertEqual(fields[2], gfapy.Line(string).from_orient)
    self.assertEqual(fields[3], gfapy.Line(string).to_segment)
    self.assertEqual(fields[4], gfapy.Line(string).to_orient)
    self.assertEqual(12, gfapy.Line(string).pos)
    self.assertEqual([gfapy.alignment.cigar.CIGAR.Operation(12, "M")],
                     gfapy.Line(string).overlap)
    self.assertEqual(1232, gfapy.Line(string).MQ)
    self.assertEqual(3, gfapy.Line(string).NM)
    self.assertEqual("abcd", gfapy.Line(string).ab)
    with self.assertRaises(gfapy.FormatError):
      gfapy.Line(string+"\tH1")
    with self.assertRaises(gfapy.FormatError):
      gfapy.Line(string+"\tH1")
    with self.assertRaises(gfapy.FormatError):
      gfapy.Line("C\tH")
    with self.assertRaises(gfapy.FormatError):
      f=fields[:]
      f[2]="x"
      gfapy.Line("\t".join(f), vlevel = 2)
    with self.assertRaises(gfapy.FormatError):
      f=fields[:]
      f[4]="x"
      gfapy.Line("\t".join(f), vlevel = 2)
    with self.assertRaises(gfapy.FormatError):
      f=fields[:]
      f[5]="x"
      gfapy.Line("\t".join(f), vlevel = 2)
    with self.assertRaises(gfapy.FormatError):
      f=fields[:]
      f[6]="x"
      gfapy.Line("\t".join(f), vlevel = 2)
    with self.assertRaises(gfapy.TypeError):
      f=fields[:]
      f[7]="MQ:Z:1232"
      gfapy.Line("\t".join(f), vlevel = 2)
    with self.assertRaises(gfapy.TypeError):
      f=fields[:]
      f[8]="NM:Z:1232"
      gfapy.Line("\t".join(f), vlevel = 2)