def install_srna(species, gtf): out_file = os.path.join(SRNASEQ_DIR, "srna-transcripts.gtf") safe_makedir(SRNASEQ_DIR) if not os.path.exists(out_file): shutil.copyfile(gtf, out_file) try: from seqcluster import install except ImportError: raise ImportError("install seqcluster first, please.") with chdir(SRNASEQ_DIR): hairpin, miRNA = install._install_mirbase() cmd = ("grep -A 2 {species} {hairpin} | grep -v '\-\-$' | tr U T > hairpin.fa") do.run(cmd.format(**locals()), "set precursor.") cmd = ("grep -A 1 {species} {miRNA} > miRNA.str") do.run(cmd.format(**locals()), "set miRNA.") shutil.rmtree("mirbase") return out_file
def install_srna(species, gtf): out_file = os.path.join(SRNASEQ_DIR, "srna-transcripts.gtf") safe_makedir(SRNASEQ_DIR) if gtf: if not file_exists(out_file): shutil.copyfile(gtf, out_file) try: from seqcluster import install except ImportError: raise ImportError("install seqcluster first, please.") with chdir(SRNASEQ_DIR): hairpin, miRNA = install._install_mirbase() cmd = ("cat %s | awk '{if ($0~/>%s/){name=$0; print name} else if ($0~/^>/){name=0};if (name!=0 && $0!~/^>/){print $0;}}' | sed 's/U/T/g' > hairpin.fa") do.run(cmd % (hairpin, species), "set precursor.") cmd = ("grep -A 1 {species} {miRNA} > miRNA.str") do.run(cmd.format(**locals()), "set miRNA.") shutil.rmtree("mirbase") return out_file