Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1299 from david4096/1294_fix
Browse files Browse the repository at this point in the history
Fix VA search bug
  • Loading branch information
david4096 authored Jul 26, 2016
2 parents 7fae9f6 + 56191a5 commit 1b549f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 3 additions & 1 deletion ga4gh/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,17 @@ def _matchAnyEffects(self, effect):

def _removeNonMatchingTranscriptEffects(self, ann):
newTxE = []
oldTxE = ann.transcript_effects
if len(self._effects) == 0:
return ann
for txe in ann.transcript_effects:
for txe in oldTxE:
add = False
for effect in txe.effects:
if self._matchAnyEffects(effect):
add = True
if add:
newTxE.append(txe)
ann.ClearField('transcript_effects')
ann.transcript_effects.extend(newTxE)
return ann

Expand Down
15 changes: 5 additions & 10 deletions ga4gh/datamodel/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,11 +968,10 @@ def generateVariantAnnotation(self, variant):
ann.created = datetime.datetime.now().isoformat() + "Z"
# make a transcript effect for each alternate base element
# multiplied by a random integer (1,5)
for i in range(randomNumberGenerator.randint(1, 5)):
for base in variant.alternate_bases:
ann.transcript_effects.add().CopyFrom(
self.generateTranscriptEffect(
variant, ann, base, randomNumberGenerator))
for base in variant.alternate_bases:
ann.transcript_effects.add().CopyFrom(
self.generateTranscriptEffect(
variant, ann, base, randomNumberGenerator))
ann.id = self.getVariantAnnotationId(variant, ann)
return ann

Expand All @@ -986,10 +985,6 @@ def _addTranscriptEffectLocations(self, effect, ann, variant):
effect.cdna_location.start = variant.start
return effect

def _addTranscriptEffectId(self, effect):
effect.id = str(self.getTranscriptEffectId(effect))
return effect

def _getRandomOntologyTerm(self, randomNumberGenerator):
# TODO more mock options from simulated seqOnt?
ontologyTuples = [
Expand Down Expand Up @@ -1032,7 +1027,7 @@ def generateTranscriptEffect(
effect, randomNumberGenerator)
effect = self._addTranscriptEffectOntologyTerm(
effect, randomNumberGenerator)
effect = self._addTranscriptEffectId(effect)
effect.id = self.getTranscriptEffectId(effect)
effect = self._addAnalysisResult(effect, ann, randomNumberGenerator)
return effect

Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_simulated_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@ def testVariantAnnotationsSearch(self):
"There should be some results for a good effect ID")
for ann in responseData.variant_annotations:
effectPresent = False
txIds = map(lambda t: t.id, ann.transcript_effects)
self.assertEqual(len(txIds), len(set(txIds)),
"Transcript effects should be unique")
for effect in ann.transcript_effects:
for featureType in effect.effects:
if featureType.id in map(
Expand Down

0 comments on commit 1b549f2

Please sign in to comment.