• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to extract columns of coordinate values from text file (in java) ?

 
Jerri Loh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!

this an excerpt from an extracted pdb file in the format of a text file.

ATOM 1 N ASN A 2 18.668 27.299 52.379 1.00 41.19 N
ATOM 2 CA ASN A 2 19.400 26.674 53.492 1.00 40.18 C
ATOM 3 C ASN A 2 19.710 27.737 54.550 1.00 37.56 C
ATOM 4 O ASN A 2 19.123 27.737 55.640 1.00 38.90 O
ATOM 5 N LEU A 3 20.637 28.606 54.184 1.00 34.40 N

those in bold are the coordinates i need to extract and in the form of (x,y,z) down a long list.

Would greatly appreciate your help.

From my research it seems that i can't directly extract columns but i have to do a parsing and a split token. Could someone justify this?
 
Jerri Loh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have an idea in mind and that is to read the line by line as strings.. and split tokens.. den
it most probably come out as something like:

1ATOM
21
3N
4ASN
5A
62
718.668
827.299
952.379
101.00
1141.19
12N

so one line will become 12 tokens.

right. from here.. I do a loop that only reads in only every 7th to 9th token into a new text file. Can this be done? Kindly advise me. Thanks!
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out some of the nifty methods of java.lang.String. One of them returns a String[].
 
Jerri Loh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have come up with this but I am really lost because the classes and the methods are not integrated properly. can anybody help me to straighten my thoughts.




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic