In R:
Example file with sequences:
> gene1
ACATATTGGAGGCCGAAACAATGAGGCGTGATCAACTCAGTATATCAC
> gene2
CTAACCTCTCCCAGTGTGGAACCTCTATCTCATGAGAAAGCTGGGATGAG
> gene3
ATTTCCTCCTGCTGCCCGGGAGGTAACACCCTGGACCCCTGGAGTCTGCA
1) Extract 1/3 of each sequence and store each 1/3 as individual sequence, in a single fasta file i.e new fasta file will have new 3 sequences, but with first 1/3 of each sequence . Source file is named genes.fa and new file is named subgenes.fa
$ library(Biostrings)
$ genes=readDNAStringSet("genes.fa", format = "fasta")
$ subfasta=subseq(genes,1,ceiling(width(genes)/3))
$ writeXStringSet(subfasta, "subgenes.fa")
2) Extract 1/3 of from each sequence, combine all first 1/3 sequences as a single sequence and store it as a single sequence in a fasta format . Source file is named genes.fa and new file is named "new_gene.fasta". New sequence will have an ID "new_gene".
$ library(Biostrings)
$ genes=readDNAStringSet("genes.fa", format = "fasta")
$ subfasta=subseq(genes,1,ceiling(width(genes)/3))
$ csubfasta=DNAStringSet(unlist(subfasta))
$ names(csubfasta)="new_gene"
$ writeXStringSet(DNAStringSet(csubfasta),"new_gene.fasta")
Cut them into three new fasta sequences or else? Are all sequences the same length?