def yeasttruth(args):
    """
    %prog yeasttruth Pillars.tab *.gff

    Prepare pairs data for 14 yeasts.
    """
    p = OptionParser(yeasttruth.__doc__)
    p.set_outfile()
    opts, args = p.parse_args(args)

    if len(args) < 2:
        sys.exit(not p.print_help())

    pillars = args[0]
    gffiles = args[1:]
    aliases = {}
    pivot = {}
    for gffile in gffiles:
        is_pivot = op.basename(gffile).startswith("Saccharomyces_cerevisiae")
        gff = Gff(gffile)
        for g in gff:
            if g.type != "gene":
                continue
            for a in g.attributes["Alias"]:
                aliases[a] = g.accn
                if is_pivot:
                    pivot[a] = g.accn
    logging.debug("Aliases imported: {0}".format(len(aliases)))
    logging.debug("Pivot imported: {0}".format(len(pivot)))
    fw = open("yeast.aliases", "w")
    for k, v in sorted(aliases.items()):
        print("\t".join((k, v)), file=fw)
    fw.close()

    fp = open(pillars)
    pairs = set()
    fw = must_open(opts.outfile, "w")
    for row in fp:
        atoms = [x for x in row.split() if x != "---"]
        pps = [pivot[x] for x in atoms if x in pivot]
        atoms = [aliases[x] for x in atoms if x in aliases]
        for p in pps:
            for a in atoms:
                if p == a:
                    continue
                pairs.add(tuple(sorted((p, a))))

    for a, b in sorted(pairs):
        print("\t".join((a, b)), file=fw)
    fw.close()
def yeasttruth ( args ) : p = OptionParser ( yeasttruth . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) < 2 : sys . exit ( not p . print_help ( ) ) pillars = args [ 0 ] gffiles = args [ 1 : ] aliases = { } pivot = { } for gffile in gffiles : is_pivot = op . basename ( gffile ) . startswith ( "Saccharomyces_cerevisiae" ) gff = Gff ( gffile ) for g in gff : if g . type != "gene" : continue for a in g . attributes [ "Alias" ] : aliases [ a ] = g . accn if is_pivot : pivot [ a ] = g . accn logging . debug ( "Aliases imported: {0}" . format ( len ( aliases ) ) ) logging . debug ( "Pivot imported: {0}" . format ( len ( pivot ) ) ) fw = open ( "yeast.aliases" , "w" ) for k , v in sorted ( aliases . items ( ) ) : print ( "\t" . join ( ( k , v ) ) , file = fw ) fw . close ( ) fp = open ( pillars ) pairs = set ( ) fw = must_open ( opts . outfile , "w" ) for row in fp : atoms = [ x for x in row . split ( ) if x != "---" ] pps = [ pivot [ x ] for x in atoms if x in pivot ] atoms = [ aliases [ x ] for x in atoms if x in aliases ] for p in pps : for a in atoms : if p == a : continue pairs . add ( tuple ( sorted ( ( p , a ) ) ) ) for a , b in sorted ( pairs ) : print ( "\t" . join ( ( a , b ) ) , file = fw ) fw . close ( )
%prog yeasttruth Pillars.tab *.gff

    Prepare pairs data for 14 yeasts.