Browse Source

extra/biopython: Patched GenBankWriter to support features.

slackware-14.2
Damien Goutte-Gattat 13 years ago
parent
commit
4225f4108a
  1. 1
      extra/biopython/biopython.SlackBuild
  2. 53
      extra/biopython/fix-genbank-writer.diff

1
extra/biopython/biopython.SlackBuild

@ -76,6 +76,7 @@ cd $TMP
echo "Building $ARCHIVE..."
tar xf $CWD/$ARCHIVE
cd $NAME
patch -p 1 < $CWD/fix-genbank-writer.diff
CFLAGS=$CPUOPT \
CXXFLAGS=$CPUOPT \
python setup.py build

53
extra/biopython/fix-genbank-writer.diff

@ -0,0 +1,53 @@
diff -Naur biopython-1.50b.orig/Bio/SeqIO/InsdcIO.py biopython-1.50b/Bio/SeqIO/InsdcIO.py
--- biopython-1.50b.orig/Bio/SeqIO/InsdcIO.py 2009-04-01 12:08:06.000000000 +0200
+++ biopython-1.50b/Bio/SeqIO/InsdcIO.py 2009-04-07 14:05:01.000000000 +0200
@@ -29,6 +29,7 @@
from Bio.GenBank.Scanner import GenBankScanner, EmblScanner
from Bio import Alphabet
from Interfaces import SequentialSequenceWriter
+from Bio import SeqFeature
# NOTE
# ====
@@ -139,9 +140,9 @@
if not isinstance(a, Alphabet.Alphabet) :
raise TypeError("Invalid alphabet")
elif isinstance(a, Alphabet.ProteinAlphabet) :
- units = "bp"
- elif isinstance(a, Alphabet.NucleotideAlphabet) :
units = "aa"
+ elif isinstance(a, Alphabet.NucleotideAlphabet) :
+ units = "bp"
else :
#Must be something like NucleotideAlphabet or
#just the generic Alphabet (default for fasta files)
@@ -303,12 +304,23 @@
handle.write("//\n")
def _write_feature(self, feature):
- """Write a single SeqFeature object to features table.
-
- Not implemented yet, but this stub exists in the short term to
- facilitate working on writing GenBank files with a sub-class."""
- #TODO - Features...
- pass
+ """Write a single SeqFeature object to features table."""
+
+ if not isinstance(feature.location._start, SeqFeature.ExactPosition):
+ return
+ if not isinstance(feature.location._end, SeqFeature.ExactPosition):
+ return
+ start = feature.location._start.position + 1
+ end = feature.location._end.position
+ if feature.strand == -1:
+ loc = "complement(%i..%i)" % (start, end)
+ else:
+ loc = "%i..%i" % (start, end)
+ self.handle.write(" %-16s%s\n" % (feature.type, loc))
+ for q in feature.qualifiers.keys():
+ for val in feature.qualifiers[q]:
+ self.handle.write(" /%s=\"%s\"\n" % \
+ (q, val))
if __name__ == "__main__" :
print "Quick self test"
Loading…
Cancel
Save