Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(11)  |  Call(8)  |  Derive(0)  |  Import(3)

        def readFile(fileName, mode="rU"):
    if (zipfile.is_zipfile(fileName)):
       zfile = zipfile.ZipFile( fileName, mode );
       if (len(zfile.infolist()) == 1):
            return zfile.open(zfile.infolist()[0].filename, mode); #grab the first thing in there
       else : raise IOError("Only a zip file containing one item is accepted this contained :"+len(zfile.infolist()))
    elif (fileName.endswith(".tar") & tarfile.is_tarfile(fileName)):
        return tarfile.open(fileName, mode)
    elif (fileName.endswith(".gzip") or fileName.endswith(".gz")):
        return gzip.GzipFile(fileName , mode)
    elif (fileName.endswith(".bz2")):
        return bz2.BZ2File(fileName, mode)
        return open(fileName, mode)

src/a/i/AIGO-0.1.0/AIGO/go/OBO.py   AIGO(Download)
from AIGO import logger, logFun
from AIGO.utils.File  import checkForZip, readFile
from AIGO.go.GOGraph import get_GOGraph
            logger.info("Reading OBO file : %s" % fileName)
            G = get_GOGraph(readFile(fileName, mode="r"), prefix=prefix)

src/a/i/AIGO-0.1.0/AIGO/ReferenceSet.py   AIGO(Download)
from AIGO import logger, logFun
from AIGO.utils.File  import checkForZip, readFile
            if refType=="Fasta":
                from Bio import SeqIO
                allID=set([rec.name.split(";")[0].split(":")[-1] for rec in SeqIO.parse(readFile(fileName), "fasta")])
            #Use a simple text file to define the reference set, first column is chosen by default
            elif refType=="Text":
                allID=set([r[0] for r in csv.reader(readFile(fileName), delimiter=";")])
            #Use a Affymetrix annotation file to define the reference set
            elif refType=="AFFY":
                f = readFile(fileName)
                while row[0] == '#':

src/a/i/AIGO-0.1.0/AIGO/IO.py   AIGO(Download)
from AIGO import logger
from AIGO.utils.File  import checkForZip, readFile
IOType={"GO Annotation File":"GAF", "Blast2GO":"B2G", "Affymetrix":"AFFY", "ArrayIDer":"AID", "Mapping GPid GOids": "GP2GO"}
        GenetoGO[aspect], GOtoGene[aspect] =dict(), dict()
    rd=csv.reader(readFile(fileName), delimiter="\t")
    #sniff and seek dialect
    csvfile = readFile(fileName)
    #Read the entire file
    data=[row for row in csv.reader(readFile(fileName), delimiter="\t")]
    #Read the header
        GenetoGO[aspect], GOtoGene[aspect] =dict(), dict()
    rd=csv.reader(readFile(fileName), delimiter=";")