Esempio n. 1
0
#!/usr/bin/env python
'''Reads OTT files and produces a set of files with preorder
numbering that allow of minimal memory footprint in python scripts

Note: this script is a memory hog
'''

if __name__ == '__main__':
    from peyotl.ott import OTT
    ott = OTT()
    ott.create_pickle_files()

Esempio n. 2
0
 def ott(self):
     if self._ott is None:
         self._ott = OTT(self.ott_dir)
     return self._ott
Esempio n. 3
0
 def testTaxoRooting(self):
     ott = OTT()
     phylo = self.np.get_tree(tree_id='tree324')
     evaluate_tree_rooting(self.nexson, ott, phylo)
Esempio n. 4
0
        help='use this flag to keep the OTT ids in addition to the names')

    args = parser.parse_args()

    print "converting {f}".format(f=args.newick_file)
    print "using ott in {d}".format(d=args.ott_dir)
    if (args.keep_ottids):
        print "keeping OTT IDs in addition to names"
    else:
        print "replacing OTT IDs with names"

    # read pruned labelled synthesis tree
    ottpattern = re.compile(r"([(,)])(ott)(\d+)")
    mrcapattern = re.compile(r"([(,)])mrcaott(\d+)ott(\d+)")
    pos = 0
    ott = OTT(ott_dir=args.ott_dir)
    # load up the OTT dictionary...
    d = ott.ott_id_to_names
    outfile = codecs.open('ottnamelabelledtree.tre', 'w', encoding='utf-8')
    with open(args.newick_file, 'r') as f:
        newick = f.read()
        for m in re.finditer(ottpattern, newick):
            #print m.group(1),m.group(2),m.group(3)
            ottid = int(m.group(3))
            ottresults = d[ottid]
            ottname = ottresults
            if isinstance(ottresults, tuple):
                ottname = ottresults[0]
            print m.group(3), ottname
            skippedchars = newick[pos:m.start()]
            outfile.write(skippedchars)
Esempio n. 5
0
def ott_shell_command(args):
    ott = OTT()
    _LOG.info('launching bash in your OTT dir...')
    if subprocess.Popen('bash', cwd=ott.ott_dir).wait() != 0:
        raise RuntimeError('bash in ott dir failed.')
Esempio n. 6
0
def ott_clear_command(args):
    ott = OTT()
    ott.remove_caches()