Results 1 to 2 of 2
  1. #1
    yap_1991 is offline Member
    Join Date
    Apr 2010
    Posts
    19
    Rep Power
    0

    Default Data Extraction using JAVA

    Hi Everyone

    I need help in writing a program. Basically this program is supposed to open files dynamically from a folder and extract the parts that i need only.

    Currently what i have is only opening ONE file and only using one delimiter to start the extraction process which is a little off what I need and have to do.

    Would be great if I could get some help here.

    Below is the code that I already have:

    import java.util.Scanner;
    import java.io.*;


    public class Extraction
    {

    private static final String STREAM_NAME = "C:\Users\Royston\Desktop\Proteins\2RQW.pdb";

    public static void main(String[] args)
    {
    Scanner fileScan = null;
    String extraction = null;
    try
    {
    fileScan = new Scanner(Extraction.class.getResourceAsStream(STREA M_NAME));

    // apply the delimiter to the scanner reading the whole file
    fileScan.useDelimiter("MODEL 1");
    while (fileScan.hasNext())
    {
    extraction = fileScan.next();

    System.out.println("");
    System.out.println("");
    System.out.println("");
    System.out.println("Extraction Starts Here:");
    System.out.print(extraction);
    System.out.println("Extraction ENDS Here.");

    try{
    // Create file
    FileWriter fstream = new FileWriter("2RQWEXTRACTED.txt");
    BufferedWriter out = new BufferedWriter(fstream);
    out.write(extraction);
    //Close the output stream
    out.close();
    }catch (Exception e){//Catch exception if any
    System.err.println("Error: " + e.getMessage());
    }
    }
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }

    }
    }
    The part of the file I would need is all the lines starting after Model 1 provided if the last column on the right is NOT 'H' and the program should end once it meets ENDMDL. So, How would i need to modify my current program to suit what I need? Help pleaseee.
    MODEL 1
    ATOM 1 N SER A 253 -19.559 -25.512 -41.130 1.00 0.00 N
    ATOM 2 CA SER A 253 -18.749 -26.500 -41.895 1.00 0.00 C
    ATOM 3 C SER A 253 -17.587 -26.979 -41.032 1.00 0.00 C
    ATOM 4 O SER A 253 -16.504 -27.273 -41.538 1.00 0.00 O
    ATOM 5 CB SER A 253 -18.218 -25.843 -43.167 1.00 0.00 C
    ATOM 6 OG SER A 253 -17.271 -24.841 -42.819 1.00 0.00 O
    ATOM 7 H1 SER A 253 -18.928 -24.906 -40.567 1.00 0.00 H
    ATOM 8 H2 SER A 253 -20.212 -26.016 -40.494 1.00 0.00 H
    ATOM 9 H3 SER A 253 -20.104 -24.923 -41.790 1.00 0.00 H
    ATOM 10 HA SER A 253 -19.371 -27.344 -42.159 1.00 0.00 H
    ATOM 11 HB2 SER A 253 -17.735 -26.585 -43.786 1.00 0.00 H
    ATOM 12 HB3 SER A 253 -19.042 -25.399 -43.715 1.00 0.00 H
    ATOM 13 HG SER A 253 -16.398 -25.161 -43.058 1.00 0.00 H

    ATOM 14 N THR A 254 -17.819 -27.053 -39.724 1.00 0.00 N
    ATOM 15 CA THR A 254 -16.783 -27.498 -38.796 1.00 0.00 C
    ATOM 16 C THR A 254 -17.406 -28.192 -37.591 1.00 0.00 C
    ATOM 17 O THR A 254 -17.294 -29.409 -37.438 1.00 0.00 O
    ATOM 18 CB THR A 254 -15.954 -26.301 -38.324 1.00 0.00 C
    ATOM 19 OG1 THR A 254 -16.815 -25.333 -37.740 1.00 0.00 O
    ATOM 20 CG2 THR A 254 -15.220 -25.683 -39.514 1.00 0.00 C
    ATOM 21 H THR A 254 -18.700 -26.805 -39.377 1.00 0.00 H
    ATOM 22 HA THR A 254 -16.130 -28.193 -39.302 1.00 0.00 H
    ATOM 23 HB THR A 254 -15.233 -26.628 -37.592 1.00 0.00 H
    ATOM 24 HG1 THR A 254 -16.416 -25.036 -36.920 1.00 0.00 H
    ATOM 25 HG21 THR A 254 -14.730 -26.462 -40.078 1.00 0.00 H
    ATOM 26 HG22 THR A 254 -14.484 -24.980 -39.156 1.00 0.00 H
    ATOM 27 HG23 THR A 254 -15.928 -25.170 -40.148 1.00 0.00 H

    ATOM 28 N ALA A 255 -18.063 -27.413 -36.738 1.00 0.00 N
    TER 2254 ASP A 407
    ENDMDL
    MASTER 141 0 0 9 0 0 0 6 1137 1 0 12
    END

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

Similar Threads

  1. File Extraction using Java
    By yap_1991 in forum Advanced Java
    Replies: 7
    Last Post: 05-14-2010, 08:06 AM
  2. JAVA Video Extraction
    By KSadeck in forum Advanced Java
    Replies: 3
    Last Post: 01-08-2009, 07:43 AM
  3. web extraction
    By murali in forum Networking
    Replies: 3
    Last Post: 12-13-2008, 07:10 AM
  4. Replies: 0
    Last Post: 10-31-2008, 02:13 PM
  5. Replies: 1
    Last Post: 02-04-2008, 08:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •