def count_reads_in_features(sam_filename, gff_filename, samtype, order, stranded, overlap_mode, feature_type, id_attribute, quiet, minaqual, samout, directory): forward = stranded in ["yes", "both"] reverse = stranded in ["reverse", "both"] is_stranded = stranded != "NO" if samout != "" and stranded == "both": raise Exception("Output SAM alignment records not supported " "for stranded 'both'") if samtype == "bam": extensions = [".bam"] elif samtype == "sam": extensions = [".sam", ".sam.gz"] else: extensions = [".bam", ".sam", ".sam.gz"] files = brenninc_utils.find_files(sam_filename, extensions=extensions, recursive=True) features, counts = get_features(gff_filename, is_stranded, feature_type, id_attribute, quiet) for a_file in files: if samout == "auto": samout_file = brenninc_utils.create_new_file(sam_filename, "_annotated", outputdir=directory, extension="sam", gzipped=False) else: samout_file = samout print "counting", a_file count_reads(a_file, features, counts, samtype, order, forward, reverse, overlap_mode, quiet, minaqual, samout_file, directory)
def count_reads_in_features(sam_filename, gff_filename, samtype, order, stranded, overlap_mode, feature_type, id_attribute, quiet, minaqual, samout, directory): forward = stranded in ["yes", "both"] reverse = stranded in ["reverse", "both"] is_stranded = stranded != "NO" if samout != "" and stranded == "both": raise Exception("Output SAM alignment records not supported " "for stranded 'both'") if samtype == "bam": extensions = [".bam"] elif samtype == "sam": extensions = [".sam", ".sam.gz"] else: extensions = [".bam", ".sam", ".sam.gz"] files = brenninc_utils.find_files(sam_filename, extensions=extensions, recursive=True) features, counts = get_features(gff_filename, is_stranded, feature_type, id_attribute, quiet) for a_file in files: if samout == "auto": samout_file = brenninc_utils.create_new_file(sam_filename, "_annotated", outputdir=directory, extension="sam", gzipped=False) else: samout_file = samout print "counting", a_file count_reads(a_file, features, counts, samtype, order, forward, reverse, overlap_mode, quiet, minaqual, samout_file, directory)
def makehead(path, sequences=100, outputdir=None, qual_scale=_default_qual_scale): files = brenninc_utils.find_files(path, ["fastq", "fastq.gz"]) for afile in files: head(path=afile, sequences=sequences, outputdir=outputdir, qual_scale=qual_scale)
def count_reads_in_features(sam_filename, gff_filename, samtype, order, stranded, overlap_mode, feature_type, id_attribute, quiet, minaqual, samout, directory): if samtype == "bam": extensions = [".bam"] elif samtype == "sam": extensions = [".sam", ".sam.gz"] else: extensions = [".bam", ".sam", ".sam.gz"] files = brenninc_utils.find_files(sam_filename, extensions=extensions, recursive=True) (features, counts) = get_features(gff_filename, stranded, feature_type, id_attribute, quiet) for a_file in files: print "counting", a_file count_reads_using_features(a_file, features, counts, samtype, order, stranded, overlap_mode, quiet, minaqual, samout, directory)
def count_reads_in_features(sam_filename, gff_filename, samtype, order, stranded, overlap_mode, feature_type, id_attribute, quiet, minaqual, samout, directory): if samtype == "bam": extensions = [".bam"] elif samtype == "sam": extensions = [".sam", ".sam.gz"] else: extensions = [".bam", ".sam", ".sam.gz"] files = brenninc_utils.find_files(sam_filename, extensions=extensions, recursive=True) (features, counts) = get_features(gff_filename, stranded, feature_type, id_attribute, quiet) for a_file in files: print "counting", a_file count_reads_using_features(a_file, features, counts, samtype, order, stranded, overlap_mode, quiet, minaqual, samout, directory)
def test_txt(self): fileList = brenninc_utils.find_files(os.getcwd(), extensions="txt") found = check_files_for_ending(fileList, "brenninc_utils_test.py") self.assertFalse(found)
def pathsort(path, outputdir=None, qual_scale=_default_qual_scale): files = brenninc_utils.find_files(path, ["fastq", "fastq.gz"]) for afile in files: sort(fastq_file=afile, outputdir=outputdir, qual_scale=qual_scale)
def count_alignments(path=os.getcwd(), output_file=None): files = brenninc_utils.find_files(path, ['sam', 'sam.gz']) with brenninc_utils.smart_open(output_file) as handle: for sam_file in files: count_single_file(sam_file, handle)
def makehead(path, sequences=100, outputdir=None, qual_scale=_default_qual_scale): files = brenninc_utils.find_files(path, ["fastq", "fastq.gz"]) for afile in files: head(path=afile, sequences=sequences, outputdir=outputdir, qual_scale=qual_scale)
def count_alignments(path=os.getcwd(), output_file=None): files = brenninc_utils.find_files(path, ['sam', 'sam.gz']) with brenninc_utils.smart_open(output_file) as handle: for sam_file in files: count_single_file(sam_file, handle)
def test_parent(self): parent = os.path.dirname(os.getcwd()) fileList = brenninc_utils.find_files(parent) found = check_files_for_ending(fileList, "brenninc_utils_test.py") self.assertFalse(found)
def test_parent_recursive(self): parent = os.path.dirname(os.getcwd()) fileList = brenninc_utils.find_files(parent, recursive=True) found = check_files_for_ending(fileList, "brenninc_utils_test.py") self.assertTrue(found)
def test_all(self): fileList = brenninc_utils.find_files(os.getcwd()) found = check_files_for_ending(sorted(fileList), "brenninc_utils_test.py") self.assertTrue(found)
def test_txt_py(self): fileList = brenninc_utils.find_files(os.getcwd(), extensions=["txt", ".py"]) found = check_files_for_ending(fileList, "brenninc_utils_test.py") self.assertTrue(found)
def test_all(self): fileList = brenninc_utils.find_files(os.getcwd()) found = check_files_for_ending(sorted(fileList), "brenninc_utils_test.py") self.assertTrue(found)
def test_parent_recursive(self): parent = os.path.dirname(os.getcwd()) fileList = brenninc_utils.find_files(parent, recursive=True) found = check_files_for_ending(fileList, "brenninc_utils_test.py") self.assertTrue(found)
def test_parent(self): parent = os.path.dirname(os.getcwd()) fileList = brenninc_utils.find_files(parent) found = check_files_for_ending(fileList, "brenninc_utils_test.py") self.assertFalse(found)
def test_txt_py(self): fileList = brenninc_utils.find_files(os.getcwd(), extensions=["txt", ".py"]) found = check_files_for_ending(fileList, "brenninc_utils_test.py") self.assertTrue(found)
def test_txt(self): fileList = brenninc_utils.find_files(os.getcwd(), extensions="txt") found = check_files_for_ending(fileList, "brenninc_utils_test.py") self.assertFalse(found)