<commit_before>package uk.ac.ebi.biosamples.service;

import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import uk.ac.ebi.biosamples.model.ExternalReference;

import java.util.Optional;

public class ExternalReferenceUtils {
    private ExternalReferenceUtils() {
        //private
    }

    public static final String ENA_BASE_URL_FRAGMENT = "www.ebi.ac.uk/ena";
    public static final String ARRAYEXPRESS_BASE_URL_FRAGMENT = "www.ebi.ac.uk/arrayexpress";
    public static final String HPSCREG_URL_FRAGMENT = "hpscreg.eu/";
    public static final String DBGAP_BASE_URL_FRAGMENT = "ncbi.nlm.nih.gov/projects/gap";
    public static final String EGA_DATASET_BASE_URL_FRAGMENT = "ega-archive.org/datasets";
    public static final String EGA_SAMPLE_BASE_URL_FRAGMENT = "ega-archive.org/metadata";
    public static final String EGA_STUDY_BASE_URL_FRAGMENT = "ega-archive.org/metadata";
    public static final String BIOSTUDIES_BASE_URL_FRAGMENT = "ebi.ac.uk/biostudies";
    public static final String DUO_BASE_URL = "http://purl.obolibrary.org/obo/";

    public static String getNickname(ExternalReference externalReference) {
        if (externalReference.getUrl().contains(ENA_BASE_URL_FRAGMENT)) {
            return "ENA";
        } else if (externalReference.getUrl().contains(ARRAYEXPRESS_BASE_URL_FRAGMENT)) {
            return "ArrayExpress";
        } else if (externalReference.getUrl().contains(HPSCREG_URL_FRAGMENT)) {
            return "hPSCreg";
        } else if (externalReference.getUrl().contains(DBGAP_BASE_URL_FRAGMENT)) {
            return "dbGaP";
        } else if (externalReference.getUrl().contains(EGA_DATASET_BASE_URL_FRAGMENT)) {
            return "EGA Dataset";
        } else if (externalReference.getUrl().contains(EGA_SAMPLE_BASE_URL_FRAGMENT)) {
            return "EGA Sample";
        } else if (externalReference.getUrl().contains(EGA_STUDY_BASE_URL_FRAGMENT)) {
            return "EGA Study";
        } else if (externalReference.getUrl().contains(BIOSTUDIES_BASE_URL_FRAGMENT)) {
            return "BioStudies";
        } else {
            return "other";
        }
    }

    public static Optional<String> getDataId(ExternalReference externalReference) {<commit_msg>Add feature to EGA study ID<commit_after>package uk.ac.ebi.biosamples.service;

import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import uk.ac.ebi.biosamples.model.ExternalReference;

import java.util.Optional;

public class ExternalReferenceUtils {
    private ExternalReferenceUtils() {
        //private
    }

    public static final String ENA_BASE_URL_FRAGMENT = "www.ebi.ac.uk/ena";
    public static final String ARRAYEXPRESS_BASE_URL_FRAGMENT = "www.ebi.ac.uk/arrayexpress";
    public static final String HPSCREG_URL_FRAGMENT = "hpscreg.eu/";
    public static final String DBGAP_BASE_URL_FRAGMENT = "ncbi.nlm.nih.gov/projects/gap";
    public static final String EGA_DATASET_BASE_URL_FRAGMENT = "ega-archive.org/datasets";
    public static final String EGA_SAMPLE_BASE_URL_FRAGMENT = "ega-archive.org/metadata";
    public static final String EGA_STUDY_BASE_URL_FRAGMENT = "ega-archive.org/studies";
    public static final String BIOSTUDIES_BASE_URL_FRAGMENT = "ebi.ac.uk/biostudies";
    public static final String DUO_BASE_URL = "http://purl.obolibrary.org/obo/";

    public static String getNickname(ExternalReference externalReference) {
        if (externalReference.getUrl().contains(ENA_BASE_URL_FRAGMENT)) {
            return "ENA";
        } else if (externalReference.getUrl().contains(ARRAYEXPRESS_BASE_URL_FRAGMENT)) {
            return "ArrayExpress";
        } else if (externalReference.getUrl().contains(HPSCREG_URL_FRAGMENT)) {
            return "hPSCreg";
        } else if (externalReference.getUrl().contains(DBGAP_BASE_URL_FRAGMENT)) {
            return "dbGaP";
        } else if (externalReference.getUrl().contains(EGA_DATASET_BASE_URL_FRAGMENT)) {
            return "EGA Dataset";
        } else if (externalReference.getUrl().contains(EGA_SAMPLE_BASE_URL_FRAGMENT)) {
            return "EGA Sample";
        } else if (externalReference.getUrl().contains(EGA_STUDY_BASE_URL_FRAGMENT)) {
            return "EGA Study";
        } else if (externalReference.getUrl().contains(BIOSTUDIES_BASE_URL_FRAGMENT)) {
            return "BioStudies";
        } else {
            return "other";
        }
    }

    public static Optional<String> getDataId(ExternalReference externalReference) {
{'fraction_non_alphanumeric': 0.09721918108167286, 'fraction_numerical': 0.0, 'mean_word_length': 3.680327868852459, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2657355', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1405, 'n_words': 255}