def check_bowtie_mapping(mapping,offset_or_nibble): """Generator function to test import of bowtie files under many read mapping rules Parameters ---------- mapping : str String specifying mapping rule. "fiveprime", "threeprime", "center", or "fiveprime_variable" offset_or_nibble : int or str Integer specifying offset or nibble (only for center mapping) or str specifying filename of variable offset dict text file """ # assure correct mapping function was applied # by comparing counts loaded from a bowtie file # under those map rules to a vector corresponding # to known answers for those rules argstr = "--countfile_format bowtie --count_files %s --%s " % (bowtiefilename, mapping) if mapping == "center": argstr += ("--nibble %s" % offset_or_nibble) else: argstr += ("--offset %s" % offset_or_nibble) args = alignment_file_parser.parse_args(shlex.split(argstr)) ga = get_genome_array_from_args(args) assert_greater(ga.sum(),0) check_genome_array_against_vector(ga,mapping,offset_or_nibble)
def test_alignment_parser_open_bam_makes_bamgenomearray(): argstr = "--countfile_format BAM --count_files %s --fiveprime" % bamfilename args = alignment_file_parser.parse_args(shlex.split(argstr)) assert_equal(bamfilename,args.count_files[0]) ga = get_genome_array_from_args(args) assert_true(isinstance(ga,BAMGenomeArray))
def check_bam_mapping(mapping,offset_or_nibble): """Generator function to test import of BAM files under many read mapping rules Parameters ---------- mapping : str String specifying mapping rule. "fiveprime", "threeprime", "center", or "fiveprime_variable" offset_or_nibble : int or str Integer specifying offset or nibble (only for center mapping) or str specifying filename of variable offset dict text file """ argstr = "--countfile_format BAM --count_files %s --%s " % (bamfilename, mapping) if mapping == "center": argstr += ("--nibble %s" % offset_or_nibble) else: argstr += ("--offset %s" % offset_or_nibble) mapdict = { "fiveprime" : FivePrimeMapFactory, "threeprime" : ThreePrimeMapFactory, "center" : CenterMapFactory, "fiveprime_variable" : VariableFivePrimeMapFactory, } args = alignment_file_parser.parse_args(shlex.split(argstr)) ga = get_genome_array_from_args(args) #assert_equal(mapping,ga.map_fn.__mapping__)a assert_true(isinstance(ga.map_fn,mapdict[mapping])) # assure correct mapping function was applied # by comparing counts loaded from a bowtie file # under those map rules to a vector corresponding # to known answers for those rules assert_greater(ga.sum(),0) check_genome_array_against_vector(ga,mapping,offset_or_nibble)
def alignment_parser_check_set_sum(fmt,filename): my_sum = 5 argstr = "--countfile_format %s --count_files %s --fiveprime --sum %s" % (fmt,filename,my_sum) args = alignment_file_parser.parse_args(shlex.split(argstr)) ga = get_genome_array_from_args(args) assert_equal(my_sum,ga.sum())
def alignment_parser_check_normalize(fmt,filename): argstr = "--countfile_format %s --count_files %s --fiveprime --normalize" % (fmt,filename) args = alignment_file_parser.parse_args(shlex.split(argstr)) ga = get_genome_array_from_args(args) assert_true(ga._normalize)
def test_alignment_parser_wiggle_with_sparsegenomearray(): argstr = "--countfile_format wiggle --count_files %s --big_genome" % wigglefilename args = alignment_file_parser.parse_args(shlex.split(argstr)) ga = get_genome_array_from_args(args) assert_true(isinstance(ga,SparseGenomeArray))
def test_alignment_parser_open_wiggle_makes_genomearray(): argstr = "--countfile_format wiggle --count_files %s" % wigglefilename args = alignment_file_parser.parse_args(shlex.split(argstr)) ga = get_genome_array_from_args(args) assert_true(isinstance(ga,GenomeArray))
def test_alignment_parser_open_bigwig_makes_bigwiggenomearray(): argstr = "--countfile_format bigwig --count_files %s" % bigwigfilename args = alignment_file_parser.parse_args(shlex.split(argstr)) ga = get_genome_array_from_args(args) assert_true(isinstance(ga,BigWigGenomeArray))