Skip to content

Commit

Permalink
Started debugging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nschcolnicov committed Nov 6, 2024
1 parent 448318b commit 693b7d8
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 5 deletions.
Binary file added data/examples/annotate/SQL_sample.db
Binary file not shown.
Binary file added data/examples/annotate/mirtop.db
Binary file not shown.
3 changes: 3 additions & 0 deletions mirtop/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from mirtop.libs import spikeins
from mirtop.gff import update
from mirtop.sql import sql
from mirtop.mirna import mapper
import mirtop.libs.logger as mylog

import time
Expand All @@ -25,6 +26,8 @@ def main(**kwargs):
kwargs['args'].print_debug)
logger = mylog.getLogger(__name__)
start = time.time()
if (not hasattr(kwargs["args"], "database") and ("sql" not in kwargs and "stats" not in kwargs and "update" not in kwargs)):
kwargs["args"].database = mapper.guess_database(kwargs["args"])

if "gff" in kwargs:
logger.info("Run annotation")
Expand Down
2 changes: 1 addition & 1 deletion mirtop/exporter/isomirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def convert(args):
def _convert_file(gff, args):
sep = "\t"
precursors = fasta.read_precursor(args.hairpin, args.sps)
matures = mapper.read_gtf_to_precursor(args.gtf)
matures = mapper.read_gtf_to_precursor(args.gtf, args.database)
variant_header = sep.join(['mism', 'add', 't5', 't3'])

gff_file = open(gff, 'r')
Expand Down
6 changes: 3 additions & 3 deletions mirtop/exporter/vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def convert(args):
for fn in args.files:
out_file = op.join(args.out, "%s.vcf" % op.splitext(op.basename(fn))[0])
logger.info("Reading %s" % fn)
create_vcf(fn, args.hairpin, args.gtf, out_file)
create_vcf(fn, args.hairpin, args.gtf, out_file, args.database)
logger.info("VCF generated %s" % out_file)


Expand Down Expand Up @@ -121,7 +121,7 @@ def cigar_2_key(cigar, readseq, refseq, pos, var5p, var3p, parent_ini_pos, paren
return(key_pos, key_var, ref, alt)


def create_vcf(mirgff3, precursor, gtf, vcffile):
def create_vcf(mirgff3, precursor, gtf, vcffile, database):
"""
Args:
'mirgff3(str)': File with mirGFF3 format that will be converted
Expand Down Expand Up @@ -178,7 +178,7 @@ def create_vcf(mirgff3, precursor, gtf, vcffile):
n_noSNP = 0
no_var = 0
hairpins = read_precursor(precursor)
gff3 = read_gtf_to_precursor(gtf)
gff3 = read_gtf_to_precursor(gtf, database)
gtf_dic = read_gtf_to_mirna(gtf)
for line in range(0, len(gff3_data)):
if not gff3_data[line]:
Expand Down
2 changes: 1 addition & 1 deletion mirtop/gff/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def reader(args):
args.database = database
precursors = fasta.read_precursor(args.hairpin, args.sps)
args.precursors = precursors
matures = mapper.read_gtf_to_precursor(args.gtf)
matures = mapper.read_gtf_to_precursor(args.gtf, args.database)
args.matures = matures
# TODO check numbers of miRNA and precursors read
# TODO print message if numbers mismatch
Expand Down
2 changes: 2 additions & 0 deletions mirtop/mirna/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def guess_database(args):
TODO: this needs to be generic to other databases.
"""
if not hasattr(args, "database"):
args.database = None
return _guess_database_file(args.gtf, args.database)


Expand Down

0 comments on commit 693b7d8

Please sign in to comment.