I'm trying to generate a test dataset of randomly sampled 150bp sequences from a complete genome. I found what appeared to be the perfect Biopython script on the SeqIO Wiki page (http://biopython.org/wiki/SeqIO#Randomsubsequences) but genomefrags.append(record) throws an Attribute error that 'Seq' object has no attribute append. I'm not sure why this script is listed if that is really the case unless this is an issue with my current version of Biopython (1.52) which I run off my work server (so it would take some work to get it updated). The Biopython Tutorial and Cookbook says that Seq object could only be added starting with version 1.53 but adding is more of a concatenation, not an appending of separate objects into a single file. Does anyone know a way around this keeping in mind that I can write very minimal code at this point?
genome_frags=[]
limit=len(genome_record.seq)
for i in range(0, 1000) :
start=randint(0,limit-150)
end=start+150
genome_frags=genome_record.seq[start:end]
print (type(genome_frags))
record=SeqRecord(genome_frags,'fragment_%i' % (i+1),'','')
genome_frags.append(record)
Do you want a list of SeqRecords, each containing a random sample or one long SeqRecord made of those random samples?