<commit_before>package gngs.tools

import gngs.Region
import gngs.ToolBase
import groovy.util.logging.Log

/**
 * Simple tool that translates between genome coordinates with automatic
 * download and caching of the chain files.
 * 
 * @author <NAME>
 */
@Log
class LiftOver extends ToolBase {

    @Override
    public void run() {
        gngs.LiftOver lo = new gngs.LiftOver(from: opts.from, to: opts.to)
        
        def formatResult = opts.tabs ? {
           if(it)
               println([it.chr, it.from, it.to].join("\t")) 
        } : {
           if(it)
               println(it.toString()) 
        }
        
        int count = 0
        if(opts.arguments().isEmpty()) {
            System.in.eachLine {  line ->
                println formatResult(lo.liftOver(new Region(line.trim())))
                ++count
            }
        }
        else
        for(String regionValue in opts.arguments()) {
            println formatResult(lo.liftOver(new Region(regionValue)))
                ++count
        }
        
        log.info "Lifted over ${count} coordinates."
    }
    
    static void main(String[] args) {
        cli('Liftover -from <hg38|hg19> -to <hg38|g19> <region1> <region2> ...',
            'Lifts over regions provided as arguments or, if no arguments, reads from standard input', args) {
            tabs 'Set output format to tab separated'
            from 'Genome build of the source coordinates', args: 1, required: true
            to 'Genome build of the target coordinates', args: 2, required: true
        }
    }
}<commit_msg>fix null printed by LiftOver<commit_after>package gngs.tools

import gngs.Region
import gngs.ToolBase
import groovy.util.logging.Log

/**
 * Simple tool that translates between genome coordinates with automatic
 * download and caching of the chain files.
 * 
 * @author <NAME>
 */
@Log
class LiftOver extends ToolBase {

    @Override
    public void run() {
        gngs.LiftOver lo = new gngs.LiftOver(from: opts.from, to: opts.to)
        
        def formatResult = opts.tabs ? {
           if(it)
               return ([it.chr, it.from, it.to].join("\t")) 
        } : {
           if(it)
               return (it.toString()) 
        }
        
        int count = 0
        if(opts.arguments().isEmpty()) {
            System.in.eachLine {  line ->
                println formatResult(lo.liftOver(new Region(line.trim())))
                ++count
            }
        }
        else
        for(String regionValue in opts.arguments()) {
            println formatResult(lo.liftOver(new Region(regionValue)))
                ++count
        }
        
        log.info "Lifted over ${count} coordinates."
    }
    
    static void main(String[] args) {
        cli('Liftover -from <hg38|hg19> -to <hg38|g19> <region1> <region2> ...',
            'Lifts over regions provided as arguments or, if no arguments, reads from standard input', args) {
            tabs 'Set output format to tab separated'
            from 'Genome build of the source coordinates', args: 1, required: true
            to 'Genome build of the target coordinates', args: 2, required: true
        }
    }
}
{'fraction_non_alphanumeric': 0.10798863277549732, 'fraction_numerical': 0.008209662140827282, 'mean_word_length': 1.872166817769719, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '241184', 'n_tokens_mistral': 944, 'n_tokens_neox': 885, 'n_words': 266}