Skip to content
Snippets Groups Projects
Commit 567477f3 authored by Neil Kindlon's avatar Neil Kindlon
Browse files

Fixed bug 223, Insertions for VCF records. Added unit test.

parent 488b0593
No related branches found
No related tags found
No related merge requests found
......@@ -145,6 +145,7 @@ int SingleLineDelimTextFileReader::getVcfSVlen() {
cerr << "WARNING: line number " << _lineNum << " of file " << _filename << " has an imprecise variant, but no SVLEN specified. Defaulting to length 1." << endl;
return 1;
}
startPtr +=6; // length of label "SVLEN="
const char *endPtr = strchr(startPtr, ';');
const char *midPtr = strchr(startPtr, ',');
int endCoord = -1;
......
......@@ -21,8 +21,14 @@ bool VcfRecord::initFromFile(SingleLineDelimTextFileReader *fileReader)
fileReader->getField(4, _varAlt);
fileReader->getField(3, _varRef);
if (_varAlt[0] == '<') {
//this is a structural variant. Need to parse the tags to find the endpos.
_endPos = _startPos + fileReader->getVcfSVlen();
// this is a structural variant. Need to parse the tags to find the endpos,
// UNLESS it's an insertion.
if (!(_varAlt[1] == 'I' && _varAlt[2] == 'N' && _varAlt[3] == 'S')) {
_endPos = _startPos + fileReader->getVcfSVlen();
} else {
//for insertions, treat as zero-length records
_endPos = _startPos;
}
} else {
//endPos is just the startPos plus the length of the variant
_endPos = _startPos + _varRef.size();
......
##fileformat=VCFv4.1
chr1 1 a G <DEL> 70.90 . TOOL=LUMPY;SVTYPE=DEL;SVLEN=-389,-4611;END=253195;STR=+-:4;IMPRECISE;CIPOS=-2,137;CIEND=0,0;EVENT=791255;SUP=4;PESUP=4;SRSUP=0;EV=PE;PRIN;CSQ=intergenic_variant||||||||||
chr1 4 a G <INS> 70.90 . TOOL=LUMPY;SVTYPE=DEL;SVLEN=-4611;END=253195;STR=+-:4;IMPRECISE;CIPOS=-2,137;CIEND=0,0;EVENT=791255;SUP=4;PESUP=4;SRSUP=0;EV=PE;PRIN;CSQ=intergenic_variant||||||||||
##fileformat=VCFv4.1
chr1 5 a G <INS> 70.90 . TOOL=LUMPY;SVTYPE=DEL;SVLEN=500;END=253195;STR=+-:4;IMPRECISE;CIPOS=-2,137;CIEND=0,0;EVENT=791255;SUP=4;PESUP=4;SRSUP=0;EV=PE;PRIN;CSQ=intergenic_variant||||||||||
chr1 15 a G <DEL> 70.90 . TOOL=LUMPY;SVTYPE=DEL;SVLEN=-600;END=253195;STR=+-:4;IMPRECISE;CIPOS=-2,137;CIEND=0,0;EVENT=791255;SUP=4;PESUP=4;SRSUP=0;EV=PE;PRIN;CSQ=intergenic_variant||||||||||
......@@ -538,13 +538,16 @@ rm exp obs
##################################################################
# see that -nonamecheck only works for sorted data
# NOTE: This test is now deprecated, as the -nonamecheck option
# must also now work with unsorted data
##################################################################
echo " intersect.t44...\c"
echo \
"***** ERROR: -nonamecheck option is only valid for sorted input. *****" > exp
$BT intersect -a nonamecheck_a.bed -b nonamecheck_b.bed -nonamecheck 2>&1 > /dev/null | cat - | head -2 | tail -1 > obs
check exp obs
rm exp obs
echo ok
#"***** ERROR: -nonamecheck option is only valid for sorted input. *****" > exp
#$BT intersect -a nonamecheck_a.bed -b nonamecheck_b.bed -nonamecheck 2>&1 > /dev/null | cat - | head -2 | tail -1 > obs
#check exp obs
#rm exp obs
##################################################################
# see that differently named chroms don't work with -sorted
......@@ -559,7 +562,7 @@ rm exp obs
##################################################################
# see that differently named chroms -sorted and -nonamecheck
# don't complain
# don't complain with -nonamecheck
##################################################################
echo " intersect.t46...\c"
touch exp
......@@ -567,6 +570,19 @@ $BT intersect -a nonamecheck_a.bed -b nonamecheck_b.bed -sorted -nonamecheck 2>&
check exp obs
rm exp obs
##################################################################
# see that SVLEN in VCF files is treated as zero length
# records when the SV type is an insertion
##################################################################
echo " intersect.t47...\c"
echo \
"chr1 1 a G <DEL> 70.90
chr1 1 a G <DEL> 70.90
chr1 4 a G <INS> 70.90" > exp
$BT intersect -a bug223_sv1_a.vcf -b bug223_sv1_b.vcf | cut -f1-6 > obs
check exp obs
rm exp obs
cd multi_intersect
bash test-multi_intersect.sh
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment