当前位置: 首页>>代码示例>>Python>>正文


Python colors.linearlyInterpolatedColor函数代码示例

本文整理汇总了Python中reportlab.lib.colors.linearlyInterpolatedColor函数的典型用法代码示例。如果您正苦于以下问题:Python linearlyInterpolatedColor函数的具体用法?Python linearlyInterpolatedColor怎么用?Python linearlyInterpolatedColor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了linearlyInterpolatedColor函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addFeat

	def addFeat(self,feat,colorMax,percent):
		labelTab=[]
		try :
			labelTab=feat.qualifiers['product'][0].split(" ")
		except KeyError:
			print " NO PRODUCT FOUND FOR "
			print feat
			labelTab[0]="No name"
		labelName=""
		if len(labelTab)<= Track.maxLabelWord :
			for word in labelTab :
				labelName+=word+" "
		else :
			labelName=labelTab[0]+" "+labelTab[1]+" "+labelTab[2]+" "
				
		labelName=labelName[0:len(labelName)-1]+" \n "+str(feat.location.start)+" - "+str(feat.location.end) #skip the final space and add location
		
		#change location
		newStart=feat.location.start-self.diff
		newEnd=feat.location.end-self.diff
		if newEnd > Track.maxSize :
			Track.maxSize=newEnd
		newLocation = FeatureLocation(newStart,newEnd,feat.strand)
		feat.location=newLocation
		if self.nbFeats==0:
			self.gdFeature.add_feature(feat,color=Track.backgroundColor,sigil="ARROW",name=labelName,label_position="start",label_angle=Track.angle[self.nbFeats%2],label=True,strand=Track.strand[self.nbFeats%2])
		else :
			self.gdFeature.add_feature(feat,color=Track.backgroundColor,sigil="ARROW",name=labelName,label_position="middle",label_angle=Track.angle[self.nbFeats%2],label=True,strand=Track.strand[self.nbFeats%2])
		if feat.strand==1:			
			self.gdFeature.add_feature(feat,border=colorMax,color=colors.linearlyInterpolatedColor(white,colorMax,minSimilarityScore,100,percent),sigil="ARROW",name=feat.qualifiers['product'][0][0:11].replace(" ","_")+" \n "+str(feat.location.start)+" - "+str(feat.location.end),label_position="middle",label_angle=0,label=False)
		else :
			self.gdFeature.add_feature(feat,border=colorMax,color=colors.linearlyInterpolatedColor(white,colorMax,minSimilarityScore,100,percent),sigil="ARROW",label_position="middle",label_angle=180,label=False)
		self.nbFeats+=1
		self.gdTrack.add_set(self.gdFeature)
开发者ID:AgResearch,项目名称:pyNotation,代码行数:34,代码来源:Visualizer.py

示例2: draw

    def draw(self):
        # general widget bits
        group = Group()
        x, y, w, h, c0, c1 = self._flipRectCorners()
        numShades = self.numShades
        if self.cylinderMode:
            if not numShades % 2: numShades = numShades + 1
            halfNumShades = (numShades - 1) / 2 + 1
        num = float(numShades)  # must make it float!
        vertical = self.orientation == 'vertical'
        if vertical:
            if numShades == 1:
                V = [x]
            else:
                V = frange(x, x + w, w / num)
        else:
            if numShades == 1:
                V = [y]
            else:
                V = frange(y, y + h, h / num)

        for v in V:
            stripe = vertical and Rect(v, y, w / num, h) or Rect(
                x, v, w, h / num)
            if self.cylinderMode:
                if V.index(v) >= halfNumShades:
                    col = colors.linearlyInterpolatedColor(
                        c1, c0, V[halfNumShades], V[-1], v)
                else:
                    col = colors.linearlyInterpolatedColor(
                        c0, c1, V[0], V[halfNumShades], v)
            else:
                col = colors.linearlyInterpolatedColor(c0, c1, V[0], V[-1], v)
            stripe.fillColor = col
            stripe.strokeColor = col
            stripe.strokeWidth = 1
            group.add(stripe)
        if self.strokeColor and self.strokeWidth >= 0:
            rect = Rect(x, y, w, h)
            rect.strokeColor = self.strokeColor
            rect.strokeWidth = self.strokeWidth
            rect.fillColor = None
            group.add(rect)
        return group
开发者ID:radical-software,项目名称:radicalspam,代码行数:44,代码来源:grids.py

示例3: colorRange

def colorRange(c0, c1, n):
    "Return a range of intermediate colors between c0 and c1"
    if n==1: return [c0]

    C = []
    if n>1:
        lim = n-1
        for i in range(n):
            C.append(colors.linearlyInterpolatedColor(c0,c1,0,lim, i))
    return C
开发者ID:halimath,项目名称:taskcardmaker,代码行数:10,代码来源:grids.py

示例4: _blast_feature

 def _blast_feature(self, f, c1, c2, features1, features2, evalue, max_rlen):
     results = BlastCLI.s2s_blast(f.extract(c1), c2, evalue, command='blastn', task='blastn')
     hsps = BlastCLI.all_hsps(results, max_rlen)
     if not hsps: return [(None, None, None)]
     f1 = []
     f2 = []
     col = []
     for hsp in hsps:
         col.append(colors.linearlyInterpolatedColor(colors.Color(1,1,1,0.2), colors.Color(0,0,0,0.2), 
                                                     0, 1, float(hsp.identities)/hsp.align_length))
         f1.append(SeqFeature(FeatureLocation(f.location.start+hsp.query_start, 
                                              f.location.start+hsp.query_start+hsp.align_length, strand=0)))
         f2.append(SeqFeature(FeatureLocation(hsp.sbjct_start, hsp.sbjct_start+hsp.align_length, strand=0)))
     return zip(f1, f2, col)
开发者ID:allista,项目名称:BioUtils,代码行数:14,代码来源:draw_clusters.py

示例5: Add_Blast

    def Add_Blast(self,aList) :
        self.blast_num+=1
        fields=aList.split('\t')
        gene=fields[0]
        query=fields[1]
        chrom=fields[2]
        q_start=int(fields[7])
        q_end=int(fields[8])
        s_start=int(fields[9])
        s_end=int(fields[10])
        evalue=fields[11]
        score=fields[12]

        color = colors.linearlyInterpolatedColor(colors.blue, colors.firebrick, 0,self.blast_rownum,self.blast_num)
        if s_start<=s_end:
            feature = SeqFeature(FeatureLocation(s_start-self.txStart,s_end-self.txStart), strand=-1)
        if s_start>s_end:
            feature = SeqFeature(FeatureLocation(s_end-self.txStart,s_start-self.txStart), strand=-1)
        self.gds_features.add_feature(feature,name=str(self.blast_num),label=True,color=color)
开发者ID:hanice,项目名称:SIBS,代码行数:19,代码来源:Diagram_class.py

示例6: draw_heat_graph

    def draw_heat_graph(self, graph):
        """ draw_heat_graph(self, graph) -> [element, element,...]

            o graph     Graph object

            Returns a list of drawable elements for the heat graph
        """
        #print '\tdraw_heat_graph'
        # At each point contained in the graph data, we draw a box that is the
        # full height of the track, extending from the midpoint between the
        # previous and current data points to the midpoint between the current
        # and next data points
        heat_elements = []      # holds drawable elements

        # Get graph data
        data_quartiles = graph.quartiles()
        minval, maxval = data_quartiles[0],data_quartiles[4]
        midval = (maxval + minval)/2.    # mid is the value at the X-axis
        btm, ctr, top = self.track_radii[self.current_track_level]
        trackheight = (top-btm)
        newdata = intermediate_points(self.start, self.end,
                                      graph[self.start:self.end])

        # Create elements on the graph, indicating a large positive value by
        # the graph's poscolor, and a large negative value by the graph's
        # negcolor attributes
        for pos0, pos1, val in newdata:
            pos0angle, pos0cos, pos0sin = self.canvas_angle(pos0)
            pos1angle, pos1cos, pos1sin = self.canvas_angle(pos1)

            # Calculate the heat color, based on the differential between
            # the value and the median value
            heat = colors.linearlyInterpolatedColor(graph.poscolor,
                                                    graph.negcolor,
                                                    maxval, minval, val)
            
            # Draw heat box
            heat_elements.append(self._draw_arc(btm, top, pos0angle, pos1angle,
                                               heat, border=heat))
        return heat_elements
开发者ID:Nizy,项目名称:biopython,代码行数:40,代码来源:_CircularDrawer.py

示例7: Add_Anno

    def Add_Anno(self,aList) :
        fields=aList.split()
        name=fields[1]
        chrom=fields[2]
        strand=fields[3]
        txStart=int(fields[4])
        self.txStart=txStart
        txEnd=int(fields[5])
        self.txEnd=txEnd
        self.frag=(txEnd-txStart)/10000
        self.end=txEnd-txStart
        cdsStart=int(fields[6])
        cdsEnd=int(fields[7])
        exonCount=int(fields[8])
        exonStarts=[int(i) for i in fields[9].split(',')[0:-1]]
        exonEnds=[int(i) for i in fields[10].split(',')[0:-1]]
        name2=fields[12]
        exonFrames=[int(i) for i in fields[15].split(',')[0:-1]]

        for i in range(exonCount):
    	    color = colors.linearlyInterpolatedColor(colors.white, colors.green,0,exonCount,i+1 )
	    feature = SeqFeature(FeatureLocation(exonStarts[i]-txStart,exonEnds[i]-txStart), strand=+1)
	    self.gds_features.add_feature(feature,name=str(i+1),label=True,color=color)
开发者ID:hanice,项目名称:SIBS,代码行数:23,代码来源:Diagram_class.py

示例8: zip

                                                 name=record.name,
                                                 greytrack=True, height=0.5,
                                                 start=0, end=len(record))
    assert record.name not in feature_sets
    feature_sets[record.name] = gd_track_for_features.new_set()

# We add dummy features to the tracks for each cross-link BEFORE we add the
# arrow features for the genes. This ensures the genes appear on top:
for X, Y, X_vs_Y in [("NC_002703", "AF323668", A_vs_B),
                     ("AF323668", "NC_003212", B_vs_C)]:
    features_X = records[X].features
    features_Y = records[Y].features
    set_X = feature_sets[X]
    set_Y = feature_sets[Y]
    for score, x, y in X_vs_Y:
        color = colors.linearlyInterpolatedColor(colors.white, colors.firebrick,
                                                 0, 100, score)
        border = colors.lightgrey
        f_x = get_feature(features_X, x)
        F_x = set_X.add_feature(SeqFeature(FeatureLocation(f_x.location.start,
                                                           f_x.location.end,
                                                           strand=0)),
                                color=color, border=border)
        f_y = get_feature(features_Y, y)
        F_y = set_Y.add_feature(SeqFeature(FeatureLocation(f_y.location.start,
                                                           f_y.location.end,
                                                           strand=0)),
                                color=color, border=border)
        gd_diagram.cross_track_links.append(CrossLink(F_x, F_y, color, border))


for record, gene_colors in zip([A_rec, B_rec, C_rec],
开发者ID:BioGeek,项目名称:biopython,代码行数:32,代码来源:Proux_et_al_2002_Figure_6.py

示例9: draw_heat_graph

    def draw_heat_graph(self, graph):
        """ draw_heat_graph(self, graph) -> [element, element,...]

            o graph     Graph object

            Returns a list of drawable elements for the heat graph
        """
        #print '\tdraw_heat_graph'
        # At each point contained in the graph data, we draw a box that is the
        # full height of the track, extending from the midpoint between the
        # previous and current data points to the midpoint between the current
        # and next data points
        heat_elements = []  # Holds drawable elements for the graph

        # Get graph data and information
        data_quartiles = graph.quartiles()
        minval, maxval = data_quartiles[0],data_quartiles[4]
        midval = (maxval + minval)/2.    # mid is the value at the X-axis
        btm, ctr, top = self.track_offsets[self.current_track_level]
        trackheight = (top-btm)
        #print self.start, self.end
        newdata = intermediate_points(self.start, self.end,
                                      graph[self.start:self.end])
        #print newdata

        # Create elements on the graph, indicating a large positive value by
        # the graph's poscolor, and a large negative value by the graph's
        # negcolor attributes
        for pos0, pos1, val in newdata:
            fragment0, x0 = self.canvas_location(pos0)
            fragment1, x1 = self.canvas_location(pos1)
            x0, x1 = self.x0 + x0, self.x0 + x1     # account for margin
            #print 'x1 before:', x1
            
            # Calculate the heat color, based on the differential between
            # the value and the median value
            heat = colors.linearlyInterpolatedColor(graph.poscolor,
                                                    graph.negcolor,
                                                    maxval, minval, val)
            
            # Draw heat box
            if fragment0 == fragment1:  # Box is contiguous on one fragment
                if pos1 >= self.fragment_limits[fragment0][1]:
                    x1 = self.xlim
                ttop = top + self.fragment_lines[fragment0][0]
                tbtm = btm + self.fragment_lines[fragment0][0]
                #print 'equal', pos0, pos1, val
                #print pos0, pos1, fragment0, fragment1
                heat_elements.append(draw_box((x0, tbtm), (x1, ttop),
                                              color=heat, border=None))
            else:   # box is split over two or more fragments
                #if pos0 >= self.fragment_limits[fragment0][0]:
                #    fragment0 += 1
                fragment = fragment0
                start = x0
                while self.fragment_limits[fragment][1] <= pos1:
                    #print pos0, self.fragment_limits[fragment][1], pos1
                    ttop = top + self.fragment_lines[fragment][0]
                    tbtm = btm + self.fragment_lines[fragment][0]
                    heat_elements.append(draw_box((start, tbtm),
                                                  (self.xlim, ttop),
                                                  color=heat,
                                                  border=None))
                    fragment += 1
                    start = self.x0
                ttop = top + self.fragment_lines[fragment][0]
                tbtm = btm + self.fragment_lines[fragment][0]
                # Add the last part of the bar
                #print 'x1 after:', x1, '\n'
                heat_elements.append(draw_box((self.x0, tbtm), (x1, ttop),
                                              color=heat, border=None))                    

        return heat_elements
开发者ID:chapmanb,项目名称:biosqlweb,代码行数:73,代码来源:_LinearDrawer.py

示例10: generateClusterCompGraphic

def generateClusterCompGraphic(cluster1,cluster2,pairs,outname):
    noPair = tuple(map(lambda x: x/255.,(211,211,211)))
    distDict = {}
    colorDict = {}
    colorPalette = [tuple(float(value) for value in values) for values in _get_colors_Janus(len(pairs))]

    cluster1Name = "%s:%i-%i" % (cluster1[0].species,cluster1.location[0],cluster1.location[1])
    cluster2Name = "%s:%i-%i" % (cluster2[0].species,cluster2.location[0],cluster2.location[1])

    # Generate color dictionary
    maxLen = 0
    proteinHits = set()
    pairs.reverse()
    for idx,(dist,prot1,prot2) in enumerate(pairs):
        distDict[prot1.hitName] = dist
        distDict[prot2.hitName] = dist
        colorDict[prot1.hitName] = colorPalette[idx]
        colorDict[prot2.hitName] = colorPalette[idx]
        proteinHits.update([prot1,prot2])

    # Draw the cluster
    gd_diagram = GenomeDiagram.Diagram(outname)
    featureHandles = {}
    for idx,cluster in enumerate([cluster1,cluster2]):
        offset = cluster.location[0]
        maxLen = max(maxLen,cluster.location[1]-offset)
        clusterName = "%s:%i-%i" % (cluster[0].species,cluster.location[0],cluster.location[1])
        gd_track_for_features = gd_diagram.new_track(3-2*idx,name = clusterName,
                            start=0, end=cluster.location[1]-offset,
                            scale_ticks=0,scale=0)
        assert clusterName not in featureHandles
        featureHandles[clusterName] = gd_track_for_features.new_set()

    for dist,prot1,prot2 in pairs:
        color = colors.linearlyInterpolatedColor(colors.firebrick,colors.white,  0, 1, dist)
        border = colors.lightgrey

        coord1,direction1 = prot1.location
        coord2,direction2 = prot2.location
        offset1 = cluster1.location[0]
        offset2 = cluster2.location[0]
        coord1 = (x - offset1 for x in coord1)
        coord2 = (x - offset2 for x in coord2)
        F_x = featureHandles[cluster1Name].add_feature(SeqFeature(FeatureLocation(*coord1),strand=0),color=color,border=border)
        F_y = featureHandles[cluster2Name].add_feature(SeqFeature(FeatureLocation(*coord2),strand=0),color=color,border=border)

        gd_diagram.cross_track_links.append(CrossLink(F_x,F_y,color,border))



    for name,cluster in zip([cluster1Name,cluster2Name],[cluster1,cluster2]):
        offset = cluster.location[0]
        for protein in cluster:
            coord,direction  = protein.location
            coord = (x-offset for x in coord)
            if direction == '+':
                strand = +1
            else:
                strand = -1
            feature = SeqFeature(FeatureLocation(*coord),strand=strand)
            featureHandles[name].add_feature(feature,sigil="BIGARROW", color=colorDict.get(protein.hitName,noPair),
                                      name = protein.name,label_position="middle",
                                             label=protein in proteinHits,arrowshaft_height=1,
                                             arrowshaft_length = 0.1,label_strand = 1,
                                   label_size=8, label_angle=45)


    tracks = gd_diagram.get_tracks()
    for track in tracks:
        track.height=1
        track.greytrack_fontcolor  = colors.black
        track.greytrack_labels = 1
        track.greytrack = 1
        track.greytrack_fontsize=16
        track.greytrack_font_rotation = 0
        track.axis_labels = 0
    gd_diagram.draw(format="linear", pagesize='A4', fragments=1,
                start=0, end=maxLen)

    gd_diagram.write(outname + ".svg", "SVG")
开发者ID:emzodls,项目名称:clusterTools,代码行数:80,代码来源:clusterGraphics.py

示例11: SeqFeature

gdd = GenomeDiagram.Diagram('Diagram')
gdt1_features = gdd.new_track(1, greytrack=False)
gds1_features = gdt1_features.new_set()
gdt2_features = gdd.new_track(1, greytrack=False)
gds2_features = gdt2_features.new_set()


inFile=open('CHC10A.unmapped.sam.mapped.fa.fa.blasted')
NC_len=5894
num=0
startend=[]
for line in inFile :
    fields=line.split('\t')
    if fields[1]=='NC_003977.1':
        num+=1
        color = colors.linearlyInterpolatedColor(colors.white, colors.firebrick, 0, 200, num)
        line=line.strip()
        q_start=int(fields[6])
        q_end=int(fields[7])
        s_start=int(fields[9])
        s_end=int(fields[9])
    
        startend.append(q_start)
        startend.append(q_end)
        startend.append(s_start)
        startend.append(s_end)
    
        feature = SeqFeature(FeatureLocation(q_start,q_end),strand=+1)
        #gds1_features.add_feature(feature,name=str(num),label=True,color=color)
    
        feature = SeqFeature(FeatureLocation(s_start,s_end),strand=+1)
开发者ID:hanice,项目名称:SIBS,代码行数:31,代码来源:3.diagram.py

示例12: enumerate

    for index, connection in enumerate(links_handle):
        connection = connection.strip()
        values = connection.split("\t")

        phage1 = values[0]
        phage1Full = phageFullNameConvert[phage1]
        phage1_gene = int(values[1])
        phage2 = values[2]
        phage2Full = phageFullNameConvert[phage2]
        phage2_gene = int(values[3])
        score = float(values[4])

        track1 = genomeDiag.tracks[phageTrack[phage1]]
        track2 = genomeDiag.tracks[phageTrack[phage2]]

        color = colors.linearlyInterpolatedColor(colors.white, colors.lightcoral, 0, 100, score)
        borderColor = None

        if phage1Full == "OCN008_K139_region.fa" or phage1Full == "RE98_web_2_ep3.fa" or phage1Full == "RE98_web_1_kappa.fa":
            link_xy = CrossLink((track1, phageDict[phage1Full][phage1_gene]["start"], phageDict[phage1Full][phage1_gene]["stop"]), (track2, phageDict[phage2Full][phage2_gene]["start"], phageDict[phage2Full][phage2_gene]["stop"]), color=color, flip=True, border=borderColor)
        else:
            link_xy = CrossLink((track1, phageDict[phage1Full][phage1_gene]["start"], phageDict[phage1Full][phage1_gene]["stop"]), (track2, phageDict[phage2Full][phage2_gene]["start"], phageDict[phage2Full][phage2_gene]["stop"]), color=color, flip=False, border=borderColor)

        # add link features to first track

        BoxFeatureTrack1 = SeqFeature(FeatureLocation(phageDict[phage1Full][phage1_gene]["start"], phageDict[phage1Full][phage1_gene]["stop"], strand=0))

        borderBoxColor = colors.white

        genomeSet = track1.new_set()
        genomeSet.add_feature(BoxFeatureTrack1, label=False, label_position="start", sigil="BOX", color=color, border=borderBoxColor)
开发者ID:neavemj,项目名称:vibrioPhages,代码行数:31,代码来源:vibrioPhageLinSim.py


注:本文中的reportlab.lib.colors.linearlyInterpolatedColor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。