File: easy_align.py

package info (click to toggle)
spades 3.13.1+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 22,172 kB
  • sloc: cpp: 136,213; ansic: 48,218; python: 16,809; perl: 4,252; sh: 2,115; java: 890; makefile: 507; pascal: 348; xml: 303
file content (43 lines) | stat: -rwxr-xr-x 1,501 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python3
import os
import sys

pipeline_modules_home = 'src/spades_pipeline/'#os.path.dirname(os.path.realpath(__file__)
sys.path.append(os.path.join(pipeline_modules_home, "common"))
sys.path.append(os.path.join(pipeline_modules_home, "truspades"))

import logging
import alignment

#import spades_init
#spades_init.init()


def align(contigs_file, left, right, out_dir, threads):
    #logging
    log = logging.getLogger('reference_construction')
    log.setLevel(logging.INFO)
    console = logging.StreamHandler(sys.stderr)
    console.setFormatter(logging.Formatter('%(message)s'))
    console.setLevel(logging.INFO)
    log.addHandler(console)
    #logging

    bwa_command='bin/spades-bwa'
    index = alignment.index_bwa(bwa_command, log, contigs_file, os.path.join(out_dir, "bwa_index"), "bwtsw")
    index = os.path.join(out_dir, "bwa_index", "index")
    sam = alignment.align_bwa_pe_lib(bwa_command, index, left, right, os.path.join(out_dir, "align"), log, threads)
    #index_bwa(command, log, reference, work_dir, algorithm = "is"):
    #align_bwa_pe_lib(command, work_dir + "/index", reads_file1, reads_file2, work_dir, log, threads = 1):

if __name__ == '__main__':

    if len(sys.argv) < 5:
        sys.stderr.write("Usage: %s <contigs> <left_reads> <right_reads> <out_dir> [threads = 8]\n" % sys.argv[0])
        exit(1)

    threads = 8
    if len(sys.argv) >= 6:
        threads = int(sys.argv[5])

    align(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], threads)