<commit_before>// BridgeDb,
// An abstraction layer for identifier mapping services, both local and online.
//
// Copyright      2012  <NAME>
// Copyright      2012  OpenPhacts
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package org.bridgedb.uri.loader.transative;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.bridgedb.uri.lens.Lens;
import org.bridgedb.uri.loader.transative.constant.ChemInf;
import org.bridgedb.uri.loader.transative.constant.OboConstants;
import org.bridgedb.utils.BridgeDBException;

/**
 *
 * @author Christian
 */
public class JustificationMaker {

    public static Set<String> PARENT_CHILD = new HashSet<String>(Arrays.asList(
            ChemInf.hasStereoundefinedParent, 
            ChemInf.hasOPSNormalizedCounterpart, 
            ChemInf.hasIsotopicallyUnspecifiedParent,
            ChemInf.hasUnchargedCounterpart,
            ChemInf.hasComponentWithUnchargedCounterpart,
            ChemInf.hasMajorTautomerAtpH7point4,
            OboConstants.HAS_PART,
            OboConstants.IS_TAUTOMER_OF,
            OboConstants.HAS_FUNCTIONAL_PARENT
            ));

    private static final String CW_GENE_HACK = "http://example.com/ConceptWikiGene";
    private static final String CW_PROTEIN_HACK = "http://example.com/ConceptWikiProtein";
    private static final String ENEMBL_BASED_PROTIEN_GENE_HACK = "http://example.com/EnsemblBasedProteinGene";

    public static Set<String> CROSS_TYPE = new HashSet<String>(Arrays.asList(
            ChemInf.PROTEIN_CODING_GENE,
            ChemInf.FUNCTIONAL_RNA_CODING_GENE,
            ENEMBL_BASED_PROTIEN_GENE_HACK
            ));
    
   public static String combine(String left, String right) throws BridgeDBException{
        String result = possibleCombine(left, right);
        if (result != null){
            return result;
        }
        throw new BridgeDBException("unable to combine " + left + " with " + right);
    }
    
    public static String possibleCombine(String left, String right) {
        if (left.equals(right)){
             if (CROSS_TYPE.contains(left)){
                 return null; //We don't want to tranitive with two cross type even if they are the same.
             }
             return left;
        } else if (left.equals(ChemInf.CHEMICAL_ENTITY)) {
            if (right.equals(ChemInf.INCHI_KEY)) {
                return ChemInf.CHEMICAL_ENTITY;
            } else if (PARENT_CHILD.contains(right)){
                return right;
            } else {
                return null;
            }
        } else if (left.equals(ChemInf.FUNCTIONAL_RNA_CODING_GENE)) {
            if (right.equals(ChemInf.PROTEIN)) {
                return ChemInf.FUNCTIONAL_RNA_CODING_GENE;
            } else if (right.equals(ChemInf.GENE)) {
                return ChemInf.FUNCTIONAL_RNA_CODING_GENE;
            } else {<commit_msg>Added Database cross reference to do not do transitive list<commit_after>// BridgeDb,
// An abstraction layer for identifier mapping services, both local and online.
//
// Copyright      2012  <NAME>
// Copyright      2012  OpenPhacts
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package org.bridgedb.uri.loader.transative;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.bridgedb.uri.lens.Lens;
import org.bridgedb.uri.loader.transative.constant.ChemInf;
import org.bridgedb.uri.loader.transative.constant.OboConstants;
import org.bridgedb.utils.BridgeDBException;

/**
 *
 * @author Christian
 */
public class JustificationMaker {

    public static Set<String> PARENT_CHILD = new HashSet<String>(Arrays.asList(
            ChemInf.hasStereoundefinedParent, 
            ChemInf.hasOPSNormalizedCounterpart, 
            ChemInf.hasIsotopicallyUnspecifiedParent,
            ChemInf.hasUnchargedCounterpart,
            ChemInf.hasComponentWithUnchargedCounterpart,
            ChemInf.hasMajorTautomerAtpH7point4,
            OboConstants.HAS_PART,
            OboConstants.IS_TAUTOMER_OF,
            OboConstants.HAS_FUNCTIONAL_PARENT
            ));

    private static final String CW_GENE_HACK = "http://example.com/ConceptWikiGene";
    private static final String CW_PROTEIN_HACK = "http://example.com/ConceptWikiProtein";
    private static final String ENEMBL_BASED_PROTIEN_GENE_HACK = "http://example.com/EnsemblBasedProteinGene";

    public static Set<String> CROSS_TYPE = new HashSet<String>(Arrays.asList(
            ChemInf.PROTEIN_CODING_GENE,
            ChemInf.FUNCTIONAL_RNA_CODING_GENE,
            ENEMBL_BASED_PROTIEN_GENE_HACK,
            ChemInf.DATABASE_CROSS_REFERENCE
            ));
    
   public static String combine(String left, String right) throws BridgeDBException{
        String result = possibleCombine(left, right);
        if (result != null){
            return result;
        }
        throw new BridgeDBException("unable to combine " + left + " with " + right);
    }
    
    public static String possibleCombine(String left, String right) {
        if (left.equals(right)){
             if (CROSS_TYPE.contains(left)){
                 return null; //We don't want to tranitive with two cross type even if they are the same.
             }
             return left;
        } else if (left.equals(ChemInf.CHEMICAL_ENTITY)) {
            if (right.equals(ChemInf.INCHI_KEY)) {
                return ChemInf.CHEMICAL_ENTITY;
            } else if (PARENT_CHILD.contains(right)){
                return right;
            } else {
                return null;
            }
        } else if (left.equals(ChemInf.FUNCTIONAL_RNA_CODING_GENE)) {
            if (right.equals(ChemInf.PROTEIN)) {
                return ChemInf.FUNCTIONAL_RNA_CODING_GENE;
            } else if (right.equals(ChemInf.GENE)) {
                return ChemInf.FUNCTIONAL_RNA_CODING_GENE;
            } else {
{'fraction_non_alphanumeric': 0.08524876345650276, 'fraction_numerical': 0.004073319755600814, 'mean_word_length': 2.6070304302203566, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4744549', 'n_tokens_mistral': 2048, 'n_tokens_neox': 1936, 'n_words': 498}