@@ -0,0 +1,2424 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A# https://github.com/shenwei356/bio_scripts%0Afrom __future__ import print_function%0A%0Aimport argparse%0Aimport gzip%0Aimport logging%0Aimport os%0Aimport re%0Aimport sys%0A%0Afrom Bio import SeqIO%0Afrom Bio.Seq import Seq%0Afrom Bio.SeqRecord import SeqRecord%0Afrom Bio.SeqUtils import MeltingTemp as mt%0A%0A%0Adef parse_args():%0A    parser = argparse.ArgumentParser(description=%22Compute DNA MeltingTemp%22)%0A    group = parser.add_mutually_exclusive_group()%0A    group.add_argument(%22--stdin%22, action=%22store_true%22,%0A                       help='read from stdin, one sequence per line')%0A    group.add_argument('-i', '--infile', type=str,%0A                       help='file name should like this: infile.%5Bfasta%7Cfa%7Cfastq%7Cfq%5D%5B.gz%5D')%0A    parser.add_argument('-f', '--format', type=str, # default='fasta',%0A                        help='seqence format: fasta %7Cfastq  %5Bfasta%5D')%0A%0A    args = parser.parse_args()%0A    if not (args.stdin or args.infile):%0A        sys.stderr.write(%22option --stdin or -i should be given%5Cn%22)%0A        sys.exit(1)%0A    if args.format and not args.format in %5B'fasta', 'fastq'%5D:%0A        sys.stderr.write(%22option -f %7C --format should be 'fasta' or 'fastq'%5Cn%22)%0A        sys.exit(1)%0A    if args.stdin and not args.format:%0A        sys.stderr.write(%22option -f %7C --format should be given when --stdin is set.%5Cn%22)%0A        sys.exit(1)%0A%0A    return args%0A%0A%0Aif __name__ == '__main__':%0A    args = parse_args()%0A%0A    file, seq_format, fh = args.infile, args.format,  None,%0A    if file:%0A        if not seq_format:%0A            found = re.search(r'(?i)(fasta%7Cfa%7Cfastq%7Cfq)(.gz)?$', file)%0A            if not found:%0A                print(%22invalid file name suffix.%5Cnfile name should like this: infile.%5Bfasfa%7Cfa%7Cfastq%7Cfq%5D%5B.gz%5D%22,%0A                      file=sys.stderr)%0A                sys.exit(1)%0A            seq_format, is_gz = found.groups()%0A            if seq_format == 'fa':%0A                seq_format = 'fasta'%0A            if seq_format == 'fq':%0A                seq_format = 'fastq'%0A%0A        fh = gzip.open(file, 'rt') if file.endswith('.gz') else open(file, 'r')%0A    else:%0A        fh = sys.stdin%0A        seq_format = args.format%0A%0A%0A    sys.stdout.write('%7B%7D%5Ct%7B%7D%5Ct%7B%7D%5Ct%7B%7D%5Cn'.format('seq_id', 'Tm_Wallace', 'Tm_GC', 'Tm_NN'))%0A    for seq in SeqIO.parse(fh, seq_format):%0A        sys.stdout.write('%7B%7D%5Ct%7B:0.2f%7D%5Ct%7B:0.2f%7D%5Ct%7B:0.2f%7D%5Cn'.format(seq.id, mt.Tm_Wallace(seq.seq), mt.Tm_GC(seq.seq), mt.Tm_NN(seq.seq)))%0A    fh.close()%0A

add sequence/fastx_tm.py