将一个或多个序列写入FASTA格式的文件中,包括核酸序列和氨基酸序列。在R语言中,需要seqinr package。
代码如下:
write.fasta(sequences, names, file.out, open = "w", nbchar = 60, as.string = FALSE)
write.fasta() 参数:
参数 | 功能 |
---|---|
sequences | DNA或蛋白质序列(默认为单个字符的载体形式)或此类序列的列表 |
names | 序列的名称 |
file.out | 输出文件的名称 |
open | 打开输出文件的模式,使用“w”写入新文件,使用“a”将序列追加在已存在文件的末尾 |
nbchar | 每行的字符数(默认值:60) |
as.string | 默认为FALSE。设置为TRUE时,序列采用字符串形式而不是单个字符的向量 |
write.fasta() 函数实例:
实例采用 Mycobacterium tuberculosis (strain ATCC 25618 / H37Rv) 的relA蛋白,其序列如下:MTAQRSTTNPVLEPLVAVHREIYPKADLSILQRAYEVADQRHASQLRQSGDPYITHPLAVANILAELGMDTTTLVAALLHDTVEDTGYTLEALTEEFGEEVGHLVDGVTKLDRVVLGSAAEGETIRKMITAMARDPRVLVIKVADRLHNMRTMRFLPPEKQARKARETLEVIAPLAHRLGMASVKWELEDLSFAILHPKKYEEIVRLVAGRAPSRDTYLAKVRAEIVNTLTASKIKATVEGRPKHYWSIYQKMIVKGRDFDDIHDLVGVRILCDEIRDCYAAVGVVHSLWQPMAGRFKDYIAQPRYGVYQSLHTTVVGPEGKPLEVQIRTRDMHRTAEYGIAAHWRYKEAKGRNGVLHPHAAAEIDDMAWMRQLLDWQREAADPGEFLESLRYDLAVQEIFVFTPKGDVITLPTGSTPVDFAYAVHTEVGHRCIGARVNGRLVALERKLENGEVVEVFTSKAPNAGPSRDWQQFVVSPRAKTKIRQWFAKERREEALETGKDAMAREVRRGGLPLQRLVNGESMAAVARELHYADVSALYTAIGEGHVSAKHVVQRLLAELGGIDQAEEELAERSTPATMPRRPRSTDDVGVSVPGAPGVLTKLAKCCTPVPGDVIMGFVTRGGGVSVHRTDCTNAASLQQQAERIIEVLWAPSPSSVFLVAIQVEALDRHRLLSDVTRALADEKVNILSASVTTSGDRVAISRFTFEMGDPKHLGHLLNAVRNVEGVYDVYRVTSAA
将此序列命名为MTrelA,fasta文件命名为MTrelA.fasta
输入代码:
library(seqinr)
seq<-c('MTAQRSTTNPVLEPLVAVHREIYPKADLSILQRAYEVADQRHASQLRQSGDPYITHPLAVANILAELGMDTTTLVAALLHDTVEDTGYTLEALTEEFGEEVGHLVDGVTKLDRVVLGSAAEGETIRKMITAMARDPRVLVIKVADRLHNMRTMRFLPPEKQARKARETLEVIAPLAHRLGMASVKWELEDLSFAILHPKKYEEIVRLVAGRAPSRDTYLAKVRAEIVNTLTASKIKATVEGRPKHYWSIYQKMIVKGRDFDDIHDLVGVRILCDEIRDCYAAVGVVHSLWQPMAGRFKDYIAQPRYGVYQSLHTTVVGPEGKPLEVQIRTRDMHRTAEYGIAAHWRYKEAKGRNGVLHPHAAAEIDDMAWMRQLLDWQREAADPGEFLESLRYDLAVQEIFVFTPKGDVITLPTGSTPVDFAYAVHTEVGHRCIGARVNGRLVALERKLENGEVVEVFTSKAPNAGPSRDWQQFVVSPRAKTKIRQWFAKERREEALETGKDAMAREVRRGGLPLQRLVNGESMAAVARELHYADVSALYTAIGEGHVSAKHVVQRLLAELGGIDQAEEELAERSTPATMPRRPRSTDDVGVSVPGAPGVLTKLAKCCTPVPGDVIMGFVTRGGGVSVHRTDCTNAASLQQQAERIIEVLWAPSPSSVFLVAIQVEALDRHRLLSDVTRALADEKVNILSASVTTSGDRVAISRFTFEMGDPKHLGHLLNAVRNVEGVYDVYRVTSAA
')
SeqName<-c('MTrelA')
write.fasta(seq, names=SeqName, file='MTrelAseq1.fasta', open='w', nbchar=60,
as.string = FALSE)
输出结果:
MTrelA.fasta文件文本打开MTrelA.fasta文件
网友评论