Wolfram Research

Function Repository Resource:

AlignmentToPositionDifferences

Source Notebook

Convert a sequence alignment to a list of positional differences from the first sequence to the second

Contributed by: John Cassel, Wolfram|Alpha Scientific Content

ResourceFunction["AlignmentToPositionDifferences"][alignment]

takes an alignment between two sequences and returns the positions and rules that allow the first sequence to be converted to the second.

Details

As the input to this function, an alignment is a list of successive matching and differing sequences. See SequenceAlignment for further documentation and examples.

Examples

Reduce the result of a sequence alignment to only the positions that have been changed:

In[1]:=
ResourceFunction[
 "AlignmentToPositionDifferences"][{"A", {"B", "C"}, "D"}]
Out[1]=

Scope (1) 

Process the result of a sequence alignment directly:

In[2]:=
ResourceFunction["AlignmentToPositionDifferences"][
 SequenceAlignment["CCGCGAGCG", "ACGCTAGTT"]]
Out[2]=

Properties and Relations (1) 

The resource function ReconstituteSequenceFromReferenceDifferences restores sequences from the positional differences produced by this sequence:

In[3]:=
ResourceFunction["ReconstituteSequenceFromReferenceDifferences"][
 ResourceFunction["AlignmentToPositionDifferences"][
  SequenceAlignment["CCGCGAGCG", "ACGCTAGTT"]], "CCGCGAGCG"]
Out[3]=

Neat Examples (1) 

Find the differences with the COVID-19 reference sequence for a reported variant:

In[4]:=
ResourceFunction["AlignmentToPositionDifferences"][
 ResourceFunction["AlignNearlyIdenticalSequences"][
  ResourceData["Genetic Sequences for the SARS-CoV-2 Coronavirus", "ReferenceBioSequence"],
  BioSequence["DNA", ResourceFunction["ImportFASTA"]["MW850352"][[2, 1]]]
  ]
 ]
Out[4]=

Version History

  • 1.0.0 – 13 April 2021

Related Resources

License Information