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
ea6c2f37
Commit
ea6c2f37
authored
20 years ago
by
Arne Stabenau
Browse files
Options
Downloads
Patches
Plain Diff
snp_lite_density replaced by variation_density.pl
parent
19497b97
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/density_feature/snp_lite_density.pl
+0
-200
0 additions, 200 deletions
misc-scripts/density_feature/snp_lite_density.pl
with
0 additions
and
200 deletions
misc-scripts/density_feature/snp_lite_density.pl
deleted
100644 → 0
+
0
−
200
View file @
19497b97
#
# script to calculate the snp density with help of
# attached lite database. Only works if argument database
# is a core database and lite can be found by substituting
# s/_core_/_lite_/
#
# blocksize condition is 4_000 per genome?
use
strict
;
use
Bio::EnsEMBL::DBSQL::
DBAdaptor
;
use
Bio::EnsEMBL::
DensityType
;
use
Bio::EnsEMBL::
DensityFeature
;
use
Bio::EnsEMBL::Lite::
DBAdaptor
;
use
Getopt::
Long
;
my
(
$host
,
$user
,
$pass
,
$port
,
$dbname
);
my
(
$block_count
,
$genome_size
,
$block_size
);
GetOptions
(
"
host=s
",
\
$host
,
"
user=s
",
\
$user
,
"
pass=s
",
\
$pass
,
"
port=i
",
\
$port
,
"
dbname=s
",
\
$dbname
);
my
$db
=
new
Bio::EnsEMBL::DBSQL::
DBAdaptor
(
-
host
=>
$host
,
-
user
=>
$user
,
-
port
=>
$port
,
-
pass
=>
$pass
,
-
dbname
=>
$dbname
);
if
(
!
lite_attach
(
$db
))
{
die
(
"
Couldnt attache lite to
$dbname
"
);
}
#
# Get the adaptors needed;
#
my
$dfa
=
$db
->
get_DensityFeatureAdaptor
();
my
$dta
=
$db
->
get_DensityTypeAdaptor
();
my
$aa
=
$db
->
get_AnalysisAdaptor
();
my
$slice_adaptor
=
$db
->
get_SliceAdaptor
();
my
$top_slices
=
$slice_adaptor
->
fetch_all
(
"
toplevel
"
);
my
(
$block_size
,
$genome_size
);
for
my
$slice
(
@$top_slices
)
{
$genome_size
+=
$slice
->
length
();
}
$block_size
=
int
(
$genome_size
/
4000
);
my
$analysis
=
new
Bio::EnsEMBL::
Analysis
(
-
program
=>
"
snp_lite_density.pl
",
-
database
=>
"
ensembl
",
-
gff_source
=>
"
snp_lite_density.pl
",
-
gff_feature
=>
"
density
",
-
logic_name
=>
"
snpDensity
");
$aa
->
store
(
$analysis
);
#
# Create new density type.
#
my
$dt
=
Bio::EnsEMBL::
DensityType
->
new
(
-
analysis
=>
$analysis
,
-
block_size
=>
$block_size
,
-
value_type
=>
'
sum
');
$dta
->
store
(
$dt
);
#
# Now the actual feature calculation loop
#
my
(
$current_start
,
$current_end
);
foreach
my
$slice
(
@$top_slices
){
$current_start
=
1
;
print
"
SNP densities for
"
.
$slice
->
seq_region_name
()
.
"
with block size
$block_size
\n
";
while
(
$current_start
<=
$slice
->
end
())
{
$current_end
=
$current_start
+
$block_size
-
1
;
if
(
$current_end
>
$slice
->
end
()
)
{
$current_end
=
$slice
->
end
();
}
my
$sub_slice
=
$slice
->
sub_Slice
(
$current_start
,
$current_end
);
my
$count
=
0
;
#
# How many snps fall into this subslice
#
foreach
my
$snp
(
@
{
$sub_slice
->
get_all_SNPs
()}){
if
(
$snp
->
start
>=
1
)
{
$count
++
}
}
my
$df
=
Bio::EnsEMBL::
DensityFeature
->
new
(
-
seq_region
=>
$slice
,
-
start
=>
$current_start
,
-
end
=>
$current_end
,
-
density_type
=>
$dt
,
-
density_value
=>
$count
);
$current_start
=
$current_end
+
1
;
$dfa
->
store
(
$df
);
}
}
#
# tries to attach lite.
#
sub
lite_attach
{
my
$db
=
shift
;
my
$core_db_name
;
$core_db_name
=
$db
->
dbname
();
if
(
$core_db_name
!~
/_core_/
)
{
return
0
;
}
#
# get a lost of all databases on that server
#
my
$sth
=
$db
->
dbc
->
prepare
(
"
show databases
"
);
$sth
->
execute
();
my
$all_db_names
=
$sth
->
fetchall_arrayref
();
my
%all_db_names
=
map
{(
$_
->
[
0
]
,
1
)}
@$all_db_names
;
my
$snp_db_name
=
$core_db_name
;
$snp_db_name
=~
s/_core_/_lite_/
;
if
(
!
exists
$all_db_names
{
$snp_db_name
}
)
{
return
0
;
}
my
$snp_db
=
Bio::EnsEMBL::Lite::
DBAdaptor
->
new
(
-
host
=>
$db
->
host
(),
-
user
=>
$db
->
username
(),
-
pass
=>
$db
->
password
(),
-
port
=>
$db
->
port
(),
-
dbname
=>
$snp_db_name
);
$db
->
add_db_adaptor
(
"
lite
",
$snp_db
);
return
1
;
}
#
# helper to draw an ascii representation of the density features
#
sub
print_features
{
my
$features
=
shift
;
return
if
(
!
@$features
);
my
$sum
=
0
;
my
$length
=
0
;
# my $type = $features->[0]->{'density_type'}->value_type();
print
("
\n
");
my
$max
=
0
;
foreach
my
$f
(
@$features
)
{
if
(
$f
->
density_value
()
>
$max
){
$max
=
$f
->
density_value
();
}
}
if
(
!
$max
)
{
$max
=
1
};
foreach
my
$f
(
@$features
)
{
my
$i
=
1
;
for
(;
$i
<
(
$f
->
density_value
()
/
$max
)
*
40
;
$i
++
){
print
"
*
";
}
for
(
my
$j
=
$i
;
$j
<
40
;
$j
++
){
print
"
";
}
print
"
"
.
$f
->
density_value
()
.
"
\t
"
.
$f
->
start
()
.
"
\n
";
}
}
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