• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.




 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic