Oh, I forgot I should instanciate a PDBFileParser, so the following codeworks
fine:
public static Object parse_pdb(String pdb_datafile, String pdb_id) {
Structure structure = null; pdb_inputstream =
Utils.get_pdbinputstream(pdb_datafile,pdb_id); PDBFileParser
pdbfileparser = new PDBFileParser(); try { if (pdb_inputstream
!= null) structure = pdbfileparser.parsePDBFile(pdb_inputstream);
} catch (IOException ioe) {System.out.println(ioe);}
return structure; }
On 11/30/05, Tamas Horvath <[EMAIL PROTECTED]> wrote:>> In my case, I had a
bunch of pdb files in a jar archive, so here's the> code I try to use:>>
public static InputStream get_pdbinputstream(String fileName,String> pdb_id) {>
System.out.println(fileName);> InputStream returnstream =
null;> JarFile jarFile = null;> try {>
jarFile = new JarFile(fileName);> for (Enumeration e =
jarFile.entries(); e.hasMoreElements();) {>> JarEntry
jarEntry = (JarEntry) e.nextElement();>> if
(jarEntry.isDirectory()) continue;>> String pdbid =
jarEntry.getName();> pdbid = pdbid.substring(0,
4).toUpperCase();> System.out.println(pdbid);>
if (pdbid.intern() != pdb_id) continue;>> returnstream
= jarFile.getInputStream(jarEntry);> }> } catch
(IOException ioe) {> !
System.out.println("An IOException occurred: " +>
ioe.getMessage());> } finally {> if (jarFile !=
null) {> try { jarFile.close(); } catch (IOException ioe) {}>
}> }> return returnstream;> }>>
public static Object parse_pdb(String pdb_datafile, String pdb_id) {>
Structure structure = null;> pdb_inputstream =
Utils.get_pdbinputstream(pdb_datafile,pdb_id);> if (pdb_inputstream !=
null) structure = org.biojava.bio.structure.io>
.PDBFileParser.parsePDBFile(pdb_inputstream);> return structure;> }>>
The 1st function is supposed to get the desired InputStream from the> specified
archive file, while the second supposed to generate the structure.> However:>>
"Utils.java": non-static method parsePDBFile(java.io.InputStream) cannot> be
referenced from a static context at line 1132, column 92> as it kindly
sais...>> Is there a solution of this problem?>>> On!
11/30/05, Andreas Prlic < [EMAIL PROTECTED]> wrote:>> > Hi Tamas,> >> > In
case you are working with a PDB file that is located> > somewhere on your hard
disk, you could use the code from below> > to parse it in.> >> > Cheers,> >
Andreas> >> >> > String filename = "path/to/pdbfile.ent" ;> >> >
PDBFileReader pdbreader = new PDBFileReader();> >> > try{> >
Structure struc = pdbreader.getStructure(filename);> >
System.out.println(struc);> > } catch (Exception e) {> >
e.printStackTrace();> > }> >> >> >> > On 29 Nov 2005, at 16:25, Tamas Horvath
wrote:> >> > > I've got an ArrayList<String> object containing a PDB file's> >
> information.How may I feed it to the structure parser? As far as I> > > could
see, it onlyaccepts BufferdReader or imputStream...> >> >> > >
----------------------------------------------------------------------> >> >
Andreas Prlic Wellcome Trust Sanger Institute> >
Hinxton, Cambridge CB10 1!
SA, UK> > +44 (0) 1223 49 6891> >> >
_______________________________________________> > Biojava-l mailing list -
Biojava-l@biojava.org> > http://biojava.org/mailman/listinfo/biojava-l> >>>
_______________________________________________
Biojava-l mailing list - Biojava-l@biojava.org
http://biojava.org/mailman/listinfo/biojava-l