Changeset 1933:bf2cdd778fee in orange-bioinformatics


Ignore:
Timestamp:
12/12/13 13:35:35 (4 months ago)
Author:
markotoplak
Branch:
default
Message:

Converted documentation of obiGeneSets to rst.

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • docs/rst/index.rst

    r1932 r1933  
    2828   reference/dictybase.rst 
    2929   reference/gene.rst 
     30   reference/genesets.rst 
    3031 
    3132Installation 
  • orangecontrib/bio/geneset.py

    r1873 r1933  
    88 
    99class GeneSet(object): 
     10    """ A single set of genes. 
     11    """ 
    1012 
    11     def __init__(self, genes=None, name=None, id=None, \ 
     13    def __init__(self, genes=[], name=None, id=None, \ 
    1214        description=None, link=None, organism=None, hierarchy=None, pair=None): 
    1315        """ 
    14         pair can be (id, listofgenes) - it is used before anything else. 
     16        :param pair: Backward compatibility: convert a tuple (name, genes) 
     17            into this object. 
    1518        """ 
    16         if genes == None: 
    17             genes = [] 
    1819 
    1920        self.hierarchy = hierarchy      
     21        """ Hierarchy should be formated as a tuple, for example ``("GO", "biological_process")``""" 
     22 
    2023        self.genes = set(genes) 
     24        """ A set of genes. Genes are strings. """ 
     25 
    2126        self.name = name 
     27        """ Gene set name. """ 
     28 
    2229        self.id = id 
     30        """ Short gene set ID. """ 
     31 
    2332        self.description = description 
     33        """ Gene set description. """ 
     34 
    2435        self.link = link 
     36        """ Link to further information about this gene set. """ 
     37 
    2538        self.organism = organism 
     39        """ Organism as a NCBI taxonomy ID. """ 
    2640 
    2741        if pair: 
     
    4963 
    5064    def cname(self, source=True, name=True): 
    51         """ Constructs a gene set name with the hierarchy. """ 
     65        """ Return a gene set name with hieararchy. """ 
    5266        oname = self.id 
    5367        if source and self.hierarchy: 
     
    5973    def to_odict(self, source=True, name=True): 
    6074        """ 
    61         Returns a pair (id, listofgenes), like in old format. 
     75        Backward compatibility: returns a gene set as a tuple 
     76        (id, list of genes). 
    6277        """ 
    6378        return self.cname(source=source, name=name), self.genes 
     
    7691 
    7792class GeneSets(set): 
     93    """ A collection of gene sets: contains :class:`GeneSet` objects.  
     94    It is a subclass of Python's :obj:`set`.  
     95    """ 
    7896     
    7997    def __init__(self, input=None): 
    8098        """ 
    81         odict are genesets in old dict format. 
    82         gs are genesets in new format 
     99        If input is a dictionary, the gene sets are converted to the current format. 
    83100        """ 
    84101        if input != None and len(input) > 0: 
     
    110127 
    111128    def set_hierarchy(self, hierarchy): 
    112         """ Sets hierarchy for all gene sets """ 
     129        """ Sets hierarchy for all gene sets. """ 
    113130        for gs in self: 
    114131            gs.hierarchy = hierarchy 
     
    118135 
    119136    def common_org(self): 
    120         """ Returns the common organism. """ 
     137        """ Return a common organism. """ 
    121138        if len(self) == 0: 
    122139            raise GenesetRegException("Empty gene sets.") 
     
    130147 
    131148    def hierarchies(self): 
    132         """ Returns all hierachies """ 
     149        """ Return all hierarchies. """ 
    133150        if len(self) == 0: 
    134151            raise GenesetRegException("Empty gene sets.") 
     
    136153 
    137154    def common_hierarchy(self): 
     155        """ Return a common hierarchy. """ 
    138156        hierarchies = self.hierarchies() 
    139157 
     
    148166 
    149167    def split_by_hierarchy(self): 
    150         """ Splits gene sets by hierarchies. """ 
     168        """ Split gene sets by hierarchies. Return a list of :class:`GeneSets` objects. """ 
    151169        hd = dict((h,GeneSets()) for h in  self.hierarchies()) 
    152170        for gs in self: 
  • orangecontrib/bio/obiGeneSetSig.py

    r1873 r1933  
    7474 
    7575        #build a new domain 
    76         print "WHOLE" 
     76        #print "WHOLE" 
    7777        newfeatures = self.build_features(data, gene_sets) 
    7878        newdomain = Orange.data.Domain(newfeatures, data.domain.class_var) 
     
    9191            data_cv = [ [] for _ in range(len(data)) ] 
    9292            for f in set(cvi): 
    93                 print "FOLD", f 
     93                #print "FOLD", f 
    9494                learn = data.select(cvi, f, negate=True) 
    9595                test = data.select(cvi, f) 
     
    100100                    zip(trans_test, [ i for i,n in enumerate(cvi) if n == f ]): 
    101101                    data_cv[pos] = ex.native(0) 
    102             print data_cv[0] 
    103102            return Orange.data.Table(newdomain, data_cv) 
    104103 
  • orangecontrib/bio/obiGeneSets.py

    r1877 r1933  
    273273def list_all(): 
    274274    """ 
    275     return a list of (hier, org, avalable_locally) 
    276     If something for a specific (hier, org) is not downloaded 
    277     yet, show it as not-local. """ 
     275    Return gene sets available in the local and ServerFiles repositories.  
     276    It returns a list of tuples of (hierarchy, organism, available_locally) 
     277    """ 
    278278    flist = list_local() + list_serverfiles() 
    279279    d = {} 
     
    345345 
    346346def register(genesets, serverFiles=None): 
    347     """ 
    348     Hierarchy is induced from the gene set names. 
     347    """ Registers given :class:`GeneSets` locally.  The gene set is registered 
     348    by the common hierarchy or organism (None if organisms are different). 
     349 
     350    If :obj:`serverFiles` as a authenticated ServerFiles connection, 
     351    the given gene sets are uploaded to the ServerFiles repository.   
    349352    """ 
    350353    if serverFiles == None: 
     
    384387 
    385388def load(hierarchy, organism): 
    386     """ First try to load from the local registred folder. If the file 
     389    """ First try to load from the local registered folder. If the file 
    387390    is not available, load it from the server files. """ 
    388391    try: 
     
    393396def collections(*args): 
    394397    """ 
    395     Input is a list of collections. 
    396     Collection can either be a tuple (hierarchy, orgranism), where 
    397     hierarchy is a tuple also. 
     398    Load gene sets from various sources: GMT file, GO, KEGG, and others.  
     399    Return an instance of :class:`GeneSets`.  
     400     
     401    Each arguments specifies a gene set and can be either: 
     402     
     403    * a filename of a GMT file, 
     404    * a tuple (hierarchy, organism) (for example ``(("KEGG",), "10090")``), or 
     405    * an instance of :class:`GeneSets` 
    398406    """ 
    399407    result = GeneSets() 
Note: See TracChangeset for help on using the changeset viewer.