Example #1
0
    def run(self):
        if not os.path.isdir(self.polishing_dir):
            os.mkdir(self.polishing_dir)

        prev_assembly = self.in_contigs
        contig_lengths = None
        for i in xrange(self.args.num_iters):
            logger.info("Polishing genome ({0}/{1})".format(i + 1,
                                                            self.args.num_iters))

            alignment_file = os.path.join(self.polishing_dir,
                                          "minimap_{0}.sam".format(i + 1))
            logger.info("Running Minimap2")
            aln.make_alignment(prev_assembly, self.reads, self.args.threads,
                               self.polishing_dir, self.args.platform,
                               alignment_file)

            logger.info("Separating alignment into bubbles")

            contigs_info = aln.get_contigs_info(prev_assembly)
            bubbles_file = os.path.join(self.polishing_dir,
                                        "bubbles_{0}.fasta".format(i + 1))
            coverage_stats = \
                bbl.make_bubbles(alignment_file, contigs_info, prev_assembly,
                                 self.args.platform, self.args.threads,
                                 config.vals["min_aln_rate"], bubbles_file)

            logger.info("Correcting bubbles")
            polished_file = os.path.join(self.polishing_dir,
                                         "polished_{0}.fasta".format(i + 1))
            contig_lengths = pol.polish(bubbles_file, self.args.threads,
                                        self.args.platform, self.polishing_dir,
                                        i + 1, polished_file)
            prev_assembly = polished_file

        with open(self.out_files["stats"], "w") as f:
            f.write("seq_name\tlength\tcoverage\n")
            for ctg_id in contig_lengths:
                f.write("{0}\t{1}\t{2}\n".format(ctg_id,
                                                 contig_lengths[ctg_id], coverage_stats[ctg_id]))
Example #2
0
 def test_paren(self):
     self.assertEquals(polish.polish("(A + B) * C"), "AB+C*")
Example #3
0
 def test_mult_add(self):
     self.assertEquals(polish.polish("A * B + C"), "AB*C+")
Example #4
0
 def test_add_mult(self):
     self.assertEquals(polish.polish("A + B * C"), "ABC*+")
Example #5
0
 def test_simple_mult(self):
     self.assertEquals(polish.polish("A * B"), "AB*")
Example #6
0
 def test_multi_addition(self):
     self.assertEquals(polish.polish("A + B + C"), "ABC++")
Example #7
0
 def test_simple_addition(self):
     self.assertEquals(polish.polish("A + B"), "AB+")
Example #8
0
 def test_paren(self):
     self.assertEquals(polish.polish("(A + B) * C"), "AB+C*")
Example #9
0
 def test_add_mult(self):
     self.assertEquals(polish.polish("A + B * C"), "ABC*+")
Example #10
0
 def test_mult_add(self):
     self.assertEquals(polish.polish("A * B + C"), "AB*C+")
Example #11
0
 def test_simple_mult(self):
     self.assertEquals(polish.polish("A * B"), "AB*")
Example #12
0
 def test_multi_addition(self):
     self.assertEquals(polish.polish("A + B + C"), "ABC++")
Example #13
0
 def test_simple_addition(self):
     self.assertEquals(polish.polish("A + B"), "AB+")
Example #14
0
 def test_complex(self):
     self.assertEquals(polish.polish("(A + B) * (B + C * F)"), "AB+BCF*+*")
Example #15
0
 def test_complex(self):
     self.assertEquals(polish.polish("(A + B) * (B + C * F)"), "AB+BCF*+*")
Example #16
0
            norm = e2.contract(AT[j], AT[lut[j, 0, 1]])
            czz += e2.contract(ZT[j], ZT[lut[j, 0, 1]]) / norm

            w1 = np.dot(e.c1[j], e.c2[lut[j, 1, 0]])
            w2 = np.dot(e.c3[lut[j, 1, 1]], e.c4[lut[j, 0, 1]])
            xi = np.linalg.svd(np.dot(w1, w2))[1]
            xi = xi[np.nonzero(xi)]
            S += np.dot(xi ** 2, np.log(xi))

        E = (-czz - h * mx) / n
        mz /= n
        return [mz, S, E]

    return test_fct_impl


a, nns = peps.load(basepath_in + statefile)
lut = util.build_lattice_lookup_table(nns, [4, 4])


def save_callback(a):
    peps.save(a, lut, basepath_out + statefile[statefile.rfind("/") + 1 :])


ecf = tebd.CTMRGEnvContractorFactory(lut, chi, test_fct, 1e-12, 1e-15)
a = polish(a, lut, ecf, num_workers=num_workers, peps_save_callback=save_callback)

peps.save(a, lut, basepath_out + statefile[statefile.rfind("/") + 1 :])

print "tfi_gs_polish.py done; needed {0:f} seconds".format(time() - t0)
Example #17
0
File: main.py Project: JuliaSyz/spo
import lexems
from pars import *
import polish

if __name__ == '__main__':
    file = open("test.txt")
    text = file.read()
    file.close()
    tokens = lexems.lex(text)
    for token in tokens:
        print(token.element, token.type)

    flag = if_right(tokens)

    if flag:
        print('true')
        polish.polish(tokens)