def loadPecan(iFileHandle, renamer=firstWord): """ Load pecan alignment data. """ aln = Alignment() for h, s in FastaFile(iFileHandle): try: aln.add(renamer(h), s) except Exception, e: print e
#!/usr/bin/env python """ testTextIndex.py Author: Tony Papenfuss Date: Thu May 29 11:44:36 EST 2008 """ import os, sys from fasta import FastaFile filename = 'tumour_sample.fa' f = FastaFile(filename, indexed=True, clobber=True, method='pickle')
end = int(tokens[7]) strand = {'1': '+', '-1': '-'}[tokens[8]] try: for contig in contigData[chrom].find(start-500, end+500): annotated.add(contig.value[0]) except: pass print 'Parse toxprot alignments' iFilename = '../toxprot/tblastn_toxprot_v_genome.txt' for b in BlastFile(iFilename): chrom = b.subjectId.split(':')[0] try: for contig in contigData[chrom].find(b.sStart, b.sEnd): annotated.add(contig.value[0]) except: pass print "Write out what's left over" writer = FastaFile('unannotated_contigs.fa', 'w') for chrom in contigData: for contig in contigData[chrom].intervals: if not contig.value[0] in annotated and len(contig.value[4])>60: name,chrom,start,end,seq = contig.value writer('%s %s:%i-%i' % (name,chrom,start,end), seq) writer.close()
def saveFasta(self, oFileHandle, **kw): writer = FastaFile(oFileHandle, 'w') for name in self.order: writer.write(name, self.seqDict[name]) writer.close()
Author: Tony Papenfuss Date: Tue Mar 18 14:27:10 EST 2008 """ import os, sys def rule(): print '-' * 80 from fasta import FastaFile f = FastaFile('HSP100.fa') rule() print 'readOne' print f.readOne() print f.readOne() rule() print 'readAll' print f.readAll() rule() print 'Mapping' f.asMapping() print f rule() rule()
Author: Tony Papenfuss Date: Tue Mar 18 14:27:10 EST 2008 """ import os, sys def rule(): print '-'*80 from fasta import FastaFile f = FastaFile('HSP100.fa') rule() print 'readOne' print f.readOne() print f.readOne() rule() print 'readAll' print f.readAll() rule() print 'Mapping' f.asMapping() print f rule() rule()
#!/usr/bin/env python """ testTextIndex.py Author: Tony Papenfuss Date: Thu May 29 11:44:36 EST 2008 """ import os, sys from fasta import FastaFile filename = 'tumour_sample.fa' f = FastaFile(filename, indexed=True, clobber=False, method='db') x = f[9000:9100]
#!/usr/bin/env python """ testTextIndex.py Author: Tony Papenfuss Date: Thu May 29 11:44:36 EST 2008 """ import os, sys from fasta import FastaFile filename = '/Users/papenfuss/databases/devil/transcriptome/reads/combined.fa' f = FastaFile(filename, indexed=True, clobber=True, method='text')