コード例 #1
0
    def loadReferenceAndModel(self, referencePath, cmpH5Path):

        # Load the reference contigs - annotated with their refID from the cmp.h5
        contigs = ReferenceUtils.loadReferenceContigs(referencePath, cmpH5Path)

        # Read reference info table from cmp.h5
        (refInfoTable, _) = ReferenceUtils.loadCmpH5Tables(cmpH5Path)
        self.refInfo = refInfoTable

        # There are three different ways the ipdModel can be loaded.
        # In order of precedence they are:
        # 1. Explicit path passed to --ipdModel
        # 2. Path to parameter bundle, model selected using the cmp.h5's chemistry info
        # 3. Fall back to built-in model.

        # By default, use built-in model
        ipdModel = None

        if self.args.ipdModel:
            ipdModel = self.args.ipdModel
            logging.info("Using passed in ipd model: %s" % self.args.ipdModel)
            if not os.path.exists(self.args.ipdModel):
                logging.error("Couldn't find model file: %s" %
                              self.args.ipdModel)

        elif self.args.paramsPath:
            if not os.path.exists(self.args.paramsPath):
                logging.error("Params path doesn't exist: %s" %
                              self.args.paramsPath)
                sys.exit(1)

            majorityChem = ReferenceUtils.loadCmpH5Chemistry(cmpH5Path)
            ipdModel = os.path.join(self.args.paramsPath, majorityChem + ".h5")

            if majorityChem == 'unknown':
                logging.warning(
                    "Chemistry is unknown. Falling back to built-in model")
                ipdModel = None
            elif not os.path.exists(ipdModel):
                logging.warning("Model not found: %s" % ipdModel)
                logging.warning("Falling back to built-in model")
                ipdModel = None
            else:
                logging.info("Using Chemistry matched IPD model: %s" %
                             ipdModel)

        self.ipdModel = IpdModel(contigs, ipdModel, self.args.modelIters)
コード例 #2
0
    def loadReferenceAndModel(self, referencePath, cmpH5Path):

        # Load the reference contigs - annotated with their refID from the cmp.h5
        contigs = ReferenceUtils.loadReferenceContigs(referencePath, cmpH5Path)

        # Read reference info table from cmp.h5
        (refInfoTable, _) = ReferenceUtils.loadCmpH5Tables(cmpH5Path)
        self.refInfo = refInfoTable

        # There are three different ways the ipdModel can be loaded.
        # In order of precedence they are:
        # 1. Explicit path passed to --ipdModel
        # 2. Path to parameter bundle, model selected using the cmp.h5's chemistry info
        # 3. Fall back to built-in model.

        # By default, use built-in model
        ipdModel = None

        if self.args.ipdModel:
            ipdModel = self.args.ipdModel
            logging.info("Using passed in ipd model: %s" % self.args.ipdModel)
            if not os.path.exists(self.args.ipdModel):
                logging.error("Couldn't find model file: %s" % self.args.ipdModel)

        elif self.args.paramsPath:
            if not os.path.exists(self.args.paramsPath):
                logging.error("Params path doesn't exist: %s" % self.args.paramsPath)
                sys.exit(1)

            majorityChem = ReferenceUtils.loadCmpH5Chemistry(cmpH5Path)
            ipdModel = os.path.join(self.args.paramsPath, majorityChem + ".h5")

            if majorityChem == "unknown":
                logging.warning("Chemistry is unknown. Falling back to built-in model")
                ipdModel = None
            elif not os.path.exists(ipdModel):
                logging.warning("Model not found: %s" % ipdModel)
                logging.warning("Falling back to built-in model")
                ipdModel = None
            else:
                logging.info("Using Chemistry matched IPD model: %s" % ipdModel)

        self.ipdModel = IpdModel(contigs, ipdModel, self.args.modelIters)
コード例 #3
0
    def loadReferenceAndModel(self, referencePath, cmpH5Path):

        # Load the reference contigs - annotated with their refID from the cmp.h5
        contigs = ReferenceUtils.loadReferenceContigs(referencePath, cmpH5Path)

        # Read reference info table from cmp.h5
        (refInfoTable, _) = ReferenceUtils.loadCmpH5Tables(cmpH5Path)

        if (self.options.refContigs is not None
                or self.options.refContigIndex != -1):

            if (self.options.refContigs is not None
                    and self.options.refContigIndex != -1):

                requestedIds = set(self.options.refContigs.split(',')).union(
                    [self.options.refContigIndex])

            elif (self.options.refContigs is None
                  and self.options.refContigIndex != -1):

                requestedIds = set([self.options.refContigIndex])

            elif (self.options.refContigs is not None
                  and self.options.refContigIndex == -1):

                requestedIds = set(self.options.refContigs.split(','))

            relevantContigs = [
                i for (i, rec) in enumerate(refInfoTable)
                if (rec.FullName in requestedIds or rec.Name in requestedIds
                    or rec.RefInfoID in requestedIds)
            ]
            self.refInfo = refInfoTable[relevantContigs]

        else:
            self.refInfo = refInfoTable

        # There are three different ways the ipdModel can be loaded.
        # In order of precedence they are:
        # 1. Explicit path passed to --ipdModel
        # 2. Path to parameter bundle, model selected using the cmp.h5's sequencingChemistry tags
        # 3. Fall back to built-in model.

        # By default, use built-in model
        ipdModel = None

        if self.args.ipdModel:
            ipdModel = self.args.ipdModel
            logging.info("Using passed in ipd model: %s" % self.args.ipdModel)
            if not os.path.exists(self.args.ipdModel):
                logging.error("Couldn't find model file: %s" %
                              self.args.ipdModel)
                sys.exit(1)
        elif self.args.paramsPath:
            if not os.path.exists(self.args.paramsPath):
                logging.error("Params path doesn't exist: %s" %
                              self.args.paramsPath)
                sys.exit(1)

            majorityChem = ReferenceUtils.loadCmpH5Chemistry(cmpH5Path)
            ipdModel = os.path.join(self.args.paramsPath, majorityChem + ".h5")
            if majorityChem == 'unknown':
                logging.error(
                    "Chemistry cannot be identified---cannot perform kinetic analysis"
                )
                sys.exit(1)
            elif not os.path.exists(ipdModel):
                logging.error(
                    "Aborting, no kinetics model available for this chemistry: %s"
                    % ipdModel)
                sys.exit(1)
            else:
                logging.info("Using Chemistry matched IPD model: %s" %
                             ipdModel)

        self.ipdModel = IpdModel(contigs, ipdModel, self.args.modelIters)
コード例 #4
0
    def loadReferenceAndModel(self, referencePath, cmpH5Path):

        # Load the reference contigs - annotated with their refID from the cmp.h5
        contigs = ReferenceUtils.loadReferenceContigs(referencePath, cmpH5Path)

        # Read reference info table from cmp.h5
        (refInfoTable, _) = ReferenceUtils.loadCmpH5Tables(cmpH5Path)

        if (self.options.refContigs is not None or
            self.options.refContigIndex != -1):

            if (self.options.refContigs is not None and 
                self.options.refContigIndex != -1):

                requestedIds = set(self.options.refContigs.split(',')).union([self.options.refContigIndex])

            elif (self.options.refContigs is None and 
                self.options.refContigIndex != -1):
       
                requestedIds = set([self.options.refContigIndex])

            elif (self.options.refContigs is not None and 
                self.options.refContigIndex == -1):
       
                requestedIds = set(self.options.refContigs.split(','))
      

            relevantContigs = [ i for (i, rec) in enumerate(refInfoTable)
                                if (rec.FullName  in requestedIds or
                                    rec.Name      in requestedIds or
                                    rec.RefInfoID in requestedIds) ]
            self.refInfo = refInfoTable[relevantContigs]


        else:
            self.refInfo = refInfoTable

        # There are three different ways the ipdModel can be loaded.
        # In order of precedence they are:
        # 1. Explicit path passed to --ipdModel
        # 2. Path to parameter bundle, model selected using the cmp.h5's sequencingChemistry tags
        # 3. Fall back to built-in model.

        # By default, use built-in model
        ipdModel = None

        if self.args.ipdModel:
            ipdModel = self.args.ipdModel
            logging.info("Using passed in ipd model: %s" % self.args.ipdModel)
            if not os.path.exists(self.args.ipdModel):
                logging.error("Couldn't find model file: %s" % self.args.ipdModel)
                sys.exit(1)
        elif self.args.paramsPath:
            if not os.path.exists(self.args.paramsPath):
                logging.error("Params path doesn't exist: %s" % self.args.paramsPath)
                sys.exit(1)

            majorityChem = ReferenceUtils.loadCmpH5Chemistry(cmpH5Path)
            ipdModel = os.path.join(self.args.paramsPath, majorityChem + ".h5")
            if majorityChem == 'unknown':
                logging.warning("Chemistry is unknown. Falling back to built-in model")
                ipdModel = None
            elif not os.path.exists(ipdModel):
                logging.warning("Model not found: %s" % ipdModel)
                logging.warning("Falling back to built-in model")
                ipdModel = None
            else:
                logging.info("Using Chemistry matched IPD model: %s" % ipdModel)

        self.ipdModel = IpdModel(contigs, ipdModel, self.args.modelIters)