Mercurial > repos > iuc > variant_analyzer
comparison mut2sscs.py @ 1:3556001ff2db draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/variant_analyzer commit 60dc8db809909edf44d662683b1f392b9d5964bf"
| author | iuc |
|---|---|
| date | Wed, 04 Dec 2019 16:21:17 -0500 |
| parents | 8d29173d49a9 |
| children | 3f1dbd2c59bf |
comparison
equal
deleted
inserted
replaced
| 0:8d29173d49a9 | 1:3556001ff2db |
|---|---|
| 54 if os.path.isfile(file2) is False: | 54 if os.path.isfile(file2) is False: |
| 55 sys.exit("Error: Could not find '{}'".format(file2)) | 55 sys.exit("Error: Could not find '{}'".format(file2)) |
| 56 | 56 |
| 57 # 1. read mut file | 57 # 1. read mut file |
| 58 with open(file1, 'r') as mut: | 58 with open(file1, 'r') as mut: |
| 59 mut_array = np.genfromtxt(mut, skip_header=1, delimiter='\t', comments='#', dtype='string') | 59 mut_array = np.genfromtxt(mut, skip_header=1, delimiter='\t', comments='#', dtype=str) |
| 60 | 60 |
| 61 # 2 read SSCS bam file | 61 # 2 read SSCS bam file |
| 62 # pysam.index(file2) | 62 # pysam.index(file2) |
| 63 bam = pysam.AlignmentFile(file2, "rb") | 63 bam = pysam.AlignmentFile(file2, "rb") |
| 64 | 64 |
| 74 stop_pos = mut_array[m, 2].astype(int) | 74 stop_pos = mut_array[m, 2].astype(int) |
| 75 chrom_stop_pos = str(chrom) + "#" + str(stop_pos) | 75 chrom_stop_pos = str(chrom) + "#" + str(stop_pos) |
| 76 ref = mut_array[m, 9] | 76 ref = mut_array[m, 9] |
| 77 alt = mut_array[m, 10] | 77 alt = mut_array[m, 10] |
| 78 | 78 |
| 79 for pileupcolumn in bam.pileup(chrom.tobytes(), stop_pos - 2, stop_pos, max_depth=1000000000): | 79 for pileupcolumn in bam.pileup(chrom, stop_pos - 2, stop_pos, max_depth=1000000000): |
| 80 if pileupcolumn.reference_pos == stop_pos - 1: | 80 if pileupcolumn.reference_pos == stop_pos - 1: |
| 81 count_alt = 0 | 81 count_alt = 0 |
| 82 count_ref = 0 | 82 count_ref = 0 |
| 83 count_indel = 0 | 83 count_indel = 0 |
| 84 print("unfiltered reads=", pileupcolumn.n, "filtered reads=", len(pileupcolumn.pileups), | 84 print("unfiltered reads=", pileupcolumn.n, "filtered reads=", len(pileupcolumn.pileups), |
