Newer
Older
package uk.ac.sanger.artemis.components.variant;
public class VariantBase
{
private VCFRecord record;
private String alt;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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;
}
{
if (VCFRecord.MULTI_ALLELE_PATTERN.matcher(alt).matches())
return true;
// look at probability of each genotype (PL) information as well
final String pl = record.getFormatValueForSample("PL", sampleIndex);
final String pls[] = COMMA_PATTERN.split(pl);
if(pls.length == 3 && pls[1].equals("0")) // middle value is zero, e.g.
return true;
}
return false;
}
protected int getNumAlleles()
{
return VCFRecord.countOccurrences(alt, ',')+2;
//return COMMA_PATTERN.split(alt).length + 1;
{
if (vcf_v4)
{
if (alt.equals("."))
return record.getRef().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(".") || alt.equals("X")) && record.getRef().length() == 1)