本文整理汇总了Python中annogesiclib.helper.Helper.translation方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.translation方法的具体用法?Python Helper.translation怎么用?Python Helper.translation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类annogesiclib.helper.Helper
的用法示例。
在下文中一共展示了Helper.translation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SubLocal
# 需要导入模块: from annogesiclib.helper import Helper [as 别名]
# 或者: from annogesiclib.helper.Helper import translation [as 别名]
class SubLocal(object):
def __init__(self, args_sub):
self.multiparser = Multiparser()
self.helper = Helper()
self.fixer = FormatFixer()
self.gff_path = os.path.join(args_sub.gffs, "tmp")
self.fasta_path = os.path.join(args_sub.fastas, "tmp")
if args_sub.trans is not None:
self.tran_path = os.path.join(args_sub.trans, "tmp")
else:
self.tran_path = None
self.out_all = os.path.join(args_sub.out_folder, "all_CDS")
self.out_express = os.path.join(args_sub.out_folder, "expressed_CDS")
self.all_tmp_path = os.path.join(self.out_all, "tmp")
self.express_tmp_path = os.path.join(self.out_express, "tmp")
self.all_stat_path = os.path.join(self.out_all, "statistics")
self.express_stat_path = os.path.join(self.out_express, "statistics")
self.all_tmp_result = os.path.join(self.out_all, "tmp_results")
self.express_tmp_result = os.path.join(self.out_express, "tmp_results")
self.all_result = os.path.join(self.out_all, "psortb_results")
self.express_result = os.path.join(self.out_express, "psortb_results")
self.endfix_table = "table.csv"
self.endfix_raw = "raw.txt"
self._make_folder()
def _make_folder(self):
self.helper.check_make_folder(self.out_all)
self.helper.check_make_folder(self.out_express)
self.helper.check_make_folder(self.all_stat_path)
self.helper.check_make_folder(self.express_stat_path)
self.helper.check_make_folder(self.all_result)
self.helper.check_make_folder(self.express_result)
def _compare_cds_tran(self, gff_file, tran_file):
out = open(os.path.join(self.out_all, "tmp_cds.gff"), "w")
cdss = []
fh = open(gff_file)
th = open(tran_file)
for entry in Gff3Parser().entries(fh):
if entry.feature == "CDS":
cdss.append(entry)
trans = []
for entry in Gff3Parser().entries(th):
trans.append(entry)
for cds in cdss:
for ta in trans:
if (cds.strand == ta.strand) and (
cds.seq_id == ta.seq_id):
if ((cds.end < ta.end) and (
cds.end > ta.start) and (
cds.start <= ta.start)) or (
(cds.start > ta.start) and (
cds.start < ta.end) and (
cds.end >= ta.end)) or (
(cds.end >= ta.end) and (
cds.start <= ta.start)) or (
(cds.end <= ta.end) and (
cds.start >= ta.start)):
out.write(cds.info + "\n")
break
fh.close()
th.close()
out.close()
def _get_protein_seq(self, gff, tmp_path, tran_path):
prefix = gff.replace(".gff", "")
fasta = self.helper.get_correct_file(self.fasta_path, ".fa",
prefix, None, None)
dna_seq_file = os.path.join(tmp_path, "_".join([prefix, "dna.fa"]))
print("Generate CDS fasta files of {0}".format(prefix))
if tran_path is not None:
self._compare_cds_tran(os.path.join(self.gff_path, gff),
os.path.join(tran_path, "_".join([
prefix, "transcript.gff"])))
self.helper.get_cds_seq(os.path.join(self.out_all, "tmp_cds.gff"),
fasta, dna_seq_file)
os.remove(os.path.join(self.out_all, "tmp_cds.gff"))
else:
self.helper.get_cds_seq(os.path.join(self.gff_path, gff),
fasta, dna_seq_file)
print("transfer DNA seq to protein seq of {0}".format(prefix))
self.helper.translation(dna_seq_file, "tmp")
prot_seq_file = os.path.join(
tmp_path, "_".join([prefix, "protein.fa"]))
self.fixer.fix_emboss("tmp", prot_seq_file)
os.remove("tmp")
return prefix
def _psortb(self, psortb_path, strain_type, prot_seq_file,
out_raw, out_err):
call([psortb_path, strain_type, prot_seq_file],
stdout=out_raw, stderr=out_err)
def _run_psortb(self, args_sub, prefix, out_folder, tmp_path, tmp_result):
print("Running psortb of {0}".format(prefix))
out_err = open(os.path.join(out_folder, "tmp_log"), "w")
out_raw = open(os.path.join(tmp_result,
"_".join([prefix, self.endfix_raw])), "w")
prot_seq_file = os.path.join(tmp_path,
#.........这里部分代码省略.........
示例2: SubLocal
# 需要导入模块: from annogesiclib.helper import Helper [as 别名]
# 或者: from annogesiclib.helper.Helper import translation [as 别名]
class SubLocal(object):
'''detection of subcellular localization'''
def __init__(self, args_sub):
self.multiparser = Multiparser()
self.helper = Helper()
self.fixer = FormatFixer()
self.gff_path = os.path.join(args_sub.gffs, "tmp")
self.fasta_path = os.path.join(args_sub.fastas, "tmp")
if args_sub.trans is not None:
self.tran_path = os.path.join(args_sub.trans, "tmp")
else:
self.tran_path = None
self.out_all = os.path.join(args_sub.out_folder, "all_CDSs")
self.out_express = os.path.join(args_sub.out_folder, "expressed_CDSs")
self.all_tmp_path = os.path.join(self.out_all, "tmp")
self.express_tmp_path = os.path.join(self.out_express, "tmp")
self.all_stat_path = os.path.join(self.out_all, "statistics")
self.express_stat_path = os.path.join(self.out_express, "statistics")
self.all_tmp_result = os.path.join(self.out_all, "tmp_results")
self.express_tmp_result = os.path.join(self.out_express, "tmp_results")
self.all_result = os.path.join(self.out_all, "psortb_results")
self.express_result = os.path.join(self.out_express, "psortb_results")
self.endfix_table = "table.csv"
self.endfix_raw = "raw.txt"
self._make_folder()
def _make_folder(self):
self.helper.check_make_folder(self.out_all)
self.helper.check_make_folder(self.out_express)
self.helper.check_make_folder(self.all_stat_path)
self.helper.check_make_folder(self.express_stat_path)
self.helper.check_make_folder(self.all_result)
self.helper.check_make_folder(self.express_result)
def _compare_cds_tran(self, gff_file, tran_file, log):
'''compare CDS and transcript to find the expressed CDS'''
log.write("Comparing transcripts and CDSs to get expressed CDSs.\n")
out = open(os.path.join(self.out_all, "tmp_cds.gff"), "w")
cdss = []
fh = open(gff_file)
th = open(tran_file)
for entry in Gff3Parser().entries(fh):
if entry.feature == "CDS":
cdss.append(entry)
trans = []
for entry in Gff3Parser().entries(th):
trans.append(entry)
for cds in cdss:
for ta in trans:
if (cds.strand == ta.strand) and (
cds.seq_id == ta.seq_id):
if ((cds.end < ta.end) and (
cds.end > ta.start) and (
cds.start <= ta.start)) or (
(cds.start > ta.start) and (
cds.start < ta.end) and (
cds.end >= ta.end)) or (
(cds.end >= ta.end) and (
cds.start <= ta.start)) or (
(cds.end <= ta.end) and (
cds.start >= ta.start)):
out.write(cds.info + "\n")
break
fh.close()
th.close()
out.close()
log.write("\t" + os.path.join(self.out_all, "tmp_cds.gff") + " is "
"temporary generated.\n")
def _get_protein_seq(self, gff, tmp_path, tran_path, args_sub, log):
prefix = gff.replace(".gff", "")
fasta = self.helper.get_correct_file(self.fasta_path, ".fa",
prefix, None, None)
dna_seq_file = os.path.join(tmp_path, "_".join([prefix, "dna.fa"]))
print("Generating CDS fasta files of {0}".format(prefix))
if tran_path is not None:
log.write("Predicting subcellular localization for expressed "
"CDSs for {0}.\n".format(prefix))
self._compare_cds_tran(os.path.join(self.gff_path, gff),
os.path.join(tran_path, "_".join([
prefix, "transcript.gff"])), log)
log.write("Running helper.py to extract sequences for CDSs.\n")
self.helper.get_cds_seq(os.path.join(self.out_all, "tmp_cds.gff"),
fasta, dna_seq_file)
os.remove(os.path.join(self.out_all, "tmp_cds.gff"))
else:
log.write("Predicting subcellular localization for all CDSs for "
"{0}.\n".format(prefix))
log.write("Running helper.py to extract sequences for CDSs.\n")
self.helper.get_cds_seq(os.path.join(self.gff_path, gff),
fasta, dna_seq_file)
log.write("\t" + dna_seq_file + " is generated.\n")
print("Transfering DNA sequences to protein sequence of {0}".format(
prefix))
log.write("Running helper.py to translate DNA sequences to Protein "
"sequences.\n")
tmp_file = os.path.join(args_sub.out_folder, "tmp")
self.helper.translation(dna_seq_file, tmp_file)
prot_seq_file = os.path.join(
#.........这里部分代码省略.........