def extract_feature(cls, genome, track, ref, option, regSpec, binSpec, trackFormat) : #print 'genome, track, ref, option, regSpec, binSpec, trackFormat: ', genome, track, ref, option, regSpec, binSpec, trackFormat validFeature = FeatureCatalog.getFeaturesFromTracks(genome,track,ref)[option] #validFeature contains analysisDef and the key to get the needed number from the global result if option == 'Prop. of tr1-points falling inside segments of tr2' and trackFormat in ['Segments', 'Valued segments'] : analysisDef = 'dummy [tf1=SegmentToMidPointFormatConverter] -> DerivedPointCountsVsSegsStat' else : analysisDef = validFeature[0] #or any other statistic from the HB collection userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) result = AnalysisDefJob(analysisDef, ref, track, userBinSource).run() if option == 'Prop. of tr2 covered by tr1' else AnalysisDefJob(analysisDef, track, ref, userBinSource).run() validAnalysisDef = validFeature[1] assert result.getGlobalResult() is not None, 'Did not get any global result for analysisDef: '+validAnalysisDef return result.getGlobalResult()[validAnalysisDef]
def extract_feature(self, genome, track, ref, option) : ''' this function return the relation of clusterTrack to referenceTrack option is the statistical function used, should be named feature track, ref is clusterTrack and referenceTrack ''' validFeature = FeatureCatalog.getFeaturesFromTracks(genome,track,ref)[option] #validFeature contains analysisDef and the key to get the needed number from the global result if option == 'Prop. of tr1-points falling inside segments of tr2' and cls.getTrackFormat(genome, track) in ['Segments', 'Valued segments'] : analysisDef = 'dummy [tf1=SegmentToMidPointFormatConverter] -> DerivedPointCountsVsSegsStat' else : analysisDef = validFeature[0] #or any other statistic from the HB collection if self.params.get("compare_in") == "Chromosomes" : regSpec = "__chrs__" binSpec = self.params.get("Chromosomes") elif self.params.get("compare_in") == "Chromosome arms" : regSpec = "__chrArms__" binSpec = self.params.get("Chromosome_arms") elif self.params.get("compare_in") == "Cytobands" : regSpec = "__chrBands__" binSpec = self.params.get("Cytobands") else : regSpec = self.params.get("region") binSpec = self.params.get("binsize") #regSpec = self.params.get("region") #binSpec = self.params.get("binsize") #regSpec = 'chr1' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome #binSpec = '10m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins #genome = 'hg18' userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) if option == 'Prop. of tr2 covered by tr1' : #because the confuse of refTrack and clusterTrack in this statistics result = AnalysisDefJob(analysisDef, ref, track, userBinSource).run() else : result = AnalysisDefJob(analysisDef, track, ref, userBinSource).run() mainResultDict = result.getGlobalResult() return mainResultDict[validFeature[1]]
def extract_feature(self, genome, track, ref, option) : ''' this function return the relation of clusterTrack to referenceTrack option is the statistical function used, should be named feature track, ref is clusterTrack and referenceTrack ''' validFeature = FeatureCatalog.getFeaturesFromTracks(genome,track,ref)[option] #validFeature contains analysisDef and the key to get the needed number from the global result if option == 'Prop. of tr1-points falling inside segments of tr2' and self.getTrackFormat(genome, track) in ['Segments', 'Valued segments'] : analysisDef = 'dummy [tf1=SegmentToMidPointFormatConverter] -> DerivedPointCountsVsSegsStat' else : analysisDef = validFeature[0] #or any other statistic from the HB collection if self.params.get("compare_in") == "Chromosomes" : regSpec = "__chrs__" binSpec = self.params.get("Chromosomes") elif self.params.get("compare_in") == "Chromosome arms" : regSpec = "__chrArms__" binSpec = self.params.get("Chromosome_arms") elif self.params.get("compare_in") == "Cytobands" : regSpec = "__chrBands__" binSpec = self.params.get("Cytobands") else : regSpec = self.params.get("region") binSpec = self.params.get("binsize") #regSpec = self.params.get("region") #binSpec = self.params.get("binsize") #regSpec = 'chr1' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome #binSpec = '10m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins #genome = 'hg18' userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) if option == 'Prop. of tr2 covered by tr1' : #because the confuse of refTrack and clusterTrack in this statistics result = AnalysisDefJob(analysisDef, ref, track, userBinSource).run() else : result = AnalysisDefJob(analysisDef, track, ref, userBinSource).run() mainResultDict = result.getGlobalResult() return mainResultDict[validFeature[1]]
def computeDistance(cls, genome, track1, track2, feature, regSpec, binSpec): #direct distance between track1, track2 ''' track1 and track2 are two lists like : ['Sequence','Repeating elements','LINE'] feature specifies how the distance between track1 and track2 is defined ''' validFeature = DirectDistanceCatalog.getValidAnalyses(genome, track1, track2)[feature] analysisDef = validFeature[0] #'bla bla -> PropFreqOfTr1VsTr2Stat' #or any other statistic from the HB collection userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) result = AnalysisDefJob(analysisDef, track1, track2, userBinSource).run() mainResultDict = result.getGlobalResult() return mainResultDict[validFeature[1]]
def computeDistance(track1, track2, feature='direct distance'): ''' track1 and track2 are two lists like : ['Sequence','Repeating elements','LINE'] feature specifies how the distance between track1 and track2 is defined ''' analysisDef = 'bla bla -> PropFreqOfTr1VsTr2Stat' #or any other statistic from the HB collection regSpec = 'chr1' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome binSpec = '10m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins genome = 'hg18' # path /../../..../genome #allRepeats = GalaxyInterface.getSubTrackNames(genome,['Sequence','Repeating elements'],False) #all elements in 'Repeating elements' directory #GalaxyInterface.run(trackName1, trackName2, question, regSpec, binSpec, genome='hg18') userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) result = AnalysisDefJob(analysisDef, track1, track2, userBinSource).run() #result er av klassen Results.. #from gold.result.Results import Results mainResultDict = result.getGlobalResult() #from PropFreqOfTr1VsTr2Stat:... #self._result = {'Track1Prop':ratio,'CountTrack1':c1, 'CountTrack2':c2,'Variance':variance} mainValueOfInterest = mainResultDict['Variance'] return mainValueOfInterest
def computeDistance(self, genome, track1, track2, feature): #direct distance between track1, track2 ''' track1 and track2 are two lists like : ['Sequence','Repeating elements','LINE'] feature specifies how the distance between track1 and track2 is defined ''' validFeature = DirectDistanceCatalog.getValidAnalyses(genome, track1, track2)[feature] analysisDef = validFeature[0] #'bla bla -> PropFreqOfTr1VsTr2Stat' #or any other statistic from the HB collection if self.params.get("compare_in") == "Chromosomes" : regSpec = "__chrs__" binSpec = self.params.get("Chromosomes") elif self.params.get("compare_in") == "Chromosome arms" : regSpec = "__chrArms__" binSpec = self.params.get("Chromosome_arms") elif self.params.get("compare_in") == "Cytobands" : regSpec = "__chrBands__" binSpec = self.params.get("Cytobands") else : regSpec = self.params.get("region") binSpec = self.params.get("binsize") #regSpec = 'chr1' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome #binSpec = '10m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins #genome = 'hg18' # path /../../..../genome #allRepeats = GalaxyInterface.getSubTrackNames(genome,['Sequence','Repeating elements'],False) #GalaxyInterface.run(trackName1, trackName2, question, regSpec, binSpec, genome='hg18') userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) result = AnalysisDefJob(analysisDef, track1, track2, userBinSource).run() #result er av klassen Results.. #from gold.result.Results import Results mainResultDict = result.getGlobalResult() #from PropFreqOfTr1VsTr2Stat:... #self._result = {'Track1Prop':ratio,'CountTrack1':c1, 'CountTrack2':c2,'Variance':variance} #mainValueOfInterest = mainResultDict['Variance'] return mainResultDict[validFeature[1]]
def execute(choices, galaxyFn=None, username=''): '''Is called when execute-button is pushed by web-user. Should print output as HTML to standard out, which will be directed to a results page in Galaxy history. If needed, StaticFile can be used to get a path where additional files can be put (e.g. generated image files). choices is a list of selections made by web-user in each options box. ''' #print 'Executing...' #print choices #trackName1 = ['Sequence','Repeating elements','LINE'] #a list of subdirectories from 'genome' to the repeat file #trackName2 = ['Sequence','Repeating elements','SINE'] #allRepeats = GalaxyInterface.getSubTrackNames(genome,['Sequence','Repeating elements'],False) #all elements in 'Repeating elements' directory #analysisDef = 'bla bla -> PropFreqOfTr1VsTr2Stat' #or any other statistic from the HB collection #regSpec = 'chr1' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome #binSpec = '10m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins genome = 'hg18' # path /../../..../genome allRepeats = GalaxyInterface.getSubTrackNames(genome,['Sequence','Repeating elements'],False) #all elements in 'Repeating elements' directory #GalaxyInterface.run(trackName1, trackName2, question, regSpec, binSpec, genome='hg18') #userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) #result = AnalysisDefJob(analysisDef, trackName1, trackName2, userBinSource).run() #result er av klassen Results.. #from gold.result.Results import Results #mainResultDict = result.getGlobalResult() #from PropFreqOfTr1VsTr2Stat:... #self._result = {'Track1Prop':ratio,'CountTrack1':c1, 'CountTrack2':c2,'Variance':variance} #mainValueOfInterest = mainResultDict['Variance'] #print 'first repeat', allRepeats[0] #print '\n all repeats', allRepeats #minValue = HiepsTool.computeDistance(trackName1,trackName2) #print minValue #choicedTracks = [['Sequence','Repeating elements',name] for name in choices] #print '\n choiced tracks', choicedTracks #d_matrix = HiepsTool.constructDistMatrix(choicedTracks) #tree = treecluster(distancematrix=d_matrix, method='s') #print tree #figure = StaticFile(['hiepln','dendro'],'jpg') #filepath = figure.getDiskPath() #print filepath #draw_dendrogram(tree,choices,filepath) #print figure.getLink('clustring result') track1 = ['Sequence','Repeating elements', 'DNA'] track2 = ['Gene regulation', 'TFBS', 'High Throughput'] analysisDef = 'bla bla -> DerivedOverlapStat' #or any other statistic from the HB collection regSpec = 'chr1' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome binSpec = '10m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins genome = 'hg18' # path /../../..../genome #allRepeats = GalaxyInterface.getSubTrackNames(genome,['Sequence','Repeating elements'],False) #all elements in 'Repeating elements' directory #GalaxyInterface.run(trackName1, trackName2, question, regSpec, binSpec, genome='hg18') userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) result = AnalysisDefJob(analysisDef, track1, track2, userBinSource).run() #result er av klassen Results.. #from gold.result.Results import Results mainResultDict = result.getGlobalResult() #keys = result.getResDictKeys() #print keys #print mainResultDict['2in1'] print '<ol>' for key in mainResultDict.keys() : print '<li>key:%s,value:%s </li>'%(key,mainResultDict[key]) print '</ol>'
from gold.application.GalaxyInterface import GalaxyInterface from gold.application.StatRunner import AnalysisDefJob trackName1 = ['Sequence', 'Repeating elements', 'LINE'] trackName2 = ['Sequence', 'Repeating elements', 'SINE'] #GalaxyInterface.getSubTrackNames(['Sequence','Repeating elements'],False) analysisDef = 'bla bla -> PropFreqOfTr1VsTr2Stat' #or any other statistic from the HB collection regSpec = 'chr1' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome binSpec = '10m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins genome = 'hg18' #GalaxyInterface.run(trackName1, trackName2, question, regSpec, binSpec, genome='hg18') userBinSource = GalaxyInterface._getUserBinSource(regSpec, binSpec, genome) result = AnalysisDefJob(analysisDef, trackName1, trackName2, userBinSource).run() #result er av klassen Results.. #from gold.result.Results import Results mainResultDict = result.getGlobalResult() #from PropFreqOfTr1VsTr2Stat:... #self._result = {'Track1Prop':ratio,'CountTrack1':c1, 'CountTrack2':c2,'Variance':variance} mainValueOfInterest = mainResultDict['Variance'] print 'The ..variance..: ', mainValueOfInterest
from gold.application.GalaxyInterface import GalaxyInterface from gold.application.StatRunner import AnalysisDefJob trackName1 = ['Sequence','Repeating elements','LINE'] trackName2 = ['Sequence','Repeating elements','SINE'] #GalaxyInterface.getSubTrackNames(['Sequence','Repeating elements'],False) analysisDef = 'bla bla -> PropFreqOfTr1VsTr2Stat' #or any other statistic from the HB collection regSpec = 'chr1' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome binSpec = '10m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins genome = 'hg18' #GalaxyInterface.run(trackName1, trackName2, question, regSpec, binSpec, genome='hg18') userBinSource = GalaxyInterface._getUserBinSource(regSpec,binSpec,genome) result = AnalysisDefJob(analysisDef, trackName1, trackName2, userBinSource).run() #result er av klassen Results.. #from gold.result.Results import Results mainResultDict = result.getGlobalResult() #from PropFreqOfTr1VsTr2Stat:... #self._result = {'Track1Prop':ratio,'CountTrack1':c1, 'CountTrack2':c2,'Variance':variance} mainValueOfInterest = mainResultDict['Variance'] print 'The ..variance..: ', mainValueOfInterest