<commit_before>package org.phenoscape.bridge;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.log4j.Logger;
import org.bbop.dataadapter.DataAdapterException;
import org.obd.model.CompositionalDescription;
import org.obd.model.Graph;
import org.obd.model.LinkStatement;
import org.obd.model.Node;
import org.obd.model.Node.Metatype;
import org.obd.query.Shard;
import org.obd.query.impl.OBDSQLShard;
import org.obo.dataadapter.OBOAdapter;
import org.obo.dataadapter.OBOFileAdapter;
import org.obo.datamodel.Dbxref;
import org.obo.datamodel.IdentifiedObject;
import org.obo.datamodel.Namespace;
import org.obo.datamodel.OBOClass;
import org.obo.datamodel.OBOSession;
import org.obo.datamodel.Type;
import org.purl.obo.vocab.RelationVocabulary;

public class ZfinObdBridge {

    /** The db-host system property should contain the name of the database server. */
    public static final String DB_HOST = "db-host";
    /** The db-name system property should contain the name of the database. */
    public static final String DB_NAME = "db-name";
    /** The db-user system property should contain the database username. */
    public static final String DB_USER = "db-user";
    /** The db-password system property should contain the database password. */
    public static final String DB_PASSWORD = "<PASSWORD>";
    /** The ontology-dir system property should contain the path to a folder with ontologies to be loaded. */
    public static final String ONTOLOGY_DIR = "ontology-dir";
    /** The phenotype-url system property should contain the URL of the ZFIN phenotypes file. */
    public static final String PHENOTYPE_URL = "phenotype-url";
    /** The missing-markers-url system property should contain the URL of the ZFIN missing markers file. */
    public static final String MISSING_MARKERS_URL = "missing-markers-url";
    /** The genotype-url system property should contain the URL of the ZFIN genotypes file. */
    public static final String GENOTYPE_URL = "genotype-url";

    public static String GENOTYPE_PHENOTYPE_REL_ID = "PHENOSCAPE:exhibits";
    public static String GENE_GENOTYPE_REL_ID = "PHENOSCAPE:has_allele";
    public static String PUBLICATION_TYPE_ID = "cdao:Pub";
    public static String HAS_PUB_REL_ID = "cdao:hasPub";
    public static String GENOTYPE_TYPE_ID = "SO:0001027";
    public static String GENE_TYPE_ID = "SO:0000704";
    private String TELEOST_ANATOMY = "teleost_anatomy";
    private static RelationVocabulary relationVocabulary = new RelationVocabulary();

    private Shard shard;
    private Graph graph;
    private OBOSession oboSession;
    
    public ZfinObdBridge() throws SQLException, ClassNotFoundException {
        super();
        this.shard = this.initializeShard();
        this.graph = new Graph();
        this.setOboSession(this.loadOBOSession());
    }

    public OBOSession getOboSession() {
        return oboSession;
    }

    public void setOboSession(OBOSession oboSession) {
        this.oboSession = oboSession;
    }

    public void loadZfinData() throws MalformedURLException, IOException {
        String phenoFileLine, genoFileLine, missingMarkersFileLine;
        LinkStatement geneAnnotLink;

        URL phenotypeURL = new URL(System.getProperty(PHENOTYPE_URL));
        URL missingMarkersURL = new URL(System.getProperty(MISSING_MARKERS_URL));
        URL genotypeURL = new URL(System.getProperty(GENOTYPE_URL));

        BufferedReader br1 = new BufferedReader(new InputStreamReader(phenotypeURL.openStream()));
        while ((phenoFileLine = br1.readLine()) != null) {
            String[] pComps = phenoFileLine.split("\\t");<commit_msg>Added final to some constants.<commit_after>package org.phenoscape.bridge;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.log4j.Logger;
import org.bbop.dataadapter.DataAdapterException;
import org.obd.model.CompositionalDescription;
import org.obd.model.Graph;
import org.obd.model.LinkStatement;
import org.obd.model.Node;
import org.obd.model.Node.Metatype;
import org.obd.query.Shard;
import org.obd.query.impl.OBDSQLShard;
import org.obo.dataadapter.OBOAdapter;
import org.obo.dataadapter.OBOFileAdapter;
import org.obo.datamodel.Dbxref;
import org.obo.datamodel.IdentifiedObject;
import org.obo.datamodel.Namespace;
import org.obo.datamodel.OBOClass;
import org.obo.datamodel.OBOSession;
import org.obo.datamodel.Type;
import org.purl.obo.vocab.RelationVocabulary;

public class ZfinObdBridge {

    /** The db-host system property should contain the name of the database server. */
    public static final String DB_HOST = "db-host";
    /** The db-name system property should contain the name of the database. */
    public static final String DB_NAME = "db-name";
    /** The db-user system property should contain the database username. */
    public static final String DB_USER = "db-user";
    /** The db-password system property should contain the database password. */
    public static final String DB_PASSWORD = "<PASSWORD>";
    /** The ontology-dir system property should contain the path to a folder with ontologies to be loaded. */
    public static final String ONTOLOGY_DIR = "ontology-dir";
    /** The phenotype-url system property should contain the URL of the ZFIN phenotypes file. */
    public static final String PHENOTYPE_URL = "phenotype-url";
    /** The missing-markers-url system property should contain the URL of the ZFIN missing markers file. */
    public static final String MISSING_MARKERS_URL = "missing-markers-url";
    /** The genotype-url system property should contain the URL of the ZFIN genotypes file. */
    public static final String GENOTYPE_URL = "genotype-url";

    public static final String GENOTYPE_PHENOTYPE_REL_ID = "PHENOSCAPE:exhibits";
    public static final String GENE_GENOTYPE_REL_ID = "PHENOSCAPE:has_allele";
    public static final String PUBLICATION_TYPE_ID = "cdao:Pub";
    public static final String HAS_PUB_REL_ID = "cdao:hasPub";
    public static final String GENOTYPE_TYPE_ID = "SO:0001027";
    public static final String GENE_TYPE_ID = "SO:0000704";
    private static final String TELEOST_ANATOMY = "teleost_anatomy";
    private static final RelationVocabulary relationVocabulary = new RelationVocabulary();

    private Shard shard;
    private Graph graph;
    private OBOSession oboSession;
    
    public ZfinObdBridge() throws SQLException, ClassNotFoundException {
        super();
        this.shard = this.initializeShard();
        this.graph = new Graph();
        this.setOboSession(this.loadOBOSession());
    }

    public OBOSession getOboSession() {
        return oboSession;
    }

    public void setOboSession(OBOSession oboSession) {
        this.oboSession = oboSession;
    }

    public void loadZfinData() throws MalformedURLException, IOException {
        String phenoFileLine, genoFileLine, missingMarkersFileLine;
        LinkStatement geneAnnotLink;

        URL phenotypeURL = new URL(System.getProperty(PHENOTYPE_URL));
        URL missingMarkersURL = new URL(System.getProperty(MISSING_MARKERS_URL));
        URL genotypeURL = new URL(System.getProperty(GENOTYPE_URL));

        BufferedReader br1 = new BufferedReader(new InputStreamReader(phenotypeURL.openStream()));
        while ((phenoFileLine = br1.readLine()) != null) {
            String[] pComps = phenoFileLine.split("\\t");
{'fraction_non_alphanumeric': 0.08972081218274111, 'fraction_numerical': 0.004314720812182741, 'mean_word_length': 4.068167202572347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1205750', 'n_tokens_mistral': 2426, 'n_tokens_neox': 2325, 'n_words': 644}