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

add more IUB codes

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@15560 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 3d9efd1c
No related branches found
No related tags found
No related merge requests found
/* MultipleAlleleVariant
*
* created: 2011
*
* This file is part of Artemis
*
* Copyright(C) 2011 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or(at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
package uk.ac.sanger.artemis.components.variant;
public class MultipleAlleleVariant
{
private static String IUB[][] =
private static String IUB_2[][] =
{
{"m", "a", "c"},
{"r", "a", "g"},
......@@ -17,11 +38,22 @@ public class MultipleAlleleVariant
{"k", "g", "u"}
};
private static String IUB_3[][] =
{
{"b", "c", "g", "t"},
{"b", "c", "g", "u"},
{"d", "a", "g", "t"},
{"d", "a", "g", "u"},
{"h", "a", "c", "t"},
{"h", "a", "c", "u"},
{"v", "a", "c", "g"}
};
/**
* M (A or C)
* R (A or G)
* W (A or T/U)
* S (C or G)
* M (A or C) B (C, G or T/U)
* R (A or G) D (A, G or T/U)
* W (A or T/U) H (A, C or T/U)
* S (C or G) V (A, C or G)
* Y (C or T/U)
* K (G or T/U)
* @param base
......@@ -30,7 +62,7 @@ public class MultipleAlleleVariant
protected static String getIUBCode(VCFRecord record)
{
String alt = record.getAlt().toString();
String alleles[] = alt.split(",");
String alleles[] = alt.toLowerCase().split(",");
String pl;
if ((pl = record.getFormatValue("PL")) != null && pl.split(",").length == 3 &&
pl.split(",")[1].equals("0"))
......@@ -39,26 +71,45 @@ public class MultipleAlleleVariant
String[] temp = new String[alleles.length+1];
System.arraycopy(alleles, 0, temp, 0, alleles.length);
alleles = temp;
alleles[alleles.length-1] = record.getRef();
alleles[alleles.length-1] = record.getRef().toLowerCase();
}
boolean isSNP = true;
for(int i=0; i<alleles.length; i++)
{
alleles[i] = alleles[i].toLowerCase();
alleles[i] = alleles[i];
if(alleles[i].length() > 1)
isSNP = false;
}
if(isSNP && alleles.length == 2)
{
for(int i=0; i<IUB.length; i++)
for(int i=0; i<IUB_2.length; i++)
{
if(IUB[i][1].equals(alleles[0]) && IUB[i][2].equals(alleles[1]) ||
IUB[i][1].equals(alleles[1]) && IUB[i][2].equals(alleles[0]))
return IUB[i][0];
if( (IUB_2[i][1].equals(alleles[0]) && IUB_2[i][2].equals(alleles[1])) ||
(IUB_2[i][1].equals(alleles[1]) && IUB_2[i][2].equals(alleles[0])) )
return IUB_2[i][0];
}
}
if(isSNP && alleles.length == 3)
{
System.out.println(record.toString());
for(int i=0; i<IUB_3.length; i++)
{
if( (IUB_3[i][1].equals(alleles[0]) && IUB_3[i][2].equals(alleles[1]) && IUB_3[i][3].equals(alleles[2])) ||
(IUB_3[i][1].equals(alleles[1]) && IUB_3[i][2].equals(alleles[0]) && IUB_3[i][3].equals(alleles[2])) ||
(IUB_3[i][1].equals(alleles[2]) && IUB_3[i][2].equals(alleles[0]) && IUB_3[i][3].equals(alleles[1])) ||
(IUB_3[i][1].equals(alleles[2]) && IUB_3[i][2].equals(alleles[1]) && IUB_3[i][3].equals(alleles[0])) ||
(IUB_3[i][1].equals(alleles[0]) && IUB_3[i][2].equals(alleles[2]) && IUB_3[i][3].equals(alleles[1])) ||
(IUB_3[i][1].equals(alleles[1]) && IUB_3[i][2].equals(alleles[2]) && IUB_3[i][3].equals(alleles[0])))
return IUB_3[i][0];
}
}
if(isSNP)
return "n";
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment