<commit_before>package edu.psu.compbio.seqcode.projects.akshay.utils;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;

import edu.psu.compbio.seqcode.genome.GenomeConfig;
import edu.psu.compbio.seqcode.genome.location.Point;
import edu.psu.compbio.seqcode.genome.location.Region;
import edu.psu.compbio.seqcode.gse.gsebricks.verbs.sequence.SequenceGenerator;
import edu.psu.compbio.seqcode.gse.tools.utils.Args;
import edu.psu.compbio.seqcode.gse.utils.ArgParser;
import edu.psu.compbio.seqcode.gse.utils.io.RegionFileUtilities;
import edu.psu.compbio.seqcode.gse.utils.sequence.SequenceUtils;

public class KmerModelScanner {
	
	
	protected double[] kmerweights;
	protected List<Point> peaks;
	protected List<Region> regions;
	protected int k; // kmer length of the model
	protected int minM; // Minimum length to consider for motif finding
	protected int maxM; //Maximum length to consider for motif finding
	//protected int n; // Number of motifs to look at each 
	
	public KmerModelScanner() {
		
	}
	
	
	
	// Settors
	public void setKmerWeights(double[] w){kmerweights=w;}
	public void setPeaks(List<Point>ps){peaks=ps;}
	public void setRegions(List<Region>rs){regions=rs;}
	public void setK(int K){k=K;}
	public void setminM(int m){minM=m;}
	public void setmaxM(int m){maxM=m;}
	
	public void scanPeaks(boolean useCache, String genpath){
		@SuppressWarnings("rawtypes")
		SequenceGenerator seqgen = new SequenceGenerator();
		seqgen.useCache(useCache);
		if(useCache){
			seqgen.useLocalFiles(true);
			seqgen.setGenomePath(genpath);
		}
		
		for(Region r: regions){
			String seq = seqgen.execute(r);
			double maxScore = Double.MIN_VALUE;
			String bestMotif = "";
			for(int l=minM; l<=maxM; l++){
				for(int i=0; i<(seq.length()-l+1);i++){
					String motif = seq.substring(i, i+l);<commit_msg>Fixed few bugs in kmerModelScanner<commit_after>package edu.psu.compbio.seqcode.projects.akshay.utils;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;

import edu.psu.compbio.seqcode.genome.GenomeConfig;
import edu.psu.compbio.seqcode.genome.location.Point;
import edu.psu.compbio.seqcode.genome.location.Region;
import edu.psu.compbio.seqcode.gse.gsebricks.verbs.sequence.SequenceGenerator;
import edu.psu.compbio.seqcode.gse.tools.utils.Args;
import edu.psu.compbio.seqcode.gse.utils.ArgParser;
import edu.psu.compbio.seqcode.gse.utils.io.RegionFileUtilities;
import edu.psu.compbio.seqcode.gse.utils.sequence.SequenceUtils;

public class KmerModelScanner {
	
	
	protected double[] kmerweights;
	protected List<Point> peaks;
	protected List<Region> regions;
	protected int k; // kmer length of the model
	protected int minM; // Minimum length to consider for motif finding
	protected int maxM; //Maximum length to consider for motif finding
	//protected int n; // Number of motifs to look at each 
	
	public KmerModelScanner() {
		
	}
	
	
	
	// Settors
	public void setKmerWeights(double[] w){kmerweights=w;}
	public void setPeaks(List<Point>ps){peaks=ps;}
	public void setRegions(List<Region>rs){regions=rs;}
	public void setK(int K){k=K;}
	public void setminM(int m){minM=m;}
	public void setmaxM(int m){maxM=m;}
	
	public void scanPeaks(boolean useCache, String genpath){
		@SuppressWarnings("rawtypes")
		SequenceGenerator seqgen = new SequenceGenerator();
		seqgen.useCache(useCache);
		if(useCache){
			seqgen.useLocalFiles(true);
			seqgen.setGenomePath(genpath);
		}
		
		for(Region r: regions){
			String seq = seqgen.execute(r).toUpperCase();
			double maxScore = Double.MIN_VALUE;
			String bestMotif = "";
			for(int l=minM; l<=maxM; l++){
				for(int i=0; i<(seq.length()-l+1);i++){
					String motif = seq.substring(i, i+l);
{'fraction_non_alphanumeric': 0.12390554523746351, 'fraction_numerical': 0.0010612894667020429, 'mean_word_length': 4.890625, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, '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': '534685', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1312, 'n_words': 279}