In [2]:
from Bio import SeqIO

with open("outfile.txt","w") as f:
        for seq_record in SeqIO.parse("ex.fasta", "fasta"):
                f.write(str(seq_record.id) + "\n")
                f.write(str(seq_record.seq[:10]) + "\n")  #first 10 base positions
                f.write(str(seq_record.seq[-10:]) + "\n") #last 10 base positions

In [4]:
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
my_seq = Seq("GATCGATGGGCCTATATAGGATCGAAAATCGC", IUPAC.unambiguous_dna)

In [5]:
my_seq[2::3]


Out[5]:
Seq('TAGCTAAGAC', IUPACUnambiguousDNA())

In [19]:
from Bio import SeqIO
handle = open("ex.fasta")

with open("outfile.txt","w") as f:
    for seq_record in SeqIO.parse(handle, "fasta") :
        print ">" + seq_record.id
        temp = Seq(str(seq_record.seq), IUPAC.unambiguous_dna)
        #temp = repr(seq_record.seq)
        print temp[2::3]
handle.close()


>seq1
GC-CG
>seq2
GC-CG
>seq3
CC-CA

negative det


In [12]:
import numpy as np
from numpy.linalg import det

In [8]:
M = np.array([[0.479432691872114, 0.392059806042706, 0.0452005027651593, 0.0833069993200213],
[0.0285658985343881, 0.472147420543281, 0.499286677736459, 3.1858726379887e-09],
[3.1858726379887e-09, 0.499286677736459, 0.472147420543281, 0.0285658985343881],
[0.0833069993200213, 0.0452005027651593, 0.392059806042706, 0.479432691872114]])

In [13]:
det(M)


Out[13]:
-0.011035444827197738

In [ ]: