def clip_parmdb(sb):
     run_process(
         input_parset.getString("pdbclip.executable"),
         "--auto",
         "--sigma=%f" % (input_parset.getFloat("pdbclip.sigma"),),
         os.path.join(sb, "instrument"),
     )
 def transfer_calibration(ms_pair):
     cal, target = ms_pair
     print "Transferring solution from %s to %s" % (cal, target)
     parmdb_name = mkdtemp(dir=scratch)
     run_process("parmexportcal", "in=%s/instrument/" % (cal, ),
                 "out=%s" % (parmdb_name, ))
     run_process("calibrate-stand-alone", "--parmdb", parmdb_name, target,
                 transfer_parset, transfer_skymodel)
Example #3
0
def run_blastn(query, db, out, threads, qcov=25, pid=98, evalue=1e-5):
    cmd = "blastn "
    cmd += "-query %s " % query
    cmd += "-db %s " % db
    cmd += "-out %s " % out
    cmd += "-outfmt '6 std qlen slen' "
    cmd += "-max_target_seqs 1 "
    cmd += "-max_hsps 1 "
    cmd += "-qcov_hsp_perc %s " % qcov
    cmd += "-perc_identity %s " % pid
    cmd += "-evalue %s " % evalue
    cmd += "-num_threads %s " % threads
    utility.run_process(cmd)
Example #4
0
def run_mash(mash_sketch, fna_path, tmp_dir, threads=1):
    out_path = '%s/mash.dist' % tmp_dir
    command = "mash dist -p %s -d 0.25 %s %s > %s" % (threads, fna_path,
                                                      mash_sketch, out_path)
    out, err = utility.run_process(command)
    with open(tmp_dir + '/id_map.tsv', 'w') as f:
        for id, rec in enumerate(utility.parse_mash(out_path)):
            f.write(str(id) + '\t' + rec['target'] + '\n')
Example #5
0
def blastn(query, target, outdir, id):
    out_path = outdir + '/' + id + '.m8'
    if not os.path.exists(out_path):
        cmd = "blastn -outfmt '6 std qlen slen' "
        cmd += "-max_target_seqs 1 -max_hsps 1 "
        cmd += "-query %s -subject %s " % (query, target)
        out, err = utility.run_process(cmd)
        open(out_path, 'w').write(out)
    else:
        out = open(out_path).read()
    return out
 def clip_parmdb(sb):
     run_process(input_parset.getString("pdbclip.executable"), "--auto",
                 "--sigma=%f" % (input_parset.getFloat("pdbclip.sigma"), ),
                 os.path.join(sb, "instrument"))
                aw_parset_name,
                target_info["skymodel"],
                input_parset.getString("make_mask.executable"),
                scratch,
                awim_init=awim_init)

    with time_code("Making images"):
        for target_info in ms_target.values():
            print "Making image %s" % target_info["output_im"]
            print run_awimager(
                aw_parset_name, {
                    "ms": target_info["bl_limit_ms"],
                    "mask": target_info["mask"],
                    "threshold": "%fJy" % (target_info["threshold"], ),
                    "image": target_info["output_im"],
                    "wmax": maxbl
                },
                initscript=awim_init)
            print "Updaging metadata in %s" % target_info["output_im"]
            run_process(
                "addImagingInfo",
                "%s.restored.corr" % target_info["output_im"],
                "",  # No sky model specified
                "0",
                str(maxbl),
                target_info["output_ms"])
            print "Saving mask for %s to %s" % (
                target_info["output_im"], target_info["output_im"] + ".mask")
            shutil.copytree(target_info["mask"],
                            target_info["output_im"] + ".mask")
 def transfer_calibration(ms_pair):
     cal, target = ms_pair
     print "Transferring solution from %s to %s" % (cal, target)
     parmdb_name = mkdtemp(dir=scratch)
     run_process("parmexportcal", "in=%s/instrument/" % (cal,), "out=%s" % (parmdb_name,))
     run_process("calibrate-stand-alone", "--parmdb", parmdb_name, target, transfer_parset, transfer_skymodel)
                input_parset.getString("make_mask.executable"),
                scratch,
                awim_init=awim_init,
            )

    with time_code("Making images"):
        for target_info in ms_target.values():
            print "Making image %s" % target_info["output_im"]
            print run_awimager(
                aw_parset_name,
                {
                    "ms": target_info["bl_limit_ms"],
                    "mask": target_info["mask"],
                    "threshold": "%fJy" % (target_info["threshold"],),
                    "image": target_info["output_im"],
                    "wmax": maxbl,
                },
                initscript=awim_init,
            )
            print "Updaging metadata in %s" % target_info["output_im"]
            run_process(
                "addImagingInfo",
                "%s.restored.corr" % target_info["output_im"],
                "",  # No sky model specified
                "0",
                str(maxbl),
                target_info["output_ms"],
            )
            print "Saving mask for %s to %s" % (target_info["output_im"], target_info["output_im"] + ".mask")
            shutil.copytree(target_info["mask"], target_info["output_im"] + ".mask")