Esempio n. 1
0
 def test_peptide_cleavage_prediction_single_input(self):
     for m in CleavageSitePredictorFactory.available_methods():
         if m.lower() != "netchop":
             mo = CleavageSitePredictorFactory(m)
             mo.predict(self.seqs[0])
             mo.predict(self.seqs[1])
Esempio n. 2
0
 def test_peptide_cleavage_prediction_mixed_input(self):
     for m in CleavageSitePredictorFactory.available_methods():
         if m != "NetChop":
             mo = CleavageSitePredictorFactory(m)
             mo.predict(self.seqs)
Esempio n. 3
0
def main():
    #Specify CTD interface
    # Every CTD Model has to have at least a name and a version, plus any of the optional attributes below them.
    model = argparse.ArgumentParser(
        description='Commandline tool for cleavage site prediction', )

    model.add_argument(
        '-m',
        '--method',
        type=str,
        choices=CleavageSitePredictorFactory.available_methods().keys(),
        default="pcm",
        help='The name of the prediction method')

    model.add_argument('-v',
                       '--version',
                       type=str,
                       default="",
                       help='The version of the prediction method')

    model.add_argument('-i',
                       '--input',
                       type=str,
                       required=True,
                       help='Path to the input file (in fasta format)')

    model.add_argument('-l',
                       '--length',
                       type=int,
                       default=0,
                       help='The length of peptides')

    model.add_argument(
        '-op',
        '--options',
        type=str,
        default="",
        help="Additional options that get directly past to the tool")

    model.add_argument('-o',
                       '--output',
                       type=str,
                       required=True,
                       help='Path to the output file')

    args = model.parse_args()

    #fasta protein
    peptides = read_fasta(args.input, in_type=Protein)

    if args.version == "":
        predictor = CleavageSitePredictorFactory(args.method)
        result = predictor.predict(peptides, options=args.method)
    else:
        predictor = CleavageSitePredictorFactory(args.method,
                                                 version=args.version)
        result = predictor.predict(peptides, options=args.method)

    #if length is specified, than generate compact output
    if int(args.length) > 0:
        length = int(args.length)
        with open(args.output, "w") as f:
            f.write("Sequence\tMethod\tScore\tProtein ID\tPosition\n")
            for seq_id in set(result.index.get_level_values(0)):
                seq = "".join(result.ix[seq_id]["Seq"])
                for start in xrange(len(seq) - (length - 1)):
                    pep_seq = seq[start:(start + length)]
                    score = result.loc[(seq_id, start + (length - 1)),
                                       predictor.name]
                    f.write(pep_seq + "\t" + predictor.name + "\t" +
                            "%.3f" % score + "\t" + seq_id + "\t" +
                            str(start) + "\n")
    else:
        result.to_csv(args.output, float_format="%.3f", sep="\t")
    return 0
Esempio n. 4
0
def main():
    model = argparse.ArgumentParser(
        description='Commandline tool for string-of-beads epitope assembly',
        )

    model.add_argument('-i',
        '--input',
        type=str,
        required=True,
        help='Path to the input file'
        )

    model.add_argument('-m',
        '--method',
        type=str,
        choices=CleavageSitePredictorFactory.available_methods().keys(),
        default="pcm",
        help='The name of the prediction method'
        )

    model.add_argument('-v',
        '--version',
        type=str,
        default="",
        help='The version of the prediction method'
        )

    model.add_argument('-w',
        '--weight',
        type=float,
        default=0.0,
        help="Specifies how strong unwanted cleavage sites should be punished [0,1], \
                             where 0 means they will be ignored, and 1 the sum of all unwanted cleave sites is \
                             subtracted from the cleave site between two epitopes"
        )

    model.add_argument('-a',
        '--approximate',
        action="store_true",
        help="Flag whether epitope ordering should be approximated"
    )

    model.add_argument('-s',
        '--solver',
        type=str,
        default="cbc",
        help="The ILP solver to be used by Pyomo (must be in PATH)"
    )

    model.add_argument('-so',
        '--solver_options',
        type=str,
        default="",
        help="Solver specific options (will not be checked for correctness)"
    )

    model.add_argument('-o',
        '--output',
        type=str,
        required=True,
        help='Path to the output file'
        )

    args = model.parse_args()

    try:
        peptides = read_lines(args.input)
    except Exception as e:
        print e
        sys.stderr.write("Input file could not be read. Please check the existence and input format.")
        return -1

    try:
        if args.version == "":
            predictor = CleavageSitePredictorFactory(args.method)
        else:
            predictor = CleavageSitePredictorFactory(args.method, version=args.version)
    except ValueError as e:
        sys.stderr.write(str(e))
        return -1

    try:
        assembler = EpitopeAssembly(peptides, predictor, solver=args.solver, weight=args.weight)
    except Exception as e:
        sys.stderr.write(str(e))
        return -1

    try:
        if args.approximate:
            assembly = assembler.approximate()
        else:
            options = {} 
            for opt in args.solver_options.split():
                name,value = opt.partition("=")[::2]
                try:
                    options[name] = float(value)
                except Exception:
                    options[name] = value
            assembly = assembler.solve(options=options)
    except Exception as e:
        sys.stderr.write(str(e))
        return -1

    try:
        with open(args.output, "w") as f:
            f.write(">assembled_polypeptide\n"+"".join(str(p) for p in assembly))
    except IOError as e:
        sys.stderr.write(str(e))
        return -1

    return 0
Esempio n. 5
0
 def test_CleavageSite_prediction_available_methods(self):
     print CleavageSitePredictorFactory.available_methods()
Esempio n. 6
0
 def test_CleavageSite_prediction_available_methods(self):
     print CleavageSitePredictorFactory.available_methods()
Esempio n. 7
0
 def test_peptide_cleavage_prediction_single_input(self):
     for m in CleavageSitePredictorFactory.available_methods():
         if m.lower() != "netchop":
             mo = CleavageSitePredictorFactory(m)
             mo.predict(self.seqs[0])
             mo.predict(self.seqs[1])
Esempio n. 8
0
def main():
    #Specify CTD interface
    # Every CTD Model has to have at least a name and a version, plus any of the optional attributes below them.
    model = argparse.ArgumentParser(
        description='Commandline tool for cleavage site prediction',
        )

    model.add_argument('-m',
        '--method',
        type=str,
        choices=CleavageSitePredictorFactory.available_methods().keys(),
        default="pcm",
        help='The name of the prediction method'
        )

    model.add_argument('-v',
        '--version',
        type=str,
        default="",
        help='The version of the prediction method'
        )

    model.add_argument('-i',
        '--input',
        type=str,
        required=True,
        help='Path to the input file (in fasta format)'
        )

    model.add_argument('-l',
        '--length',
        type=int,
        default=0,
        help='The length of peptides'
        )

    model.add_argument('-op',
        '--options',
        type=str,
        default="",
        help="Additional options that get directly past to the tool"
    )

    model.add_argument('-o',
        '--output',
        type=str,
        required=True,
        help='Path to the output file'
        )

    args = model.parse_args()

    #fasta protein
    peptides = read_fasta(args.input, in_type=Protein)

    if args.version == "":
        predictor = CleavageSitePredictorFactory(args.method)
        result = predictor.predict(peptides, options=args.method)
    else:
        predictor = CleavageSitePredictorFactory(args.method, version=args.version)
        result = predictor.predict(peptides, options=args.method)

    #if length is specified, than generate compact output
    if int(args.length) > 0:
        length = int(args.length)
        with open(args.output, "w") as f:
            f.write("Sequence\tMethod\tScore\tProtein ID\tPosition\n")
            for seq_id in set(result.index.get_level_values(0)):
                    seq = "".join(result.ix[seq_id]["Seq"])
                    for start in xrange(len(seq)-(length-1)):
                        pep_seq = seq[start:(start+length)]
                        score = result.loc[(seq_id, start+(length-1)), predictor.name]
                        f.write(pep_seq+"\t"+predictor.name+"\t"+"%.3f"%score+"\t"+seq_id+"\t"+str(start)+"\n")
    else:
        result.to_csv(args.output, float_format="%.3f", sep="\t")
    return 0