diff --git a/tools/sr_mapping/bowtie_wrapper.xml b/tools/sr_mapping/bowtie_wrapper.xml
index acbc1c7719e..f77c9973914 100644
--- a/tools/sr_mapping/bowtie_wrapper.xml
+++ b/tools/sr_mapping/bowtie_wrapper.xml
@@ -152,7 +152,6 @@
-
@@ -540,4 +539,5 @@ For aligning (bowtie)::
--seed <int> Random seed. Use <int> as the seed for the pseudo-random number generator. [off]
+
diff --git a/tools/sr_mapping/bowtie_wrapper_code.py b/tools/sr_mapping/bowtie_wrapper_code.py
new file mode 100644
index 00000000000..21a8f6b44eb
--- /dev/null
+++ b/tools/sr_mapping/bowtie_wrapper_code.py
@@ -0,0 +1,15 @@
+import os
+
+def exec_before_job(app, inp_data, out_data, param_dict, tool):
+ try:
+ refFile = param_dict['refGenomeSource']['indices'].value
+ dbkey = os.path.split(refFile)[1].split('.')[0]
+ # deal with the one odd case
+ if dbkey.find('chrM') >= 0:
+ dbkey = 'equCab2'
+ out_data['output'].set_dbkey(dbkey)
+ except:
+ try:
+ refFile = param_dict['refGenomeSource']['ownFile'].dbkey
+ except:
+ out_data['output'].set_dbkey('?')
diff --git a/tools/sr_mapping/bwa_wrapper.xml b/tools/sr_mapping/bwa_wrapper.xml
index ccfb55bb26b..41fefbabd47 100644
--- a/tools/sr_mapping/bwa_wrapper.xml
+++ b/tools/sr_mapping/bwa_wrapper.xml
@@ -80,7 +80,6 @@
-
@@ -100,7 +99,6 @@
-
diff --git a/tools/sr_mapping/bwa_wrapper_code.py b/tools/sr_mapping/bwa_wrapper_code.py
index a8e19e6bc77..cecaa528838 100644
--- a/tools/sr_mapping/bwa_wrapper_code.py
+++ b/tools/sr_mapping/bwa_wrapper_code.py
@@ -4,5 +4,8 @@ def exec_before_job(app, inp_data, out_data, param_dict, tool):
try:
refFile = param_dict['solidOrSolexa']['solidRefGenomeSource']['indices'].value
out_data['output'].set_dbkey(os.path.split(refFile)[1].split('.')[0])
- except Exception, eq:
- out_data['output'].set_dbkey(param_dict['dbkey'])
+ except:
+ try:
+ refFile = param_dict['solidOrSolexa']['solidRefGenomeSource']['ownFile'].dbkey
+ except:
+ out_data['output'].set_dbkey('?')