Mercurial > repos > jackcurragh > trips_viz_bam_to_sqlite
changeset 11:3d2b1532a1b0 draft
Uploaded
author | jackcurragh |
---|---|
date | Wed, 02 Nov 2022 14:52:17 +0000 |
parents | 78afd30c0cbf |
children | 02874b1b2015 |
files | trips_bam_to_sqlite/bam_to_sqlite.py |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/trips_bam_to_sqlite/bam_to_sqlite.py Tue Oct 25 08:19:05 2022 +0000 +++ b/trips_bam_to_sqlite/bam_to_sqlite.py Wed Nov 02 14:52:17 2022 +0000 @@ -250,13 +250,18 @@ master_offset_dict = {"fiveprime":{}, "threeprime":{}} master_metagene_stop_dict = {"fiveprime":{}, "threeprime":{}} + + os.system(f'samtools sort -n {bam_filepath} -o {bam_filepath}_n_sorted.bam') + pysam.set_verbosity(0) - infile = pysam.Samfile(bam_filepath, "rb") + infile = pysam.Samfile(f"{bam_filepath}_n_sorted.bam", "rb") + header = infile.header["HD"] - header = infile.header["HD"] unsorted = False if "SO" in header: + print("Sorting order: "+header["SO"]) if header["SO"] != "queryname": + print("Sorting order is not queryname") unsorted = True else: unsorted = True @@ -575,9 +580,6 @@ sys.exit() bam_filepath = sys.argv[1] annotation_sqlite_filepath = sys.argv[2] - #try: - # desc = sys.argv[3] - #except: - # desc = bam_filepath.split("/")[-1] - outputfile = bam_filepath+"v2.sqlite" + desc = sys.argv[3] + outputfile = sys.argv[4] process_bam(bam_filepath,annotation_sqlite_filepath,outputfile)