Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Static Public Attributes
Bio.Phylo.PhyloXML.BranchColor Class Reference
Inheritance diagram for Bio.Phylo.PhyloXML.BranchColor:
Inheritance graph
[legend]
Collaboration diagram for Bio.Phylo.PhyloXML.BranchColor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __repr__
def from_hex
def from_name
def to_hex
def to_rgb
def __repr__
def __str__

Public Attributes

 red
 green
 blue

Static Public Attributes

dictionary color_names

Detailed Description

Definition at line 426 of file PhyloXML.py.


Constructor & Destructor Documentation

def Bio.Phylo.PhyloXML.BranchColor.__init__ (   self,
  args,
  kwargs 
)

Definition at line 427 of file PhyloXML.py.

00427 
00428     def __init__(self, *args, **kwargs):
00429         BaseTree.BranchColor.__init__(self, *args, **kwargs)
00430 
00431 
00432 # PhyloXML-specific complex types


Member Function Documentation

def Bio.Phylo.BaseTree.TreeElement.__repr__ (   self) [inherited]
Show this object's constructor with its primitive arguments.

Definition at line 216 of file BaseTree.py.

00216 
00217     def __repr__(self):
00218         """Show this object's constructor with its primitive arguments."""
00219         def pair_as_kwarg_string(key, val):
00220             if isinstance(val, basestring):
00221                 return "%s='%s'" % (key, _sugar.trim_str(unicode(val)))
00222             return "%s=%s" % (key, val)
00223         return u'%s(%s)' % (self.__class__.__name__,
00224                             ', '.join(pair_as_kwarg_string(key, val)
00225                                   for key, val in self.__dict__.iteritems()
00226                                   if val is not None and
00227                                   type(val) in (str, int, float, bool, unicode)
00228                                   ))

def Bio.Phylo.BaseTree.BranchColor.__repr__ (   self) [inherited]
Preserve the standard RGB order when representing this object.

Definition at line 1144 of file BaseTree.py.

01144 
01145     def __repr__(self):
01146         """Preserve the standard RGB order when representing this object."""
01147         return (u'%s(red=%d, green=%d, blue=%d)'
01148                 % (self.__class__.__name__, self.red, self.green, self.blue))

def Bio.Phylo.BaseTree.BranchColor.__str__ (   self) [inherited]
Show the color's RGB values.

Definition at line 1149 of file BaseTree.py.

01149 
01150     def __str__(self):
01151         """Show the color's RGB values."""
01152         return "(%d, %d, %d)" % (self.red, self.green, self.blue)
01153 
def Bio.Phylo.BaseTree.BranchColor.from_hex (   cls,
  hexstr 
) [inherited]
Construct a BranchColor object from a hexadecimal string.

The string format is the same style used in HTML and CSS, such as
'#FF8000' for an RGB value of (255, 128, 0).

Definition at line 1096 of file BaseTree.py.

01096 
01097     def from_hex(cls, hexstr):
01098         """Construct a BranchColor object from a hexadecimal string.
01099 
01100         The string format is the same style used in HTML and CSS, such as
01101         '#FF8000' for an RGB value of (255, 128, 0).
01102         """
01103         assert (isinstance(hexstr, basestring) and
01104                 hexstr.startswith('#') and
01105                 len(hexstr) == 7
01106                 ), "need a 24-bit hexadecimal string, e.g. #000000"
01107         def unpack(cc):
01108             return int('0x'+cc, base=16)
01109         RGB = hexstr[1:3], hexstr[3:5], hexstr[5:]
01110         return cls(*map(unpack, RGB))

def Bio.Phylo.BaseTree.BranchColor.from_name (   cls,
  colorname 
) [inherited]
Construct a BranchColor object by the color's name.

Definition at line 1112 of file BaseTree.py.

01112 
01113     def from_name(cls, colorname):
01114         """Construct a BranchColor object by the color's name."""
01115         return cls(*cls.color_names[colorname])

def Bio.Phylo.BaseTree.BranchColor.to_hex (   self) [inherited]
Return a 24-bit hexadecimal RGB representation of this color.

The returned string is suitable for use in HTML/CSS, as a color
parameter in matplotlib, and perhaps other situations.

Example:

    >>> bc = BranchColor(12, 200, 100)
    >>> bc.to_hex()
    '#0cc864'

Definition at line 1116 of file BaseTree.py.

01116 
01117     def to_hex(self):
01118         """Return a 24-bit hexadecimal RGB representation of this color.
01119 
01120         The returned string is suitable for use in HTML/CSS, as a color
01121         parameter in matplotlib, and perhaps other situations.
01122 
01123         Example:
01124 
01125             >>> bc = BranchColor(12, 200, 100)
01126             >>> bc.to_hex()
01127             '#0cc864'
01128         """
01129         return '#' + hex(
01130                 self.red * (16**4)
01131                 + self.green * (16**2)
01132                 + self.blue)[2:].zfill(6)

def Bio.Phylo.BaseTree.BranchColor.to_rgb (   self) [inherited]
Return a tuple of RGB values (0 to 255) representing this color.

Example:

    >>> bc = BranchColor(255, 165, 0)
    >>> bc.to_rgb()
    (255, 165, 0)

Definition at line 1133 of file BaseTree.py.

01133 
01134     def to_rgb(self):
01135         """Return a tuple of RGB values (0 to 255) representing this color.
01136 
01137         Example:
01138 
01139             >>> bc = BranchColor(255, 165, 0)
01140             >>> bc.to_rgb()
01141             (255, 165, 0)
01142         """
01143         return (self.red, self.green, self.blue)


Member Data Documentation

Definition at line 1093 of file BaseTree.py.

dictionary Bio.Phylo.BaseTree.BranchColor.color_names [static, inherited]

Definition at line 1047 of file BaseTree.py.

Definition at line 1092 of file BaseTree.py.

Definition at line 1091 of file BaseTree.py.


The documentation for this class was generated from the following file: