History and technology will combine when scientists use Mary Queen of Scots' final letter to help revolutionise the way digital data is stored.

A team from Edinburgh University will use the treasured artefact to see if they can store it in a DNA sequence.

They will convert Mary Queen of Scots' last letter - written just hours before she was executed in 1587 - into "short molecular sequences" in DNA.

The National Library of Scotland has supplied the basic text of the letter to see if it can be coded, stored and then retrieved by the scientific team.

It is hoped the complex research will pave the way for large amounts of data being stored in a cheaper and more efficient way.

In theory, the text could then be safety stored for centuries to come in a method which is already being considered by software giant Microsoft.

The researchers say such a system would be capable of storing the entire Harry Potter book series 20 trillion times within a single gram of DNA.

These sequences can be rapidly assembled together in any order, using a method resembling a typewriter.

It is hoped the technology could also be used to digitally store images, music and other files, reducing the need for huge data centres that consume large amounts of energy.

The work is being carried out by the Edinburgh University undergraduate International Genetically Engineered Machine (iGEM) team, which includes students studying biology, computer science, psychology and chemistry.

Team member Brendan Largey said: "It is a real privilege to be allowed to use the basic text from the last letter of Mary Queen of Scots to test our DNA storage system.

"While there is increasing interest in using DNA in this way, our approach is unique in its security, modularity and affordability.

"We want our technology to be accessible not only to large scale companies but to anyone with long-term data storage needs."

Gill Hamilton, acting head of digital at the library, said: "We are delighted to be able to support this exciting Scottish-based research.

"Finding more effective solutions to data storage in the future is something that all libraries, organisations, companies and individuals have a strong interest in. We will be watching progress with much interest."

The research project is to be entered into an international competition in Boston in October.