示例#1
0
 def getTrackExtractionOptions(genome, trackName):
     from gtrackcore_memmap.track.core.Track import PlainTrack
     from gtrackcore_memmap.input.userbins.UserBinSource import MinimalBinSource
     from gtrackcore_memmap.extract.fileformats.FileFormatComposer import \
         findMatchingFileFormatComposers, getComposerClsFromFileSuffix
     
     tf = PlainTrack(trackName).getTrackView(MinimalBinSource(genome)[0]).trackFormat
         
     extractionOptions = []
     matchingComposers = findMatchingFileFormatComposers(tf)
     for composerInfo in matchingComposers:
         allOverlapRules = tf.getAllOverlapRules()
         for allowOverlaps in allOverlapRules:
             extractionOptions.append( \
                 (composerInfo.trackFormatName.capitalize() + \
                     ' ' + TrackExtractor.getFileFormatText(composerInfo.fileFormatName) + \
                     (', ' + (TrackExtractor.ALLOW_OVERLAPS_TRUE_TEXT if allowOverlaps else \
                              TrackExtractor.ALLOW_OVERLAPS_FALSE_TEXT) \
                              if len(allOverlapRules) > 1 else ''), \
                  composerInfo.fileSuffix) )
             
     ti = TrackInfo(genome, trackName)
     if ti.fileType != '':
         try:
             extractionOptions.append(
                 (TrackExtractor.ORIG_FILE_FORMAT_TEXT.capitalize() + \
                     ' ' + TrackExtractor.getFileSuffixText(ti.fileType), \
                  getComposerClsFromFileSuffix(ti.fileType).getDefaultFileNameSuffix()))
         except Exception, e:
             print 'Error:', e
    def _createRandomizedNumpyArrays(self, binLen, starts, ends, vals, strands, ids, edges, weights, extras, origTrackFormat, region):
        if self._minimal:
            return numpy.array([]), None, None, None, None, None, None, OrderedDict()
        
        intensityTV = PlainTrack(self._trackNameIntensity).getTrackView(region)
        if len(intensityTV.valsAsNumpyArray())==0:
            raise InvalidRunSpecException('Error: No intensity data available for sampling randomized locations in region' + \
                                          str(region) + \
                                          '. Please check that the intensity track was created with the same main track that is being randomized in this analysis.')

        #intensityTV = PlainTrack(self._trackNameIntensity).getTrackView(self._origRegion) #Dependence on origRegion is not nice, but not a big problem..
        
        if intensityTV.trackFormat.isDense():
            assert intensityTV.trackFormat.isValued('number')
            return self._createRandomizedNumpyArraysFromIntensityFunction(binLen, starts, ends, vals, strands, ids, edges, weights, extras, intensityTV)
        else:
            raise NotImplementedError