import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.datamodel.features.SequenceFeatures;
+import jalview.io.gff.Gff3Helper;
import jalview.io.gff.SequenceOntologyI;
import jalview.schemes.ResidueProperties;
import jalview.util.Comparison;
{
return variant == null ? null : variant.getFeatureGroup();
}
+
+ /**
+ * toString for aid in the debugger only
+ */
+ @Override
+ public String toString()
+ {
+ return base + ":" + (variant == null ? "" : variant.getDescription());
+ }
}
/**
AlignmentI dataset, SequenceI[] products)
{
if (dataset == null || dataset.getDataset() != null)
- {
+ {
throw new IllegalArgumentException(
"IMPLEMENTATION ERROR: dataset.getDataset() must be null!");
}
{
productSeqs = new HashSet<SequenceI>();
for (SequenceI seq : products)
- {
- productSeqs.add(seq.getDatasetSequence() == null ? seq
- : seq.getDatasetSequence());
- }
+ {
+ productSeqs.add(seq.getDatasetSequence() == null ? seq : seq
+ .getDatasetSequence());
+ }
}
/*
List<AlignedCodonFrame> seqMappings = MappingUtils
.findMappingsForSequence(dnaSeq, mappings);
for (AlignedCodonFrame mapping : seqMappings)
- {
+ {
List<Mapping> mappingsFromSequence = mapping
.getMappingsFromSequence(dnaSeq);
for (Mapping aMapping : mappingsFromSequence)
- {
+ {
MapList mapList = aMapping.getMap();
if (mapList.getFromRatio() == 1)
- {
+ {
/*
* not a dna-to-protein mapping (likely dna-to-cds)
*/
if (cdsSeq != null)
{
if (!foundSeqs.contains(cdsSeq))
- {
+ {
foundSeqs.add(cdsSeq);
SequenceI derivedSequence = cdsSeq.deriveSequence();
cdsSeqs.add(derivedSequence);
if (!dataset.getSequences().contains(cdsSeq))
- {
+ {
dataset.addSequence(cdsSeq);
- }
}
+ }
continue;
}
/*
* add a mapping from CDS to the (unchanged) mapped to range
*/
- List<int[]> cdsRange = Collections
- .singletonList(new int[]
- { 1, cdsSeq.getLength() });
+ List<int[]> cdsRange = Collections.singletonList(new int[] { 1,
+ cdsSeq.getLength() });
MapList cdsToProteinMap = new MapList(cdsRange,
mapList.getToRanges(), mapList.getFromRatio(),
mapList.getToRatio());
for (DBRefEntry primRef : dnaDss.getPrimaryDBRefs())
{
- // creates a complementary cross-reference to the source sequence's
- // primary reference.
-
- DBRefEntry cdsCrossRef = new DBRefEntry(primRef.getSource(),
- primRef.getSource() + ":" + primRef.getVersion(),
- primRef.getAccessionId());
- cdsCrossRef
- .setMap(new Mapping(dnaDss, new MapList(dnaToCdsMap)));
+ /*
+ * create a cross-reference from CDS to the source sequence's
+ * primary reference and vice versa
+ */
+
+ String source = primRef.getSource();
+ String version = primRef.getVersion();
+ DBRefEntry cdsCrossRef = new DBRefEntry(source, source + ":"
+ + version, primRef.getAccessionId());
+ cdsCrossRef.setMap(new Mapping(dnaDss, new MapList(dnaToCdsMap
+ .getInverse())));
cdsSeqDss.addDBRef(cdsCrossRef);
+ dnaSeq.addDBRef(new DBRefEntry(source, version, cdsSeq
+ .getName(), new Mapping(cdsSeqDss, dnaToCdsMap)));
+
// problem here is that the cross-reference is synthesized -
// cdsSeq.getName() may be like 'CDS|dnaaccession' or
// 'CDS|emblcdsacc'
// assuming cds version same as dna ?!?
- DBRefEntry proteinToCdsRef = new DBRefEntry(primRef.getSource(),
- primRef.getVersion(), cdsSeq.getName());
+ DBRefEntry proteinToCdsRef = new DBRefEntry(source, version,
+ cdsSeq.getName());
//
- proteinToCdsRef.setMap(
- new Mapping(cdsSeqDss, cdsToProteinMap.getInverse()));
+ proteinToCdsRef.setMap(new Mapping(cdsSeqDss, cdsToProteinMap
+ .getInverse()));
proteinProduct.addDBRef(proteinToCdsRef);
- }
+ }
/*
* transfer any features on dna that overlap the CDS
*/
transferFeatures(dnaSeq, cdsSeq, dnaToCdsMap, null,
SequenceOntologyI.CDS);
- }
}
}
+ }
- AlignmentI cds = new Alignment(
- cdsSeqs.toArray(new SequenceI[cdsSeqs.size()]));
+ AlignmentI cds = new Alignment(cdsSeqs.toArray(new SequenceI[cdsSeqs
+ .size()]));
cds.setDataset(dataset);
return cds;
{
if (var.variant != null)
{
- String alleles = (String) var.variant.getValue("alleles");
+ String alleles = (String) var.variant.getValue(Gff3Helper.ALLELES);
if (alleles != null)
{
for (String base : alleles.split(","))
{
if (var.variant != null)
{
- String alleles = (String) var.variant.getValue("alleles");
+ String alleles = (String) var.variant.getValue(Gff3Helper.ALLELES);
if (alleles != null)
{
for (String base : alleles.split(","))
{
if (var.variant != null)
{
- String alleles = (String) var.variant.getValue("alleles");
+ String alleles = (String) var.variant.getValue(Gff3Helper.ALLELES);
if (alleles != null)
{
for (String base : alleles.split(","))
/**
* Builds a map whose key is position in the protein sequence, and value is a
- * list of the base and all variants for each corresponding codon position
+ * list of the base and all variants for each corresponding codon position.
+ * <p>
+ * This depends on dna variants being held as a comma-separated list as
+ * property "alleles" on variant features.
*
* @param dnaSeq
* @param dnaToProtein
// not handling multi-locus variant features
continue;
}
+
+ /*
+ * ignore variant if not a SNP
+ */
+ String alls = (String) sf.getValue(Gff3Helper.ALLELES);
+ if (alls == null)
+ {
+ continue; // non-SNP VCF variant perhaps - can't process this
+ }
+
+ String[] alleles = alls.toUpperCase().split(",");
+ boolean isSnp = true;
+ for (String allele : alleles)
+ {
+ if (allele.trim().length() > 1)
+ {
+ isSnp = false;
+ }
+ }
+ if (!isSnp)
+ {
+ continue;
+ }
+
int[] mapsTo = dnaToProtein.locateInTo(dnaCol, dnaCol);
if (mapsTo == null)
{
}
/*
- * extract dna variants to a string array
- */
- String alls = (String) sf.getValue("alleles");
- if (alls == null)
- {
- continue;
- }
- String[] alleles = alls.toUpperCase().split(",");
- int i = 0;
- for (String allele : alleles)
- {
- alleles[i++] = allele.trim(); // lose any space characters "A, G"
- }
-
- /*
* get this peptide's codon positions e.g. [3, 4, 5] or [4, 7, 10]
*/
int[] codon = peptidePosition == lastPeptidePostion ? lastCodon