def test_index_genome_alig(self, mock_open):
    """Do a full round trip test for a simple whole-genome alignment."""
    in_strm = StringIO.StringIO(self.ga_maf1)
    idx_strm = StringIO.StringIO()

    # replace open with mock
    def open_side_effect(*args, **kwargs):
      if not isinstance(args[0], basestring):
        raise TypeError()
      if args[0] == "one.maf":
        return in_strm
      elif args[0] == "one.idx":
        return idx_strm
      raise IOError("No such file")

    mock_open.side_effect = open_side_effect
    main(["build", "-o", "one.idx", "one.maf"])
    idx_strm.seek(0)
    in_strm.seek(0)
    ga = build_genome_alignment_from_file("one.maf", "hg19", "one.idx")
    b1_res = ga.get_blocks("chr22", 1711, 1720)[0]
    b2_res = ga.get_blocks("chr22", 1770, 1780)[0]
    self.assertEqual(b1_res["hg19.chr22"], self.b1_hg19)
    self.assertEqual(b2_res["hg19.chr22"], self.b2_hg19)
def test_index_genome_alig ( self , mock_open ) : in_strm = StringIO . StringIO ( self . ga_maf1 ) idx_strm = StringIO . StringIO ( ) def open_side_effect ( * args , ** kwargs ) : if not isinstance ( args [ 0 ] , basestring ) : raise TypeError ( ) if args [ 0 ] == "one.maf" : return in_strm elif args [ 0 ] == "one.idx" : return idx_strm raise IOError ( "No such file" ) mock_open . side_effect = open_side_effect main ( [ "build" , "-o" , "one.idx" , "one.maf" ] ) idx_strm . seek ( 0 ) in_strm . seek ( 0 ) ga = build_genome_alignment_from_file ( "one.maf" , "hg19" , "one.idx" ) b1_res = ga . get_blocks ( "chr22" , 1711 , 1720 ) [ 0 ] b2_res = ga . get_blocks ( "chr22" , 1770 , 1780 ) [ 0 ] self . assertEqual ( b1_res [ "hg19.chr22" ] , self . b1_hg19 ) self . assertEqual ( b2_res [ "hg19.chr22" ] , self . b2_hg19 )
Do a full round trip test for a simple whole-genome alignment.