<commit_before>from dipper.sources.Source import Source
from dipper.sources.Ensembl import Ensembl
from dipper.models.Dataset import Dataset
import logging
import gzip
import pandas as pd

logger = logging.getLogger(__name__)


class StringDB(Source):
    """
    STRING is a database of known and predicted protein-protein interactions.
    The interactions include direct (physical) and indirect
    (functional) associations; they stem from computational prediction,
    from knowledge transfer between organisms, and from interactions
    aggregated from other (primary) databases.
    From: http://string-db.org/cgi/about.pl?footer_active_subpage=content

    STRING uses one protein per gene. If there is more than one isoform
    per gene, we usually select the longest isoform, unless we have
    information that suggest that other isoform regarded as
    cannonical (e.g., proteins in the CCDS database).
    From: http://string-db.org/cgi/help.pl
    """
    STRING_BASE = "http://string-db.org/download/"
    STRING_VERSION = "v10"
    DEFAULT_TAXA = [9606, 10090, 7955, 7227, 6239]

    files = {
        'protein_links': {
            'path': '{}protein.links.detailed.{}/'.format(STRING_BASE, STRING_VERSION),
            'pattern': 'protein.links.detailed.{}.txt.gz'.format(STRING_VERSION)
        }
    }

    def __init__(self, graph_type, are_bnodes_skolemized, tax_ids=None):
        super().__init__(graph_type, are_bnodes_skolemized, 'string')
        self.dataset = Dataset(
            'string', 'String', 'http://string-db.org/', None,
            'http://string-db.org/cgi/access.pl?footer_active_subpage=licensing')

        if tax_ids is None:
            self.tax_ids = StringDB.DEFAULT_TAXA
        else:
            logger.info("Filtering on taxa {}".format(tax_ids))
            self.tax_ids = tax_ids

    def fetch(self, is_dl_forced=False):
        """<commit_msg>up stringdb version<commit_after>from dipper.sources.Source import Source
from dipper.sources.Ensembl import Ensembl
from dipper.models.Dataset import Dataset
import logging
import gzip
import pandas as pd

logger = logging.getLogger(__name__)


class StringDB(Source):
    """
    STRING is a database of known and predicted protein-protein interactions.
    The interactions include direct (physical) and indirect
    (functional) associations; they stem from computational prediction,
    from knowledge transfer between organisms, and from interactions
    aggregated from other (primary) databases.
    From: http://string-db.org/cgi/about.pl?footer_active_subpage=content

    STRING uses one protein per gene. If there is more than one isoform
    per gene, we usually select the longest isoform, unless we have
    information that suggest that other isoform regarded as
    cannonical (e.g., proteins in the CCDS database).
    From: http://string-db.org/cgi/help.pl
    """
    STRING_BASE = "http://string-db.org/download/"
    STRING_VERSION = "v10.5"
    DEFAULT_TAXA = [9606, 10090, 7955, 7227, 6239]

    files = {
        'protein_links': {
            'path': '{}protein.links.detailed.{}/'.format(STRING_BASE, STRING_VERSION),
            'pattern': 'protein.links.detailed.{}.txt.gz'.format(STRING_VERSION)
        }
    }

    def __init__(self, graph_type, are_bnodes_skolemized, tax_ids=None):
        super().__init__(graph_type, are_bnodes_skolemized, 'string')
        self.dataset = Dataset(
            'string', 'String', 'http://string-db.org/', None,
            'http://string-db.org/cgi/access.pl?footer_active_subpage=licensing')

        if tax_ids is None:
            self.tax_ids = StringDB.DEFAULT_TAXA
        else:
            logger.info("Filtering on taxa {}".format(tax_ids))
            self.tax_ids = tax_ids

    def fetch(self, is_dl_forced=False):
        """
{'fraction_non_alphanumeric': 0.10378349973725697, 'fraction_numerical': 0.01234892275354703, 'mean_word_length': 3.1380434782608697, 'pattern_counts': {'":': 0, '<': 3, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5971340', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1097, 'n_words': 306}