aspose file tools*
The moose likes I/O and Streams and the fly likes How to extract columns of coordinate values from text file (in java) ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to extract columns of coordinate values from text file (in java) ?" Watch "How to extract columns of coordinate values from text file (in java) ?" New topic
Author

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

Jerri Loh
Ranch Hand

Joined: Jul 06, 2010
Posts: 31
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

Joined: Jul 06, 2010
Posts: 31
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

Joined: Oct 27, 2005
Posts: 19670
    
  18

Check out some of the nifty methods of java.lang.String. One of them returns a String[].


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jerri Loh
Ranch Hand

Joined: Jul 06, 2010
Posts: 31
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.




 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to extract columns of coordinate values from text file (in java) ?