Skip to content
Snippets Groups Projects
Commit d3024a80 authored by tjc's avatar tjc
Browse files

more fixes for identifying heterozygous sites

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@15553 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent f63be8a9
Branches
Tags
No related merge requests found
......@@ -73,7 +73,7 @@ class VCFRecord
rec.pos = Integer.parseInt(parts[1]);
rec.ID = parts[2];
rec.ref = parts[3];
rec.var = rec.new VariantBase(parts[4]);
rec.var = new VariantBase(rec, parts[4]);
try
{
......@@ -232,7 +232,7 @@ class VCFRecord
*/
protected void setAlt(String alt)
{
this.var = new VariantBase(alt);
this.var = new VariantBase(this, alt);
}
/**
......@@ -428,108 +428,4 @@ class VCFRecord
return 3;
}
public class VariantBase
{
private String alt;
public VariantBase(String alt)
{
this.alt = alt;
}
public String toString()
{
return alt;
}
protected int length()
{
return alt.length();
}
/**
* Is this a deletion type.
* @param variant
* @return
*/
protected boolean isDeletion(boolean vcf_v4)
{
if(vcf_v4)
{
if( alt.length() < ref.length() && !(alt.indexOf(",") > -1) )
return true;
}
else if(alt.indexOf("D")>-1)
return true;
return false;
}
/**
* Is this an insertion type.
* @param variant
* @return
*/
protected boolean isInsertion(boolean vcf_v4)
{
if(vcf_v4)
{
if( alt.length() > ref.length() && !(alt.indexOf(",") > -1) )
return true;
}
else if(alt.indexOf("I")>-1)
return true;
return false;
}
protected boolean isMultiAllele()
{
if(VCFRecord.MULTI_ALLELE_PATTERN.matcher(alt).matches())
return true;
// look at probability of each genotype (PL) information as well
String pl;
if((pl = getFormatValue("PL")) != null &&
pl.split(",").length == 3 &&
pl.split(",")[1].equals("0")) // middle value is zero, e.g.
return true;
return false;
}
protected int getNumAlleles()
{
if (alt.equals("."))
return 1;
return alt.split(",").length+1;
}
protected int getNumberOfDeletions(boolean vcf_v4)
{
String alt = getAlt().toString();
if(vcf_v4)
{
if(alt.equals("."))
return getRef().length();
return getRef().length()-alt.length();
}
int index = alt.indexOf("D");
int ndel = 0;
try
{
ndel = Integer.parseInt( alt.substring(index+1) );
}
catch(NumberFormatException e) { e.printStackTrace(); }
return ndel;
}
protected boolean isNonVariant()
{
if(alt.equals(".") && ref.length() == 1)
return true;
return false;
}
}
}
\ No newline at end of file
......@@ -706,7 +706,7 @@ public class VCFview extends JPanel
msg += "Qual: "+mouseVCF.getQuality()+"\n";
String pl;
if((pl = mouseVCF.getFormatValue("PL")) != null && pl.split(",").length > 1)
msg += "PL: "+pl+"\n";
msg += "Genotype likelihood (PL): "+pl+"\n";
return msg;
}
......@@ -1008,15 +1008,15 @@ public class VCFview extends JPanel
if(colourScheme == QUAL_COLOUR_SCHEME)
g.setColor(getQualityColour(record));
else if(record.getAlt().isDeletion(vcf_v4))
g.setColor(Color.gray);
else if(record.getAlt().isInsertion(vcf_v4))
g.setColor(Color.yellow);
else if(record.getAlt().isMultiAllele())
{
g.setColor(Color.orange);
g.fillArc(pos[0]-3, pos[1]-LINE_HEIGHT-3, 6, 6, 0, 360);
}
else if(record.getAlt().isDeletion(vcf_v4))
g.setColor(Color.gray);
else if(record.getAlt().isInsertion(vcf_v4))
g.setColor(Color.yellow);
else if(record.getAlt().length() == 1 && record.getRef().length() == 1)
{
g.setColor(getColourForSNP(record, features, basePosition));
......
package uk.ac.sanger.artemis.components.variant;
public class VariantBase
{
private VCFRecord record;
private String alt;
public VariantBase(VCFRecord record, String alt)
{
this.record = record;
this.alt = alt;
}
public String toString()
{
return alt;
}
protected int length()
{
return alt.length();
}
/**
* Is this a deletion type.
* @param variant
* @return
*/
protected boolean isDeletion(boolean vcf_v4)
{
if (vcf_v4)
{
if (alt.length() < record.getRef().length() && !(alt.indexOf(",") > -1))
return true;
}
else if (alt.indexOf("D") > -1)
return true;
return false;
}
/**
* Is this an insertion type.
*
* @param variant
* @return
*/
protected boolean isInsertion(boolean vcf_v4)
{
if (vcf_v4)
{
if (alt.length() > record.getRef().length() && !(alt.indexOf(",") > -1))
return true;
}
else if (alt.indexOf("I") > -1)
return true;
return false;
}
protected boolean isMultiAllele()
{
if (VCFRecord.MULTI_ALLELE_PATTERN.matcher(alt).matches())
return true;
// look at probability of each genotype (PL) information as well
String pl;
if ((pl = record.getFormatValue("PL")) != null && pl.split(",").length == 3 &&
pl.split(",")[1].equals("0")) // middle value is zero, e.g.
return true;
return false;
}
protected int getNumAlleles()
{
if (alt.equals("."))
return 1;
return alt.split(",").length + 1;
}
protected int getNumberOfDeletions(boolean vcf_v4)
{
if (vcf_v4)
{
if (alt.equals("."))
return record.getRef().length();
return record.getRef().length() - alt.length();
}
int index = alt.indexOf("D");
int ndel = 0;
try
{
ndel = Integer.parseInt(alt.substring(index + 1));
}
catch (NumberFormatException e)
{
e.printStackTrace();
}
return ndel;
}
protected boolean isNonVariant()
{
if (alt.equals(".") && record.getRef().length() == 1)
return true;
return false;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment