File: ht2example.py

package info (click to toggle)
hisat2 2.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,448 kB
  • sloc: cpp: 97,109; python: 11,075; perl: 7,279; sh: 2,328; ansic: 1,458; makefile: 532; javascript: 273; java: 116
file content (68 lines) | stat: -rwxr-xr-x 1,750 bytes parent folder | download | duplicates (3)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python3

#
# Copyright 2018, Chanhee Park <parkchanhee@gmail.com> and Daehwan Kim <infphilo@gmail.com>
#
# This file is part of HISAT 2.
#
# HISAT 2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# HISAT 2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with HISAT 2.  If not, see <http://www.gnu.org/licenses/>.

#
# ./setup.py build
# ./setup.py install
#
import ht2py 

# Path to index
ht2_index = '../../evaluation/indexes/HISAT2_22/22_rep'

# Get default options
ht2_options = ht2py.get_options()

print(ht2_options)
ht2_options['gVerbose'] = 1
ht2_options['startVerbose'] = 1
# or
ht2_options = {}

handle = ht2py.init(ht2_index, ht2_options)

print(ht2py.index_getrefnamebyid(handle, 0))

#print ht2py.index_getrefnamebyid(handle, 0, 1, 3, 5, 7, 9)
# outofindex
#print ht2py.index_getrefnamebyid(handle, 1)
#print ht2py.index_getrefnamebyid(handle, -1)

refnames = ht2py.index_getrefnames(handle)

#for name in refnames:
#    print name

# repeat expansion
positions = ht2py.repeat_expand(handle, 'rep100-300', 8308, 100) 

for pos in positions:
    chr_id = pos[0]
    direction = pos[1]
    chr_pos = pos[2]

    chr_dir = '+'
    if direction == 1:
        chr_dir = '-'

    print(refnames[chr_id].split()[0] + ":" + str(chr_pos) + ':' + chr_dir)

# close handle
ht2py.close(handle)