This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Transform A Location-Type Coordinate Into Integer Or String?

I have set of SecRecord objects with SeqFeature.location.start and I want to transform this coordinate into integer to compare to other sets of coordinates, add shifts etc.. How can I do that? I have read Biopython cookbook, but I still can't solve the problem.

biopython
start = int(str(seqRecord.features[0].location.start))

Well, I converted it first into string, then into integer, is there a more elegant solution?

can you give more of your code?

In the soon to be released Biopython 1.59 the position objects will be subclasses of int, so you won't need to do anything.

2 answers

I think you need to get the position of the start.

So if currFeat is a SeqFeature from your SeqRecord object:

location = currFeat.location

start = location.start.position

end = location.end.position

start and end should be integers.

Exactly - although in the soo to be released Biopython 1.59 the position objects will subclass int so you can use them directly.

I apologize for revealing this ancient thread, but since the discussion is listed among search results for the question, some updates are required. In the current biopython, one should use

start = int(feature.location.start)

The feature.location.start.position is now abandoned as well feature.location.end.position.

Best regards

Asan

Log in to answer this question.