<commit_before>import java.sql.*;
import java.sql.DriverManager;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;

import org.ensembl.compara.datamodel.GenomeDB;
import org.ensembl.compara.driver.ComparaDriver;

import org.ensembl.datamodel.*;
import org.ensembl.registry.*;
import org.ensembl.driver.*;
import org.ensembl.variation.driver.*;

public class Ensembl2Visio {
	final static String[] sysCodes = new String[] {
			"U", "X", "Em", "En", "L", "F", "T",
			"H", "I", "M", "Om", "Pd", "Pf",
			"Q", "R", "D", "S", "W",
			"Z"
	};
	
	final static String[] sysNames = new String[] {
		"UniProt/TrEMBL", "Affymetrix Probe Set ID", "EMBL", "Ensembl", "Entrez Gene", 
		"FlyBase", "Gene Ontology", "HUGO", "InterPro", "MGI", 
		"OMIM", "PDB", "Pfam", "RefSeq", "RGD", "SGD", 
		"UniGene", "WormBase", "ZFIN"
	};
	
	final static String[] lookFor = new String[] {
			"(?i)uniprot","(?i)affy", "\\bEMBL\\b", "Ensembl", "EntrezGene", "FlyBase", "GO",
			"HUGO", "InterPro", "MGI", "OMIM", "PDB", "Pfam", 
			"RefSeq", "RGD", "SGD", "UniGene", "WormBase",
			"ZFIN"
	};
	final static int ENS_CODE = 2;
	
	Vector patterns;
    
    Connection con;
    
    public static void main(String[] args) {
//    	int nrGenes = 10;
//    	String organism = "human";
    	String file = "ensembl_genes.txt";
    	String dbname = "ensembl_homo_sapiens_38_36";
    	Ensembl2Visio ensj = new Ensembl2Visio();
//    	ensj.fetchFromEnsembl(nrGenes, organism, file); // Do this with perl
    	ensj.createGdbFromTxt(file, dbname);
    }
    
    public Ensembl2Visio() {}

    public void compilePatterns()
    {
    	patterns = new Vector();
    	for(int i = 0; i < lookFor.length; i++)
    	{
    		patterns.add(Pattern.compile(lookFor[i]));		
    	}
    }
    
    public void createGdbFromTxt(String file, String dbname)
    {
    	PrintWriter eout = null;
	    try {
	        eout = new PrintWriter(new FileWriter("error.txt"));
	    } catch(IOException ex) {
	        ex.printStackTrace();
	    }
	    
	    compilePatterns();
	    
    	connectDerby(dbname);
		createTables();
    	try
    	{
    		con.setAutoCommit(false);<commit_msg>- fixed bug in Ensembl2Visio.java: ensembl ids had EMBL systemcode in link table<commit_after>import java.sql.*;
import java.sql.DriverManager;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;

import org.ensembl.compara.datamodel.GenomeDB;
import org.ensembl.compara.driver.ComparaDriver;

import org.ensembl.datamodel.*;
import org.ensembl.registry.*;
import org.ensembl.driver.*;
import org.ensembl.variation.driver.*;

public class Ensembl2Visio {
	final static String[] sysCodes = new String[] {
			"U", "X", "Em", "En", "L", "F", "T",
			"H", "I", "M", "Om", "Pd", "Pf",
			"Q", "R", "D", "S", "W",
			"Z"
	};
	
	final static String[] sysNames = new String[] {
		"UniProt/TrEMBL", "Affymetrix Probe Set ID", "EMBL", "Ensembl", "Entrez Gene", 
		"FlyBase", "Gene Ontology", "HUGO", "InterPro", "MGI", 
		"OMIM", "PDB", "Pfam", "RefSeq", "RGD", "SGD", 
		"UniGene", "WormBase", "ZFIN"
	};
	
	final static String[] lookFor = new String[] {
			"(?i)uniprot","(?i)affy", "\\bEMBL\\b", "Ensembl", "EntrezGene", "FlyBase", "GO",
			"HUGO", "InterPro", "MGI", "OMIM", "PDB", "Pfam", 
			"RefSeq", "RGD", "SGD", "UniGene", "WormBase",
			"ZFIN"
	};
	final static int ENS_CODE = 3;
	
	Vector patterns;
    
    Connection con;
    
    public static void main(String[] args) {
//    	int nrGenes = 10;
//    	String organism = "human";
    	String file = "ensembl_genes.txt";
//    	String file = "test.txt";
    	String dbname = "ensembl_homo_sapiens_38_36";
//    	String dbname = "test";
    	Ensembl2Visio ensj = new Ensembl2Visio();
//    	ensj.fetchFromEnsembl(nrGenes, organism, file); // Do this with perl
    	ensj.createGdbFromTxt(file, dbname);
    }
    
    public Ensembl2Visio() {}

    public void compilePatterns()
    {
    	patterns = new Vector();
    	for(int i = 0; i < lookFor.length; i++)
    	{
    		patterns.add(Pattern.compile(lookFor[i]));		
    	}
    }
    
    public void createGdbFromTxt(String file, String dbname)
    {
    	PrintWriter eout = null;
	    try {
	        eout = new PrintWriter(new FileWriter("error.txt"));
	    } catch(IOException ex) {
	        ex.printStackTrace();
	    }
	    
	    compilePatterns();
	    
    	connect(dbname);
		createTables();
    	try
    	{
    		con.setAutoCommit(false);
{'fraction_non_alphanumeric': 0.17344658024139473, 'fraction_numerical': 0.005587840858292356, 'mean_word_length': 3.120626151012891, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5979537', 'n_tokens_mistral': 1815, 'n_tokens_neox': 1678, 'n_words': 381}