Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
6d512df9
Commit
6d512df9
authored
20 years ago
by
Glenn Proctor
Browse files
Options
Downloads
Patches
Plain Diff
Superclass for parsers containing common functionality
parent
b53f121b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc-scripts/xref_mapping/BaseParser.pm
+92
-0
92 additions, 0 deletions
misc-scripts/xref_mapping/BaseParser.pm
with
92 additions
and
0 deletions
misc-scripts/xref_mapping/BaseParser.pm
0 → 100644
+
92
−
0
View file @
6d512df9
package
BaseParser
;
my
$host
=
"
ecs1g
";
my
$port
=
3306
;
my
$database
=
"
glenn_test_xref
";
my
$user
=
"
ensadmin
";
my
$password
=
"
ensembl
";
my
$dbi
=
DBI
->
connect
("
dbi:mysql:host=
$host
;port=
$port
;database=
$database
",
"
$user
",
"
$password
",
{'
RaiseError
'
=>
1
})
||
die
"
Can't connect to database
";
# --------------------------------------------------------------------------------
# Upload a source object to the source table.
# Return the ID of the new row in the database.
sub
upload_source
{
my
(
$self
,
$source
)
=
@_
;
my
$sth
=
$dbi
->
prepare
("
INSERT INTO source (name,url,file_modified_date,upload_date,release) VALUES(?,?,?, NOW(),?)
");
$sth
->
execute
(
$source
->
{
NAME
},
$source
->
{
URL
},
$source
->
{
FILE_MODIFIED_DATE
},
"")
||
die
$dbi
->
errstr
;
$sth
=
$dbi
->
prepare
("
SELECT last_insert_id()
");
$sth
->
execute
();
my
$id
;
while
(
my
@row
=
$sth
->
fetchrow_array
())
{
$id
=
$row
[
0
];
}
$sth
->
finish
()
if
defined
$sth
;
return
$id
;
}
# --------------------------------------------------------------------------------
# Upload xrefs to the database
sub
upload_xrefs
{
my
(
$self
,
@xrefs
)
=
@_
;
my
$sth
;
foreach
my
$xref
(
@xrefs
)
{
# Create entry in xref table and note ID
$sth
=
$dbi
->
prepare
("
INSERT INTO xref (accession,label,source_id,species_id) VALUES(?,?,?,?)
");
$sth
->
execute
(
$xref
->
{
ACCESSION
},
$xref
->
{
LABEL
},
$xref
->
{
SOURCE_ID
},
$xref
->
{
SPECIES_ID
})
||
die
$dbi
->
errstr
;
# get ID of xref just inserted
$sth
=
$dbi
->
prepare
("
SELECT last_insert_id()
");
$sth
->
execute
();
my
$id
;
while
(
my
@row
=
$sth
->
fetchrow_array
())
{
$id
=
$row
[
0
];
}
# create entry in primary_xref table with sequence
# TODO experimental/predicted????
$sth
=
$dbi
->
prepare
("
INSERT INTO primary_xref VALUES(?,?,?,?,?)
");
$sth
->
execute
(
$id
,
$xref
->
{
SEQUENCE
},
'
peptide
',
'
experimental
',
$xref
->
{
SOURCE_ID
})
||
die
$dbi
->
errstr
;
}
$sth
->
finish
()
if
defined
$sth
;
}
# --------------------------------------------------------------------------------
sub
dbi
{
my
$self
=
shift
;
return
$dbi
;
}
# --------------------------------------------------------------------------------
1
;
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment