[Biopython-dev] [Bug 2381] translate and transcibe methods for the Seq object (in Bio.Seq)

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Thu Nov 6 17:11:26 UTC 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2381





------- Comment #47 from biopython-bugzilla at maubp.freeserve.co.uk  2008-11-06 12:11 EST -------
(In reply to comment #46)
> If you only wanted the conceptual translations of sequences that fit the
> criteria for a CDS, then a one-liner to replace
> 
> [seq.translate(cds=True) for seq in seqlist]
> 
> might be
> 
> [seq.translate() for seq in seqlist if seq.is_cds()]
> 
> I prefer the second option, for readability, but YMMV.
> 

Note the above wouldn't give you translations starting with methionine, you'd
need something like:

[seq.translate(cds_start=True) for seq in seqlist if seq.is_cds()]

(assuming we call the "init" option "cds_start")

Or, going with the complete_cds option you could build a list of translations
of valid CDSs like this:

proteins = []
for seq in seqlist :
    try :
        proteins.append(seq.translate(complete_cds=True))
    except ValueError :
        #Not a valid CDS, excluded
        pass

Not a one liner, but I think in a real situation you'd want to do something
with the invalid CDSs anyway (even if just logging them).


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list