<commit_before>from GamTools import corr
import numpy as np
import argparse

parser = argparse.ArgumentParser(description='Calculate coverage over different window sizes for a list of bam files.')
parser.add_argument('npz_frequencies_file', help='An npz file containing co-segregation frequencies to convert to correlations')

args = parser.parse_args()

correlation_file = args.npz_frequencies_file.split('.')
correlation_file = correlation_file[0] + '.correlations.npz'

freqs = np.load(args.npz_frequencies_file)['freqs']

def flatten_freqs(freqs):
        
    freqs_shape = freqs.shape
    flat_shape = ( freqs_shape[0] * freqs_shape[1], freqs_shape[2], freqs_shape[3])
    return freqs.reshape(flat_shape)

distances = np.array(map(corr, flatten_freqs(freqs))).reshape(freqs.shape[:2])

np.save_compressed(correlation_file, corr=distances)<commit_msg>Change how/where to save the file<commit_after>from GamTools import corr
import numpy as np
import argparse

parser = argparse.ArgumentParser(description='Calculate coverage over different window sizes for a list of bam files.')
parser.add_argument('npz_frequencies_file', help='An npz file containing co-segregation frequencies to convert to correlations')

args = parser.parse_args()

correlation_file = args.npz_frequencies_file.split('.')
correlation_file[correlation_file.index('chrom')] = "corr"
correlation_file = '.'.join(correlation_file)

freqs = np.load(args.npz_frequencies_file)['freqs']

def flatten_freqs(freqs):
        
    freqs_shape = freqs.shape
    flat_shape = ( freqs_shape[0] * freqs_shape[1], freqs_shape[2], freqs_shape[3])
    return freqs.reshape(flat_shape)

distances = np.array(map(corr, flatten_freqs(freqs))).reshape(freqs.shape[:2])

np.savez_compressed(correlation_file, corr=distances)
{'fraction_non_alphanumeric': 0.1101742551995503, 'fraction_numerical': 0.006183249016301293, 'mean_word_length': 6.447698744769874, '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': '3468106', 'n_tokens_mistral': 618, 'n_tokens_neox': 584, 'n_words': 123}