<commit_before>package XrefParser::DBASSParser;

use strict;

use base qw( XrefParser::BaseParser);

# This parser will read direct xrefs from a simple comma-delimited file downloaded from the DBASS database.
# The columns of the file should be the following:
#
# 1)    DBASS Gene ID
# 2)    DBASS Gene Name
# 3)    Ensembl Gene ID


sub new {
    my $proto = shift;

    my $class = ref $proto || $proto;
    my $self = bless {}, $class;

    return $self;
}

sub run {
    my $self = shift;

    my ( $source_id, $species_id, $filename ) = @_;

    my $file_io = $self->get_filehandle($filename);
    if ( !defined($file_io) ) {
        return 1;
    }

    my $parsed_count = 0;

    printf( STDERR "source = %d\t species = %d\n",
            $source_id, $species_id );

    $file_io->getline();
    
    while ( defined( my $line = $file_io->getline() ) ) {
 
	$line =~ s/\s*$//;
		

        my ( $dbass_gene_id, $dbass_gene_name, $ensembl_id) = split( /,/, $line );

        if ( !defined($dbass_gene_id) || !defined($ensembl_id) ) {
            printf( "Line %d contains  has less than two columns.\n",
                    1 + $parsed_count );
            print ("The parsing failed\n");
            return 1;
        }
	
        my $label       = $dbass_gene_name;
	my $type        = 'gene';
        my $description = '';
        my $version     = '1';

        ++$parsed_count;

        my $xref_id = XrefParser::BaseParser->get_xref( $dbass_gene_id, $source_id );

        if ( !defined($xref_id) || $xref_id eq '' ) {
            $xref_id = XrefParser::BaseParser->add_xref($dbass_gene_id, $version, $label, $description, $source_id, $species_id);
        }
	
	
	XrefParser::BaseParser->add_direct_xref( $xref_id, $ensembl_id, $type, $dbass_gene_id);
	
    } ## end while ( defined( my $line...

    printf( "%d direct xrefs succesfully parsed\n", $parsed_count );

    $file_io->close();

    print "Done\n";

    return 0;
} ## end sub run

1;
<commit_msg>Update to add synonyms and remove data from the linkage_xref column<commit_after>package XrefParser::DBASSParser;

use strict;

use base qw( XrefParser::BaseParser);
use DBI;
use Carp;

# This parser will read direct xrefs from a simple comma-delimited file downloaded from the DBASS database.
# The columns of the file should be the following:
#
# 1)    DBASS Gene ID
# 2)    DBASS Gene Name
# 3)    Ensembl Gene ID


my $dbi;
my $xref_id;
my $source_id;

sub new {
    my $proto = shift;

    my $class = ref $proto || $proto;
    my $self = bless {}, $class;

    return $self;
}


sub run {
    my $self = shift;

    my ( $source_id, $species_id, $filename ) = @_;

    my $file_io = $self->get_filehandle($filename);
    if ( !defined($file_io) ) {
        return 1;
    }

    my $parsed_count = 0;

    printf( STDERR "source = %d\t species = %d\n",
            $source_id, $species_id );

    $file_io->getline();
    
    while ( defined( my $line = $file_io->getline() ) ) {
 
	$line =~ s/\s*$//;
		

        my ( $dbass_gene_id, $dbass_gene_name, $ensembl_id) = split( /,/, $line );

        if ( !defined($dbass_gene_id) || !defined($ensembl_id) ) {
            printf( "Line %d contains  has less than two columns.\n",
                    1 + $parsed_count );
            print ("The parsing failed\n");
            return 1;
        }
	
	
	my $first_gene_name;
	my $second_gene_name;
	
	
	if ($dbass_gene_name =~ /.\/./){
		($first_gene_name, $second_gene_name) = split( /\//, $dbass_gene_name );
	}
	
	if ($dbass_gene_name =~ /(.*)\((.*)\)/){
		$first_gene_name = $1;
	 	$second_gene_name = $2;
		print $first_gene_name, "\n", $second_gene_name, "\n";
	}
       
       
       
        my $label       = $first_gene_name;
	my $type        = 'gene';
        my $description = '';
        my $version     = '1';
	my $synonym	= $second_gene_name;

        ++$parsed_count;

        my $xref_id = XrefParser::BaseParser->get_xref( $dbass_gene_id, $source_id );

        if ( !defined($xref_id) || $xref_id eq '' ) {
            $xref_id = XrefParser::BaseParser->add_xref($dbass_gene_id, $version, $label, $description, $source_id, $species_id);
        }
	
	XrefParser::BaseParser->add_direct_xref( $xref_id, $ensembl_id, $type, '');
	
	if (defined ($synonym)) {
		XrefParser::DBASSParser->add_synonym($xref_id, $synonym);
	}
	elsif ($synonym =~ /^\s/){
		print "There is white space! \n";	
	}
	else {
		next;
	}
	
	
    } ## end while ( defined( my $line...

    printf( "%d direct xrefs succesfully parsed\n", $parsed_count );

    $file_io->close();

    print "Done\n";

    return 0;
} ## end sub run


1;

{'fraction_non_alphanumeric': 0.15109949923797084, 'fraction_numerical': 0.004789897670367951, 'mean_word_length': 2.4750378214826023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '4377520', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1650, 'n_words': 411}