Skip to content

Commit

Permalink
adding minimap2 map-ont support
Browse files Browse the repository at this point in the history
  • Loading branch information
mitenjain committed Apr 4, 2018
1 parent 9fae385 commit 9455f48
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@
[submodule "submodules/cPecan"]
path = submodules/cPecan
url = https://github.com/benedictpaten/cPecan.git
[submodule "submodules/minimap2"]
path = submodules/minimap2
url = https://github.com/lh3/minimap2
2 changes: 1 addition & 1 deletion src/executionScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
export PYTHONPATH=${BASEDIR}/src:${BASEDIR}/submodules

#Set the path to just the relevant directories
export PATH=${BASEDIR}/submodules/sonLib/bin:${BASEDIR}/submodules/jobTree/bin:${BASEDIR}/submodules/bwa/:${BASEDIR}/submodules/last/src/:${BASEDIR}/submodules/last/scripts/:${PATH}
export PATH=${BASEDIR}/submodules/sonLib/bin:${BASEDIR}/submodules/jobTree/bin:${BASEDIR}/submodules/bwa/:${BASEDIR}/submodules/last/src/:${BASEDIR}/submodules/last/scripts/:${BASEDIR}/submodules/minimap2/:${PATH}

#Run described script
python $@
Expand Down
20 changes: 20 additions & 0 deletions src/margin/mappers/minimap2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from margin.mappers.abstractMapper import AbstractMapper
from sonLib.bioio import system
import os

class Minimap2(AbstractMapper):
def run(self, args="-ax map-ont"):
localReferenceFastaFile = os.path.join(self.getLocalTempDir(), "ref.fa") #Because BWA builds these crufty index files, copy to a temporary directory
system("cp %s %s" % (self.referenceFastaFile, localReferenceFastaFile))
system("minimap2 %s %s %s > %s" % (args, localReferenceFastaFile, self.readFastqFile, self.outputSamFile))

class Minimap2Chain(Minimap2):
def run(self):
Minimap2.run(self)
self.chainSamFile()

class Minimap2Realign(Minimap2):
def run(self):
Minimap2.run(self)
self.realignSamFile()

24 changes: 21 additions & 3 deletions src/margin/marginAlign.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from jobTree.scriptTree.stack import Stack
from margin.mappers.last import Last, LastChain, LastRealign
from margin.mappers.bwa import Bwa, BwaChain, BwaRealign
from margin.mappers.minimap2 import Minimap2, Minimap2Chain, Minimap2Realign
from margin.utils import pathToBaseNanoporeDir
import cPecan.cPecanEm
from cPecan.cPecanEm import addExpectationMaximisationOptions
Expand All @@ -30,6 +31,8 @@ def main():
default=0.5, type=float)
parser.add_option("--matchGamma", dest="matchGamma", help="Set the match gamma for the AMAP function",
default=0.0, type=float)
parser.add_option("--minimap2", dest="minimap2", help="Use minimap2 (map-ont) instead of LAST",
default=False, action="store_true")

#Add the cPecan expectation maximisation options
options = cPecan.cPecanEm.Options()
Expand Down Expand Up @@ -71,11 +74,26 @@ def main():
#Set the mapper
if options.noRealign:
if options.noChain: # i.e. --noChain --noRealign
mapper = Bwa if options.bwa else Last
if options.bwa:
mapper = Bwa
elif options.minimap2:
mapper = Minimap2
else:
mapper = Last
else: # i.e. --noRealign
mapper = BwaChain if options.bwa else LastChain
if options.bwa:
mapper = BwaChain
elif options.minimap2:
mapper = Minimap2Chain
else:
mapper = LastChain
else:
mapper = BwaRealign if options.bwa else LastRealign
if options.bwa:
mapper = BwaRealign
elif options.minimap2:
mapper = Minimap2Realign
else:
mapper = LastRealign

#This line invokes jobTree
i = Stack(mapper(readFastqFile=args[0], referenceFastaFile=args[1], outputSamFile=args[2],
Expand Down
2 changes: 1 addition & 1 deletion submodules/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# order is important, libraries first
modules = sonLib jobTree bwa last cPecan
modules = sonLib jobTree bwa last cPecan minimap2
.PHONY: all %.all clean %.clean

all : ${modules:%=all.%}
Expand Down
1 change: 1 addition & 0 deletions submodules/minimap2
Submodule minimap2 added at ee4cd0
6 changes: 6 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def testMarginAlignBwa(self):
def testMarginAlignBwaNoRealign(self):
self.runMarginAlign(self.readFastqFile1, self.referenceFastaFile1, "--bwa --noRealign")

def testMarginAlignMinimap2(self):
self.runMarginAlign(self.readFastqFile1, self.referenceFastaFile1, "--minimap2")

def testMarginAlignMinimap2NoRealign(self):
self.runMarginAlign(self.readFastqFile1, self.referenceFastaFile1, "--minimap2 --noRealign")

#The following tests marginCaller

def runMarginCaller(self, samFile, referenceFastaFile, mutationsFile, args=""):
Expand Down

0 comments on commit 9455f48

Please sign in to comment.