Example #1
0
    def testIsValidWithMetadata(self):
        # Create one valid DSV file
        content = """@title: test
#CHROM.POS.ID.REF.ALT.QUAL.FILTER
20.14370.rs6054257.G.A.29.PASS
20.17330.   ..A.3.q10 low

20.1110696.rs6040355.A.G,T.67.PASS
.1230237..T..47.
20.1234567.microsat1.GTC.G,GTCT.50.
......"""
        with open(self.tmp_out_dsv, "w") as FH_out:
            FH_out.write(content)
        # Check isValid
        self.assertTrue(not SVIO.isValid(self.tmp_out_dsv, ".", "@"))
        # Create one valid DSV file
        content = """@title: test
#CHROM.POS.ID.REF.ALT.QUAL.FILTER
20.14370.rs6054257.G.A.29.PASS
20.17330.   ..A.3.q10 low
20.1110696.rs6040355.A.G,T.67.PASS
.1230237..T..47.
20.1234567.microsat1.GTC.G,GTCT.50.
......"""
        with open(self.tmp_out_dsv, "w") as FH_out:
            FH_out.write(content)
        # Check isValid
        self.assertTrue(SVIO.isValid(self.tmp_out_dsv, ".", "@"))
        # Check if file pointer is ok in reopen
        observed_rows = []
        with open(self.tmp_out_dsv) as FH_in:
            for row_idx, readed_row in enumerate(FH_in):
                observed_rows.append(readed_row)
        self.assertEqual(content, "".join(observed_rows))
Example #2
0
 def testIsValidTrue(self):
     # Create one valid DSV file
     rows = deepcopy(self.data["rows"])
     rows.insert(0, self.data["titles"])
     rows.extend([
         ["1", "1234567", "microsat1", "GTC", "G,GTCT", "50", ""],
         ["1", "1234567", "microsat1", "GTC", "G,GTCT", "50", ""],
         ["1", "1234567", "microsat1", "GTC", "G,GTCT", "50", ""],
         ["1", "1234567", "microsat1", "GTC", "G,GTCT", "50", ""],
         ["1", "1234567", "microsat1", "GTC", "G,GTCT", "50", ""],
         ["1", "1234567", "microsat1", "GTC", "G,GTCT", "50", ""],
         ["1", "1234567", "microsat1", "GTC", "G,GTCT", "50", ""],
         ["1", "1234567", "microsat1", "GTC", "G,GTCT", "50", ""]
     ])
     with open(self.tmp_out_dsv, "w") as FH_out:
         for curr_row in rows:
             FH_out.write(".".join(curr_row) + "\n")
     # Check isValid
     self.assertEqual(True, SVIO.isValid(self.tmp_out_dsv, "."))
     # Check if fie pointer is ok in reopen
     with open(self.tmp_out_dsv) as FH_in:
         for row_idx, readed_row in enumerate(FH_in):
             expected_row = ".".join(rows[row_idx]) + "\n"
             self.assertEqual(expected_row, readed_row)