parsing_opts.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:RiboCode 作者: xzt41 项目源码 文件源码
def parsing_metaplots():
    parser = argparse.ArgumentParser(
        description="""
        This script create aggregate plots of distances from the 5'end of reads to start or stop codons,
        which help determine the length range of the PRF reads that are most likely originated from the
        translating ribosomes and identify the P-site locations for each reads lengths.
        """
    )
    parser.add_argument("-a","--annot_dir",dest="annot_dir",required=True,type=str,
                        help="transcripts annotation directory, generated by prepare_transcripts.")
    parser.add_argument("-r","--rpf_mapping_file",dest="rpf_mapping_file",required=True,type=str,
                        help="ribo-seq BAM/SAM file aligned to the transcriptome.")
    parser.add_argument("-s","--stranded",dest="stranded",required=False,type=str,choices=["yes","reverse"],
                        default="yes",help="whether the data is strand-specific, \
                        reverse means reversed strand interpretation.(default: yes)")
    parser.add_argument("-m","--minimum-length",dest="minLength",required=False,type=int,default=24,
                        help="minimum length of read to output, default 24")
    parser.add_argument("-M","--maximum-length",dest="maxLength",required=False,type=int,default=36,
                        help="maximum length of read to output, default 36")
    parser.add_argument("-pv1","--pvalue1_cutoff",dest="pvalue1_cutoff",required=False,type=float,default=0.001,
                        help="pvalue cutoff of frame0 > frame2 for automatically predicting P-site location, default 0.001")
    parser.add_argument("-pv2","--pvalue2_cutoff",dest="pvalue2_cutoff",required=False,type=float,default=0.001,
                        help="pvalue cutoff of frame0 > frame2 for automatically predicting P-site location, default 0.001")
    parser.add_argument("-f0_percent","--frame0_percent",dest="frame0_percent",required=False,type=float,default=0.65,
                        help="proportion threshold of the number of reads in frame0, defined by f0/(f0+f1+f2), default 0.65")
    parser.add_argument("-o","--outname",dest="outname",required=False,type=str,default="metaplots",
                        help="name of output pdf file(default: metaplots)")
    parser.add_argument('-V',"--version",action="version",version=__version__)
    args = parser.parse_args()

    if not os.path.exists(args.annot_dir):
        raise ValueError("Error, the transcript annotation directory not found: {} \n \
                          pleas run prepare_transcripts.py first.".format(args.annot_dir))
    if args.minLength > args.maxLength:
        raise ValueError("minimum length must be <= maximum length (currently %d and %d, respectively)" % (args.minLength, args.maxLength))
    if args.minLength <= 0 or  args.maxLength <=0:
        raise ValueError("minimum length or maximum length must be larger than 0.")
    if not os.path.exists(args.rpf_mapping_file):
        raise  ValueError("Error, the rpf mapping file not found: %s\n" % args.rpf_mapping_file)
    args.stranded = True if args.stranded == "yes" else False
    args.pvalue1_cutoff = float(args.pvalue1_cutoff)
    args.pvalue2_cutoff = float(args.pvalue2_cutoff)
    args.frame0_percent = float(args.frame0_percent)

    return args
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号