Reputation: 2974
I have a ruby script that creates a HTML file as the output with certain letters coloured.
e.g.
<p>
<b>>aug3me.g5.t1</b> has a signal p with a cleavage site between positions 19 and 20.<br>
<b class="SignalP">MLRSMMLMIAMGCFLNAFG</b>QSGQELE<b class="motif_site">KR</b>VI<b class="motif_site">KNAR</b>QLIYEG<b class="motif_site">KR</b>SGEGYFSKDGK<b class="motif_site">HLIFQSER</b>EEENPYYQIYILDLESGDINRVSPGQGKTTCSYFDWSSDNNVLFGSTHHDPKAKEKQQAELDF<b class="motif_site">RASGKKRR</b>YSWDYDKEMDIFSAN<b class="motif_site">RDGSNVKR</b>ITTEEGYDAEGSYSPDG<b class="motif_site">KK</b>IAFCSLRDAYN<b class="motif_site">KK</b>LSEKEIKTLEVDAAYFGEIYIMDADGSNQ<b class="motif_site">KR</b>LTNVPEPVRITHTDGFDGLPVFSPNGKNIAWTSVRTSD<b class="motif_site">KK</b>SQIFYASWDHQAALSLLKQAPAKGQDAKDPNFTGEIKSDEIKSKVAYLASDELEGRMTGSEGI<b class="motif_site">KK</b>ASDYITGQF<b class="motif_site">KK</b>IGLNSIESREEYLQEFPFVSSVEVNAAGTSFSTTN<b class="motif_site">KK</b>KPKAWVLYENFVPLPFSMNGEFEGEVVFAGYGIKTPDKSEVEYNSYANIEVKDKAVMILFDVPPHFNDDEEKELI<b class="motif_site">RYASPR</b>Y<b class="motif_site">KALVAR</b>ELGAKAVIFISE<b class="motif_site">REREFR</b>GVSKDNVPGNAGILALKVKSDLANEMLKSKETDFEKVKTQFENYNPHSENEFPLPGQTIGITTQLDKVESSDNNVIGILYADEPTDHYLMVGAHYD<b class="motif_site">HLGR</b>GEAGTLAHGEEKEEIHNGADDNASGTAAVMELAEYFVQLKNENPGSLTKNLLFALWSGEEMGLVGSAHYTKQSSKEIEGMDAYLNFDMIGMLNDNKLILQGLGSSPAWNKIVE<b class="motif_site">KK</b>NVAAGFDLTLQDDPYVPTDGMSFYQAGVPMLCFFSGIHDYYH<b class="motif_site">KPTDDIER</b>LNYEGAERIIKFSAEIIKELMKVDTLAYA<b class="motif_site">KVEMVKNR</b>AAGSKGFSVYLGTIPDYVAEVEGV<b class="motif_site">KLSGVR</b>AGGPAEKAVFRPN<b class="motif_site">KALR</b>LYGLNPLRGPH
</p>
With the above sequence, certain residues (letters) are coloured in colour or another etc.
I need to make a script that makes a text file of some kind (ideally a .doc file) that has all these formattings.
Is it possible to make a script to create a word document with formatting. If so, how would I approach this?
Upvotes: 0
Views: 104
Reputation: 3596
Yes, it is possible. There is the hard way and the easy way.
Hard Way
Use can create a Microsft Word document using WordprocessingML. I have done this in the past using an XML style sheet to transform XML output into a template, also in C# to build them from scratch. (see http://msdn.microsoft.com/en-us/library/office/aa212812(v=office.11).aspx & http://msdn.microsoft.com/en-us/library/bb264572(v=office.12).aspx for more details on the format).
If you can create a template with the styles you need in Word. Change the extension to .zip
and unpack. document.xml
is the document, that can give you your base XML file to work with.
Easy Way
If the html file is 'stand alone', contains all the styles required, the you can cheat and just give the html file a .doc
extention. Word will render the HTML as a word document.
Upvotes: 1