コード例 #1
0
 def __init__(self, gaReadGroupSet, samFile, readGroupName):
     self.gaReadGroup = reads.AbstractReadGroup(gaReadGroupSet,
                                                readGroupName)
     self.id = self.gaReadGroup.getId()
     self.samFile = samFile
     self.mappedReads = collections.defaultdict(list)
     for read in self.samFile:
         tags = dict(read.tags)
         if 'RG' not in tags or tags['RG'] != readGroupName:
             continue
         if read.reference_id != -1:
             # mapped read
             referenceName = self.samFile.getrname(read.reference_id)
             self.mappedReads[referenceName].append(read)
     self.numAlignedReads = -1
     self.numUnalignedReads = -1
     self.programs = []
     if 'PG' in self.samFile.header:
         self.programs = self.samFile.header['PG']
     self.sampleName = None
     self.description = None
     self.predictedInsertSize = None
     self.instrumentModel = None
     self.sequencingCenter = None
     self.experimentDescription = None
     self.library = None
     self.platformUnit = None
     self.runTime = None
     if 'RG' in self.samFile.header:
         readGroupHeader = [
             rgHeader for rgHeader in self.samFile.header['RG']
             if rgHeader['ID'] == readGroupName
         ][0]
         self.sampleName = readGroupHeader.get('SM', None)
         self.description = readGroupHeader.get('DS', None)
         if 'PI' in readGroupHeader:
             self.predictedInsertSize = int(readGroupHeader['PI'])
         self.instrumentModel = readGroupHeader.get('PL', None)
         self.sequencingCenter = readGroupHeader.get('CN', None)
         self.experimentDescription = readGroupHeader.get('DS', None)
         self.library = readGroupHeader.get('LB', None)
         self.platformUnit = readGroupHeader.get('PU', None)
         self.runTime = readGroupHeader.get('DT', None)
コード例 #2
0
 def getReadGroup(self):
     return reads.AbstractReadGroup(self.getReadGroupSet(), "readGroup")
コード例 #3
0
 def testNonexistentReadGroup(self):
     # a request for a readGroup that doesn't exist should throw an error
     readGroup = reads.AbstractReadGroup(self.readGroupSet, 'notFound')
     self.request.read_group_ids.extend([readGroup.getId()])
     with self.assertRaises(exceptions.ReadGroupNotFoundException):
         self.backend.readsGenerator(self.request)