Changeset 1530:48dc3a3e2cac in orange-bioinformatics for obiArrayExpress.py


Ignore:
Timestamp:
01/30/12 15:14:38 (2 years ago)
Author:
ales_erjavec
Branch:
default
Message:

Fixed docstrings, typos.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • obiArrayExpress.py

    r1470 r1530  
    44=============== 
    55 
    6 A python module for accessing the ArrayExpress web services. 
     6A python module for accessing the ArrayExpress web services and database. 
    77 
    88`Array Express Archive <http://www.ebi.ac.uk/arrayexpress/>`_ is a database of gene expression experiments that you 
    99can query and download. 
    1010 
    11 Example of an Array Express query :: 
     11Example :: 
     12 
     13    >>> # Retrieve the object representing experiment with accession E-TABM-25  
     14    >>> experiment = ArrayExpressExperiment("E-TABM-25") 
     15    >>> print experiment.accession 
     16    E-TABM-25 
     17     
     18    >>> print experiment.name 
     19    Transcription profiling of aging in the primate brain 
     20     
     21    >>> print experiment.species 
     22    ['Pan troglodytes'] 
     23     
     24    >>> print experiment.files 
     25    [{'kind': ... 
     26     
     27    >>> # Retrieve the data matrix for experiment 'E-MEXP-2917' 
     28    >>> experiment = ArrayExpressExperiment("E-MEXP-2917") 
     29    >>> table = experiment.fgem_to_table()  
     30 
     31 
     32Low level Array Express query using REST services:: 
    1233 
    1334    >>> import obiArrayExpress 
     
    1940     
    2041    >>> obiArrayExpress.query_files(accession='E-MEXP-32', format="xml") 
    21     <xml.etree.ElementTree.ElementTree instance... 
     42    <xml.etree.ElementTree.ElementTree object ... 
    2243    
    2344.. note:: Currently querying ArrayExpress files only works with the xml format. 
     
    3152import urllib2 
    3253 
    33 import orngEnviron 
    3454import orngServerFiles 
    3555import warnings 
     
    473493            rows)  
    474494     
    475 class InvesigationDesign(dict): 
     495class InvestigationDesign(dict): 
    476496    """ Investigation design (contains the contents of the .idf). 
    477497     
     
    836856    directory. 
    837857     
    838     .. todo:: Add Characteristics, Factor Values ... to the feture.attributes dict 
     858    .. todo:: Add Characteristics, Factor Values ... to the feature.attributes dict 
    839859     
    840860    """ 
    841861    import Orange 
    842862    dirname = os.path.dirname(idf_filename) 
    843     idf = InvesigationDesign(idf_filename) 
     863    idf = InvestigationDesign(idf_filename) 
    844864     
    845865    sdrf_filename = os.path.join(dirname, idf.sdrf_file[0]) 
     
    891911     
    892912def _dictify(element): 
    893     """ Dictify and xml.etree.Element.Element instance. 
     913    """ 'Dictify' and xml.etree.Element.Element instance by taking all 
     914    subnode tags as keys and the corresponding text values as items i.e. turn 
     915    `<node><bla>foo</bla><a>b</b></node>` into a {"bla":"foo", "a":b"} 
     916         
    894917    """ 
    895918    if element is None: 
     
    901924    return dict 
    902925     
     926class SearchableList(list): 
     927    """ A list with a `search` method 
     928    """ 
     929    def search(self, **kwargs): 
     930        """ Search the list for elements with members that correspond the 
     931        supplied keyword arguments. 
     932         
     933            >>> foo.bar = "foo" 
     934            >>> list = SearchableList([foo, bar]) 
     935            >>> list.search(bar="foo") # Search for objects which have a member named "bar" and that member equals "foo" 
     936            [<__main__.foo object ... 
     937             
     938        """ 
     939        ret = [] 
     940        for obj in self: 
     941            for member, value in kwargs.items(): 
     942                if hasattr(obj, member) and getattr(obj, member) == value: 
     943                    ret.append(obj) 
     944        return ret 
    903945     
    904946class ArrayExpressExperiment(object): 
     
    915957        E-MEXP-2917.sdrf.txt http://www.ebi.ac.uk/arrayexpress/files/E-MEXP-2917/E-MEXP-2917.sdrf.txt 
    916958        ... 
     959         
     960        >>> table = ae.fgem_to_table() # Retieve the experiment data table  
    917961             
    918962    """ 
     
    9761020    def _download_processed(self): 
    9771021        """ Download the processed matrix file, and associated MAGE-TAB files (idf, sdrf, adf) 
     1022         
     1023        .. todo:: What about the raw data files (we need converters for other file types)  
    9781024        """ 
    9791025        assert(self.fgemdatafiles) 
     
    11051151            raise ValueError("The experiment '{0}' does not have an investigation design file".format(self.accession)) 
    11061152        file = files[0] 
    1107         return InvesigationDesign(self._open(file.get("url"))) 
     1153        return InvestigationDesign(self._open(file.get("url"))) 
    11081154         
    11091155         
     
    11191165         
    11201166    def fgem_to_table(self): 
     1167        """ Retrieve the processed matrix from the Array Express ftp 
     1168        server and convert it to an :class:`Orange.data.Table` instance. 
     1169          
     1170        """ 
    11211171        assert(self.fgemdatafiles) 
    11221172        repo_dir = orngServerFiles.localpath("ArrayExpress", self.accession) 
     
    11381188         
    11391189     
    1140 __doc__ += """\ 
     1190"""\ 
    11411191Gene Expression Atlas 
    11421192--------------------- 
     
    14341484        >>> condition = AtlasConditionExperiment("", "", "E-GEOD-24283") 
    14351485        >>> # Condition on experiments involving lung 
    1436         >>> condition = AtlasConditionGeneProperty("Organism_part", "Has", "lung") 
     1486        >>> condition = AtlasConditionExperiment("Organism_part", "Has", "lung") 
    14371487         
    14381488    """ 
     
    16201670    conn = ArrayExpressConnection() 
    16211671    import doctest 
    1622     doctest.testmod(optionflags=doctest.ELLIPSIS, extraglobs={"conn": conn}) 
     1672    foo = type("foo", (object,), {})() 
     1673    bar = type("bar", (object,), {})() 
     1674     
     1675    doctest.testmod(optionflags=doctest.ELLIPSIS, 
     1676                    extraglobs={"conn": conn, "foo": foo,"bar": bar}) 
    16231677     
    16241678     
Note: See TracChangeset for help on using the changeset viewer.