Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl-rest
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
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-rest
Commits
689d2343
Commit
689d2343
authored
9 years ago
by
Alessandro Vullo
Browse files
Options
Downloads
Plain Diff
Merge pull request #91 from Ensembl/
ENSCORESW-1480
ENSCORESW-1480
parents
0915987d
564cf93b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/EnsEMBL/REST/Controller/Sequence.pm
+28
-24
28 additions, 24 deletions
lib/EnsEMBL/REST/Controller/Sequence.pm
t/sequences.t
+34
-12
34 additions, 12 deletions
t/sequences.t
with
62 additions
and
36 deletions
lib/EnsEMBL/REST/Controller/Sequence.pm
+
28
−
24
View file @
689d2343
...
...
@@ -156,6 +156,13 @@ sub _process {
Catalyst::
Exception
->
throw
(
qq{The type '$type' is not understood by this service}
)
unless
$allowed_values
{
type
}{
$type
};
if
(
$c
->
request
->
param
('
start
')
||
$c
->
request
->
param
('
end
'))
{
# We don't support circular features at this time, if it's a circular
# feature, and not a translation, throw an error.
unless
(
$object
->
isa
('
Bio::EnsEMBL::Translation
'))
{
my
$feat_slice
=
$object
->
feature_Slice
();
Catalyst::
Exception
->
throw
(
qq{Circular slices aren't supported for sequence trimming at this time}
)
if
(
$feat_slice
->
is_circular
());
}
# It doesn't make sense to expand the sequence when doing a sub-sequence
if
(
$c
->
request
->
param
('
expand_5prime
')
||
$c
->
request
->
param
('
expand_3prime
'))
{
Catalyst::
Exception
->
throw
(
qq{You may not expand the 3prime or 5prime sequence end when requesting a sub-sequence}
);
...
...
@@ -203,42 +210,33 @@ sub _process_feature {
if
(
$object
->
isa
('
Bio::EnsEMBL::Translation
'))
{
$molecule
=
'
protein
';
$seq
=
$object
->
transcript
()
->
translate
()
->
seq
();
# Grab the subsequence if we've been asked to trim the ends
$seq
=
$self
->
_process_subseq
(
$c
,
$seq
)
if
(
$c
->
stash
()
->
{
dosubseq
});
}
#Transcripts
elsif
(
$object
->
isa
('
Bio::EnsEMBL::PredictionTranscript
'))
{
if
(
$type
eq
'
cdna
')
{
$seq
=
$object
->
spliced_seq
(
$mask_feature
);
# Grab the subsequence if we've been asked to trim the ends
$seq
=
$self
->
_process_subseq
(
$c
,
$seq
)
if
(
$c
->
stash
()
->
{
dosubseq
});
}
elsif
(
$type
eq
'
cds
')
{
$seq
=
$object
->
translateable_seq
();
# Grab the subsequence if we've been asked to trim the ends
$seq
=
$self
->
_process_subseq
(
$c
,
$seq
)
if
(
$c
->
stash
()
->
{
dosubseq
});
}
elsif
(
$type
eq
'
protein
')
{
$molecule
=
'
protein
';
$seq
=
$object
->
translate
()
->
seq
();
if
(
$c
->
stash
()
->
{
dosubseq
})
{
# It's a protein that's been requested so we have to translate
# the coordinates first
$self
->
_translate_coordinates
(
$c
,
$object
);
$seq
=
$self
->
_process_subseq
(
$c
,
$seq
);
}
# It's a protein that's been requested so we have to translate
# the coordinates first
$self
->
_translate_coordinates
(
$c
,
$object
)
if
(
$c
->
stash
()
->
{
dosubseq
});
}
}
elsif
(
$object
->
isa
('
Bio::EnsEMBL::Transcript
'))
{
if
(
$type
eq
'
cdna
')
{
$seq
=
$object
->
spliced_seq
(
$mask_feature
);
$seq
=
$self
->
_process_subseq
(
$c
,
$seq
)
if
(
$c
->
stash
()
->
{
dosubseq
});
}
elsif
(
$type
eq
'
cds
')
{
$seq
=
$object
->
translateable_seq
();
# We might not have a translatable sequence, be sure
# we do before attempting to trim
$seq
=
$self
->
_process_subseq
(
$c
,
$seq
)
if
(
$c
->
stash
()
->
{
dosubseq
}
&&
$seq
);
}
#If protein perform recursive calls with the Translation object
elsif
(
$type
eq
'
protein
')
{
...
...
@@ -251,6 +249,7 @@ sub _process_feature {
foreach
my
$t
(
@translations
)
{
# Catch case where no translation is available for a transcript
next
unless
$t
;
push
(
@sequences
,
@
{
$self
->
_process_feature
(
$c
,
$t
,
$type
)});
}
}
...
...
@@ -297,6 +296,10 @@ sub _process_feature {
}
if
(
$seq
)
{
# Grab the subsequence if we've been asked to trim the ends
$seq
=
$self
->
_process_subseq
(
$c
,
$seq
)
if
(
$c
->
stash
()
->
{
dosubseq
});
push
(
@sequences
,
{
id
=>
$object
->
stable_id
(),
seq
=>
$seq
,
...
...
@@ -338,9 +341,11 @@ sub _check_limits {
if
(
$start
<
0
||
$start
>
$seq_len
)
{
Catalyst::
Exception
->
throw
(
qq{Your start coordinate is not within the sequence requested}
)
}
if
(
$end
<
1
||
$end
>
$seq_len
+
1
)
{
Catalyst::
Exception
->
throw
(
qq{Your end coordinate is not within the sequence requested}
)
}
if
(
$start
>
$end
)
{
Catalyst::
Exception
->
throw
(
qq{Your start coordinate cannot be larger than your end}
)
}
...
...
@@ -355,9 +360,11 @@ sub _translate_coordinates {
my
(
$self
,
$c
,
$obj
)
=
@_
;
# Return if we've already translated the coordinates
return
if
(
$c
->
{
stash
}
->
{
coordstranslated
});
return
if
(
$c
->
stash
->
{
coordstranslated
});
# Do we have a translation?
return
unless
(
$obj
->
translate
());
my
$seq_len
=
length
$obj
->
spliced_seq
();
my
$start
;
my
$end
;
if
(
$obj
->
strand
()
==
1
)
{
$start
=
$c
->
request
->
param
('
start
')
?
$c
->
request
->
param
('
start
')
+
$obj
->
seq_region_start
()
-
1
:
$obj
->
seq_region_start
();
...
...
@@ -366,12 +373,9 @@ sub _translate_coordinates {
# Things get a little messy if we're on the reverse strand, we have to count from
# opposite ends.
$end
=
$c
->
request
->
param
('
start
')
?
$obj
->
seq_region_end
()
-
$c
->
request
->
param
('
start
')
:
$obj
->
seq_region_end
();
$start
=
$c
->
request
->
param
('
end
')
?
$obj
->
seq_region_
start
()
+
$seq_len
-
$c
->
request
->
param
('
end
')
:
$obj
->
seq_region_start
();
$start
=
$c
->
request
->
param
('
end
')
?
$obj
->
seq_region_
end
()
-
$c
->
request
->
param
('
end
')
:
$obj
->
seq_region_start
();
}
# Do we have a translation?
return
unless
(
$obj
->
translate
());
my
$transcript_mapper
=
$obj
->
get_TranscriptMapper
();
# Grab the coordinates for the peptide sequence that maps from
...
...
@@ -398,7 +402,7 @@ sub _translate_coordinates {
}
# Remember we've translated the coordinates so we don't try again
$c
->
{
stash
}
->
{
coordstranslated
}
=
1
;
$c
->
stash
->
{
coordstranslated
}
=
1
;
}
# For the fustrating flow where you're going from a Gene and are outputting
...
...
@@ -408,17 +412,17 @@ sub _translate_coordinates {
sub
_push_start_end
{
my
(
$self
,
$c
)
=
@_
;
$c
->
{
stash
}
->
{
orig_start
}
=
$c
->
request
->
param
('
start
')
if
(
$c
->
request
->
param
('
start
'));
$c
->
{
stash
}
->
{
orig_end
}
=
$c
->
request
->
param
('
end
')
if
(
$c
->
request
->
param
('
end
'));
$c
->
stash
->
{
orig_start
}
=
$c
->
request
->
param
('
start
')
if
(
$c
->
request
->
param
('
start
'));
$c
->
stash
->
{
orig_end
}
=
$c
->
request
->
param
('
end
')
if
(
$c
->
request
->
param
('
end
'));
}
sub
_pop_start_end
{
my
(
$self
,
$c
)
=
@_
;
$c
->
request
->
params
->
{'
start
'}
=
$c
->
{
stash
}
->
{
orig_start
}
if
(
$c
->
{
stash
}
->
{
orig_start
}
)
;
$c
->
request
->
params
->
{'
end
'}
=
$c
->
{
stash
}
->
{
orig_end
}
if
(
$c
->
{
stash
}
->
{
orig_end
}
)
;
$c
->
request
->
params
->
{'
start
'}
=
$c
->
stash
->
{
orig_start
}
?
$c
->
stash
->
{
orig_start
}
:
undef
;
$c
->
request
->
params
->
{'
end
'}
=
$c
->
stash
->
{
orig_end
}
?
$c
->
stash
->
{
orig_end
}
:
undef
;
$c
->
{
stash
}
->
{
coordstranslated
}
=
0
;
$c
->
stash
->
{
coordstranslated
}
=
0
;
}
sub
_enrich_slice
{
...
...
This diff is collapsed.
Click to expand it.
t/sequences.t
+
34
−
12
View file @
689d2343
...
...
@@ -316,12 +316,22 @@ FASTA
{
my
$id
=
'
ENSP00000259806
';
my
$url
=
"
/sequence/id/
$id
?type=protein&start=10&end=30
";
my
$fasta
=
fasta_GET
(
$url
,
'
Getting protein sub-sequence from trans
cript withou
t
e
nd
parameter
');
my
$fasta
=
fasta_GET
(
$url
,
'
Getting protein sub-sequence from trans
lation feature with star
t
a
nd
end
');
my
$expected
=
<<'FASTA';
>ENSP00000259806
APLRRACSPVPGALQAALMSP
FASTA
is
(
$fasta
,
$expected
,
'
Getting protein sub-sequence from transcript without end parameter
');
is
(
$fasta
,
$expected
,
'
Getting protein sub-sequence from translation feature with start and end
');
}
{
my
$id
=
'
ENSP00000259806
';
my
$url
=
"
/sequence/id/
$id
?type=protein&start=30&end=30
";
my
$fasta
=
fasta_GET
(
$url
,
'
Getting single bp protein sub-sequence from translation feature
');
my
$expected
=
<<'FASTA';
>ENSP00000259806
P
FASTA
is
(
$fasta
,
$expected
,
'
Getting single bp sub-sequence from translation feature
');
}
{
my
$id
=
'
ENST00000400701
';
...
...
@@ -329,25 +339,37 @@ FASTA
my
$fasta
=
fasta_GET
(
$url
,
'
Getting protein sub-sequence from transcript without start parameter
');
my
$expected
=
<<'FASTA';
>ENSP00000383537
XSNLKRDVAHLYRGVGSRYIMGSGESFMQLQQRLLREKEAKIRKALDRLRKKRHLLRRQR
TRREFPVISVVGYTNCGKTTLIKALTGDAAIQPRDQLFATLDVTAHAGTLPSRMTVLYVD
TIGFLSQLPHGLIESFSATLEDVAHSDLILHVRDVSHPEAELQKCSVLSTLRGLQLPAPL
LDSMVEVHNKVDLVPGYSPTEPNVVPVSALRGHGLQELKAELDAAVLKATGRQILTLRVR
LAGAQLS
XSNLKRDVAHLYRGVGSRYIMGSG
FASTA
is
(
$fasta
,
$expected
,
'
Getting protein sub-sequence from transcript without start parameter
');
}
{
my
$id
=
'
ENST00000400701
';
my
$url
=
"
/sequence/id/
$id
?type=protein&start=10&end=10
";
my
$fasta
=
fasta_GET
(
$url
,
'
Getting protein sub-sequence from transcript with length 1bp
');
my
$expected
=
<<'FASTA';
>ENSP00000383537
K
FASTA
is
(
$fasta
,
$expected
,
'
Getting protein sub-sequence from transcript with length 1bp
');
}
{
my
$id
=
'
ENSG00000112699
';
my
$url
=
"
/sequence/id/
$id
?type=protein&multiple_sequences=1&start=
30
0000
";
my
$url
=
"
/sequence/id/
$id
?type=protein&multiple_sequences=1&start=
15
0000
";
my
$fasta
=
fasta_GET
(
$url
,
'
Getting protein sub-sequence from gene, using multiple
');
my
$expected
=
<<'FASTA';
>ENSP00000436726
AMWLMLQNDEPEDFVIATGEVHSVREFVEKSFLHIGKTIVWEGKNENEVGRCKETGKVHV
TVDLKYYRPTEVDFLQGDCTKAKQKLNWKPRVAFDELVREMVHADVELMRTNPNA
ISFDLAEYTADVDGVGTLRLLDAVKTCGLINSVKFYQASTSELYGKVQEIPQKETTPFYP
RSPYGAAKLYAYWIVVNFREAYNLFAVNGILFNHESPRRGANFVTRKISRSVAKIYLGQL
ECFSLGNLDAKRDWGHAKDYVEAMWLMLQNDEPEDFVIATGEVHSVREFVEKSFLHIGKT
IVWEGKNENEVGRCKETGKVHVTVDLKYYRPTEVDFLQGDCTKAKQKLNWKPRVAFDELV
REMVHADVELMRTNPNA
>ENSP00000370194
GANFVTRKISRSVAKIYLGQLECFSLGNLDAKRDWGHAKDYVEAMWLMLQNDEPEDFVIA
TGEVHSVREFVEKSFLHIGKTIVWEGKNENEVGRCKETGKVHVTVDLKYYRPTEV
ISFDLAEYTADVDGVGTLRLLDAVKTCGLINSVKFYQASTSELYGKVQEIPQKETTPFYP
RSPYGAAKLYAYWIVVNFREAYNLFAVNGILFNHESPRRGANFVTRKISRSVAKIYLGQL
ECFSLGNLDAKRDWGHAKDYVEAMWLMLQNDEPEDFVIATGEVHSVREFVEKSFLHIGKT
IVWEGKNENEVGRCKETGKVHVTVDLKYYRPTEVDFLQGDCTKAKQKLNWKPRVAFDELV
REMVHADVELMRTNPNA
FASTA
is
(
$fasta
,
$expected
,
'
Getting protein sub-sequence from gene, using multiple
');
}
...
...
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