Skip to content

Instantly share code, notes, and snippets.

@kellyrob99
Created October 16, 2011 22:16
Show Gist options
  • Save kellyrob99/1291497 to your computer and use it in GitHub Desktop.
Save kellyrob99/1291497 to your computer and use it in GitHub Desktop.
BioGroovy reading fasta file
@GrabResolver(name='biojava', root='http://www.biojava.org/download/maven/')
@Grab('org.biojava:biojava3-core:3.0.2')
import org.biojava3.core.sequence.*
import org.biojava3.core.sequence.io.*
import org.biojava3.core.sequence.compound.*
def testFasta = '''> seq1 This is the description of my first sequence.
AGTACGTAGTAGCTGCTGCTACGTGCGCTAGCTAGTACGTCA
CGACGTAGATGCTAGCTGACTCGATGC
> seq2 This is a description of my second sequence.
CGATCGATCGTACGTCGACTGATCGTAGCTACGTCGTACGTAG
CATCGTCAGTTACTGCATGCTCG'''
File file = new File("${System.properties['java.io.tmpdir']}/tempFasta.fasta");
file.text = testFasta
fastaProxyReader = new FastaReader(file, new GenericFastaHeaderParser(), new FileProxyProteinSequenceCreator(file, AminoAcidCompoundSet.getAminoAcidCompoundSet()));
fastaProxyReader.process().each{
println it.key
println it.value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment