diff mut2sscs.py @ 43:d21960b45a6b draft

planemo upload for repository https://github.com/Single-Molecule-Genetics/VariantAnalyzerGalaxy/tree/master/tools/variant_analyzer commit ee4a8e6cf290e6c8a4d55f9cd2839d60ab3b11c8
author mheinzl
date Tue, 02 Mar 2021 15:32:41 +0000
parents 84a1a3f70407
children 6ccff403db8a
line wrap: on
line diff
--- a/mut2sscs.py	Wed Feb 24 14:20:17 2021 +0000
+++ b/mut2sscs.py	Tue Mar 02 15:32:41 2021 +0000
@@ -11,7 +11,7 @@
 
 =======  ==========  =================  ================================
 Version  Date        Author             Description
-2.0.0    2020-10-30  Gundula Povysil    -
+0.2.1    2019-10-27  Gundula Povysil    -
 =======  ==========  =================  ================================
 
 USAGE: python mut2sscs.py DCS_Mutations.tabular SSCS.bam SSCS_counts.json
@@ -25,6 +25,7 @@
 import os
 import sys
 
+import numpy as np
 import pysam
 from cyvcf2 import VCF
 
@@ -55,6 +56,7 @@
         sys.exit("Error: Could not find '{}'".format(file2))
 
     # read SSCS bam file
+#    pysam.index(file2)
     bam = pysam.AlignmentFile(file2, "rb")
 
     # get tags
@@ -66,10 +68,14 @@
         stop_pos = variant.start
         #chrom_stop_pos = str(chrom) + "#" + str(stop_pos)
         ref = variant.REF
-        alt = variant.ALT[0]
+        if len(variant.ALT) == 0:
+            continue
+        else:
+            alt = variant.ALT[0]
         chrom_stop_pos = str(chrom) + "#" + str(stop_pos) + "#" + ref + "#" + alt
 
         if len(ref) == len(alt):
+
             for pileupcolumn in bam.pileup(chrom, stop_pos - 1, stop_pos + 1, max_depth=1000000000):
                 if pileupcolumn.reference_pos == stop_pos:
                     count_alt = 0
@@ -131,3 +137,4 @@
 
 if __name__ == '__main__':
     sys.exit(mut2sscs(sys.argv))
+