<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import logging
import gzip
import os
import re
import sys

logger = logging.getLogger("synmap.gene_order")
logger.setLevel(logging.INFO)

def main(input, output, gid1, gid2, feature1, feature2):
    '''
    Returns a dag file

    If feature1 or feature2 are genomic then the genomic hits need to be
    reordered differently. Otherwise the positions will be set from the
    data within the file.
    '''
    genomic = False
    with open(output, "w") as fp:
        fp.write("#\n")

    if not(os.path.exists(input)):
        logging.error("Input file: (%s) not found.", input)

    if not(feature1 == "genomic") and not(feature2 == "genomic"):
        logging.info("No genomic features were specified.")
    else:
        genomic = True

    logging.info("Opening %s for converting to gene order.", input)

    input_file = None
    if input.endswith("gz"):
        logging.info("Opening the input file with gzip.")
        with gzip.open(input, 'r') as fp:
            input_file = fp.readlines()
    else:
        logging.info("Opening the input file.")
        with open(input, 'r') as fp:
            input_file = fp.readlines()

    if not input_file:
        logging.error("The input file (" + input + ") was unable to be opened or is empty.")
        return 1

    if genomic:
        genomic_order = order_genes(input_file, feature1, feature2)

    logging.info("Writing %s in gene order.", args.output)

    with open(output, "a") as fp:
        for line in input_file:<commit_msg>Add check for zero-length input file<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import logging
import gzip
import os
import re
import sys

logger = logging.getLogger("synmap.gene_order")
logger.setLevel(logging.INFO)

def main(input, output, gid1, gid2, feature1, feature2):
    '''
    Returns a dag file

    If feature1 or feature2 are genomic then the genomic hits need to be
    reordered differently. Otherwise the positions will be set from the
    data within the file.
    '''
    genomic = False
    with open(output, "w") as fp:
        fp.write("#\n")

    if not(os.path.exists(input)):
        logging.error("Input file: (%s) not found.", input)
        
    if os.stat(input).st_size == 0:
        logging.error("Input file: (%s) is empty.", input)

    if not(feature1 == "genomic") and not(feature2 == "genomic"):
        logging.info("No genomic features were specified.")
    else:
        genomic = True

    logging.info("Opening %s for converting to gene order.", input)

    input_file = None
    if input.endswith("gz"):
        logging.info("Opening the input file with gzip.")
        with gzip.open(input, 'r') as fp:
            input_file = fp.readlines()
    else:
        logging.info("Opening the input file.")
        with open(input, 'r') as fp:
            input_file = fp.readlines()

    if not input_file:
        logging.error("The input file (" + input + ") was unable to be opened or is empty.")
        return 1

    if genomic:
        genomic_order = order_genes(input_file, feature1, feature2)

    logging.info("Writing %s in gene order.", args.output)

    with open(output, "a") as fp:
        for line in input_file:
{'fraction_non_alphanumeric': 0.11654940348730498, 'fraction_numerical': 0.007647598654022637, 'mean_word_length': 2.6741573033707864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5422546', 'n_tokens_mistral': 1011, 'n_tokens_neox': 973, 'n_words': 337}