Skip to content
Snippets Groups Projects
Commit af366c4f authored by Glenn Proctor's avatar Glenn Proctor
Browse files

SwissProt records with multiple accessions now create appropriate records in...

SwissProt records with multiple accessions now create appropriate records in the xref and synonym tables
parent 4559290a
No related branches found
No related tags found
No related merge requests found
......@@ -58,17 +58,31 @@ sub upload_xrefs {
$xref->{SPECIES_ID}) || die $dbi->errstr;
# get ID of xref just inserted
my $id = $sth->{'mysql_insertid'};
my $xref_id = $sth->{'mysql_insertid'};
# create entry in primary_xref table with sequence
# TODO experimental/predicted????
$sth = $dbi->prepare("INSERT INTO primary_xref VALUES(?,?,?,?,?)");
$sth->execute($id,
$sth->execute($xref_id,
$xref->{SEQUENCE},
'peptide',
'experimental',
$xref->{SOURCE_ID}) || die $dbi->errstr;
# if there are synonyms, create xrefs for them and entries in the synonym table
my $xref_sth = $dbi->prepare("INSERT INTO xref (accession,label,source_id,species_id) VALUES(?,?,?,?)");
my $syn_sth = $dbi->prepare("INSERT INTO synonym VALUES(?,?,?)");
foreach my $syn (@{$xref->{SYNONYMS}}) {
$xref_sth->execute($syn,
$xref->{LABEL},
$xref->{SOURCE_ID},
$xref->{SPECIES_ID}) || die $dbi->errstr;
my $syn_xref_id = $xref_sth->{'mysql_insertid'};
$syn_sth->execute($xref_id, $syn_xref_id, $xref->{SOURCE_ID} ) || die $dbi->errstr;
}
}
$sth->finish() if defined $sth;
......
......@@ -107,11 +107,20 @@ sub create_xrefs {
while (<SWISSPROT>) {
my $xref;
($xref->{ACCESSION}) =$_ =~ /AC\s+(\w+);/; # note only takes first accession if > 1
my $acc;
($acc) =$_ =~ /AC\s+(.+);/; # may catch multiple ; separated accessions
($xref->{LABEL}) = $_ =~ /ID\s+(\w+)/;
($xref->{SPECIES_ID}) = $species_id;
($xref->{SOURCE_ID}) = $source_id;
# set accession (and synonyms if more than one)
# note synonyms
my @acc = split /;/, $acc;
$xref->{ACCESSION} = $acc[0];
for (my $a=1; $a <= $#acc; $a++) {
push(@{$xref->{"SYNONYMS"} }, $acc[$a]);
}
# extract sequence
my ($seq) = $_ =~ /SQ\s+(.+)/s; # /s allows . to match newline
my @seq_lines = split /\n/, $seq;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment