Permalink
Browse files

fix issues with griffithlab#75

  • Loading branch information...
gatoravi committed Sep 11, 2017
1 parent 79605d7 commit 029007512c10afeae1a68cbd4b5aac9b99f7bde3
Showing with 74 additions and 77 deletions.
  1. +74 −68 src/variants/variants_annotator.cc
  2. +0 −9 src/variants/variants_annotator.h
@@ -172,65 +172,92 @@ void VariantsAnnotator::set_variant_cis_effect_limits_ps(const vector<BED>& exon
AnnotatedVariant& variant,
uint32_t i) {
//Check if the cis effect limits have increased.
if(i != 0) {
if(exons[i-1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[i-1].start;
if(variant.annotation == "exonic" || variant.annotation == "splicing_exonic") { //Current exon is cassette
if(i != 0) {
if(exons[i-1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[i-1].start;
}
} else {
if(exons[0].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[0].start;
}
}
} else {
if(exons[0].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[0].start;
if(i != exons.size() - 1) {
if(exons[i+1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[i+1].end;
}
} else {
if(exons[exons.size() - 1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[exons.size() - 1].end;
}
}
}
if(i != exons.size() - 1) {
if(exons[i+1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[i+1].end;
} else if(variant.annotation == "intronic" || variant.annotation == "splicing_intronic") { //Current exon is cassette
if(i != 0) {
if(exons[i-1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[i-1].end;
}
} else {
if(exons[0].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[0].end;
}
}
} else {
if(exons[exons.size() - 1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[exons.size() - 1].end;
if(i != exons.size() - 1) {
if(exons[i+1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[i+1].start;
}
} else {
if(exons[exons.size() - 1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[exons.size() - 1].start;
}
}
}
return;
}
//Set limits on + strand for exonic/intronic case
inline
void VariantsAnnotator::set_variant_cis_effect_limits_exonic_intronic_ps(const vector<BED>& exons,
AnnotatedVariant& variant) {
variant.cis_effect_start = exons[0].start;
variant.cis_effect_end = exons[exons.size() - 1].end;
}
//Set limits on - strand for exonic/intronic case
inline
void VariantsAnnotator::set_variant_cis_effect_limits_exonic_intronic_ns(const vector<BED>& exons,
AnnotatedVariant& variant) {
variant.cis_effect_end = exons[0].end;
variant.cis_effect_start = exons[exons.size() - 1].start;
}
//Set limits on - strand
inline
void VariantsAnnotator::set_variant_cis_effect_limits_ns(const vector<BED>& exons,
AnnotatedVariant& variant,
uint32_t i) {
if(i != 0) {
//Check if the cis effect limits have increased.
if(exons[i-1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[i-1].end;
if(variant.annotation == "exonic" || variant.annotation == "splicing_exonic") { //Current exon is cassette
if(i != 0) {
//Check if the cis effect limits have increased.
if(exons[i-1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[i-1].end;
}
} else {
if(exons[0].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[0].end;
}
}
} else {
if(exons[0].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[0].end;
if(i != exons.size() -1) {
if(exons[i+1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[i+1].start;
}
} else {
if(exons[exons.size() - 1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[exons.size() - 1].start;
}
}
}
if(i != exons.size() -1) {
if(exons[i+1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[i+1].start;
} else if(variant.annotation == "intronic" || variant.annotation == "splicing_intronic") { //Look at junctions that overlap intronic space
if(i != 0) {
//Check if the cis effect limits have increased.
if(exons[i-1].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[i-1].start;
}
} else {
if(exons[0].end > variant.cis_effect_end) {
variant.cis_effect_end = exons[0].start;
}
}
} else {
if(exons[exons.size() - 1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[exons.size() - 1].start;
if(i != exons.size() -1) {
if(exons[i+1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[i+1].end;
}
} else {
if(exons[exons.size() - 1].start < variant.cis_effect_start) {
variant.cis_effect_start = exons[exons.size() - 1].end;
}
}
}
return;
@@ -257,27 +284,6 @@ void VariantsAnnotator::set_variant_cis_effect_limits(const vector<BED>& exons,
}
}
//Get the coordinates which limit the effect of this variant.
//The cis-splice-effects command uses these fields to pull out
//junctions which might be related to the presence of this variant.
//This is set to the nearest acceptor and donor of the neigboring
//exons. The calculation will vary according to the strand of this
//transcript.
//This is for exonic/intronic variants - not necessarily in the splice region
inline
void VariantsAnnotator::set_variant_cis_effect_limits_exonic_intronic(const vector<BED>& exons,
AnnotatedVariant& variant) {
string transcript_strand = exons[0].strand;
if(transcript_strand == "+") {
set_variant_cis_effect_limits_exonic_intronic_ps(exons, variant);
return;
}
if(transcript_strand == "-") {
set_variant_cis_effect_limits_exonic_intronic_ns(exons, variant);
return;
}
}
//Overlap splice region in the negative strand
void VariantsAnnotator::get_variant_overlaps_spliceregion_ns(const vector<BED>& exons,
AnnotatedVariant& variant) {
@@ -295,7 +301,7 @@ void VariantsAnnotator::get_variant_overlaps_spliceregion_ns(const vector<BED>&
variant.score = common::num_to_str(min(variant.end - exons[i].start,
exons[i].end - variant.end));
variant.annotation = "exonic";
set_variant_cis_effect_limits_exonic_intronic(exons, variant);
set_variant_cis_effect_limits(exons, variant, i);
return;
}
}
@@ -305,7 +311,7 @@ void VariantsAnnotator::get_variant_overlaps_spliceregion_ns(const vector<BED>&
variant.score = common::num_to_str(min(variant.end - exons[i+1].end,
exons[i].start - variant.end));
variant.annotation = "intronic";
set_variant_cis_effect_limits_exonic_intronic(exons, variant);
set_variant_cis_effect_limits(exons, variant, i);
return;
}
}
@@ -380,7 +386,7 @@ void VariantsAnnotator::get_variant_overlaps_spliceregion_ps(const vector<BED>&
variant.score = common::num_to_str(min(variant.end - exons[i].start,
exons[i].end - variant.end));
variant.annotation = "exonic";
set_variant_cis_effect_limits_exonic_intronic(exons, variant);
set_variant_cis_effect_limits(exons, variant, i);
return;
}
}
@@ -391,7 +397,7 @@ void VariantsAnnotator::get_variant_overlaps_spliceregion_ps(const vector<BED>&
variant.score = common::num_to_str(min(variant.end - exons[i].end,
exons[i+1].start - variant.end));
variant.annotation = "intronic";
set_variant_cis_effect_limits_exonic_intronic(exons, variant);
set_variant_cis_effect_limits(exons, variant, i);
return;
}
}
@@ -221,15 +221,6 @@ class VariantsAnnotator {
void set_variant_cis_effect_limits_ps(const vector<BED>& exons,
AnnotatedVariant& variant1,
uint32_t i);
//Cis limits for exonic/intronic case - figure out strand here
void set_variant_cis_effect_limits_exonic_intronic(const vector<BED>& exons,
AnnotatedVariant& variant);
//Cis limits for exonic/intronic case - negative strand
void set_variant_cis_effect_limits_exonic_intronic_ns(const vector<BED>& exons,
AnnotatedVariant& variant);
//Cis limits for exonic/intronic case - positive strand
void set_variant_cis_effect_limits_exonic_intronic_ps(const vector<BED>& exons,
AnnotatedVariant& variant);
};
inline string variant_set_to_string(const set<AnnotatedVariant> &av1) {

0 comments on commit 0290075

Please sign in to comment.