def test_path_option_and_optionl_parameters(self):
     netchop = CleavageSitePredictorFactory("NetChop")
     exe = netchop.command.split()[0]
     for try_path in os.environ["PATH"].split(os.pathsep):
         try_path = try_path.strip('"')
         exe_try = os.path.join(try_path, exe).strip()
         if os.path.isfile(exe_try) and os.access(exe_try, os.X_OK):
             print exe_try
             netchop.predict(self.seqs, path=exe_try, options="-v 1")
 def test_wrong_input(self):
     with self.assertRaises(ValueError):
         mo = CleavageSitePredictorFactory("NetChop")
         mo.predict(self.seqs[0])
 def test_peptide_cleavage_prediction_mixed_input(self):
     mo = CleavageSitePredictorFactory("NetChop")
     mo.predict(self.seqs)
 def test_peptide_cleavage_prediction_single_input(self):
     mo = CleavageSitePredictorFactory("NetChop")
     mo.predict(self.seqs[0])
     mo.predict(self.seqs[1])
예제 #5
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])
예제 #6
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
예제 #7
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)
예제 #8
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])
예제 #9
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