Skip to content

Commit 5764804

Browse files
committed
fixing formatting issues
1 parent 5aaf98c commit 5764804

File tree

2 files changed

+121
-100
lines changed

2 files changed

+121
-100
lines changed

_wikis/BioJava:CookBook3:ModFinder.md

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,34 @@ part of them.
1515
Example: identify and print all preloaded modifications from a structure
1616
------------------------------------------------------------------------
1717

18-
```java Set<ModifiedCompound> identifyAllModfications(Structure struc) {
18+
```java
1919

20-
`   ProteinModificationIdentifier parser = new ProteinModificationIdentifier();`
21-
`   parser.identify(struc);`
22-
`   Set`<ModifiedCompound>` mcs = parser.getIdentifiedModifiedCompound();`
23-
`   return mcs;`
20+
Set<ModifiedCompound> identifyAllModfications(Structure struc) {
2421

25-
} ```
22+
   ProteinModificationIdentifier parser = new ProteinModificationIdentifier();
23+
   parser.identify(struc);
24+
   Set`<ModifiedCompound> mcs = parser.getIdentifiedModifiedCompound();
25+
   return mcs;
26+
27+
}
28+
```
2629

2730
Example: identify phosphorylation sites in a structure
2831
------------------------------------------------------
2932

3033
```java List<ResidueNumber> identifyPhosphosites(Structure struc) {
3134

32-
`   List`<ResidueNumber>phosphosites = new ArrayList`<ResidueNumber>`();`
33-
`   ProteinModificationIdentifier parser = new ProteinModificationIdentifier();`
34-
`   parser.identify(struc, ProteinModificationRegistry.getByKeyword("phosphoprotein"));`
35-
`   Set`<ModifiedCompound>mcs = parser.getIdentifiedModifiedCompound();`
36-
  for (ModifiedCompound mc : mcs) {`
37-
`       Set`<StructureGroup>groups = mc.getGroups(true);`
38-
      for (StructureGroup group : groups) {`
39-
`           phosphosites.add(group.getPDBResidueNumber());`
40-
      }`
41-
  }`
42-
`   return phosphosites;`
35+
  List`<ResidueNumber> phosphosites = new ArrayList`<ResidueNumber>`();
36+
  ProteinModificationIdentifier parser = new ProteinModificationIdentifier();
37+
  parser.identify(struc, ProteinModificationRegistry.getByKeyword("phosphoprotein"));
38+
  Set`<ModifiedCompound> mcs = parser.getIdentifiedModifiedCompound();
39+
  for (ModifiedCompound mc : mcs) {`
40+
      Set`<StructureGroup> groups = mc.getGroups(true);
41+
      for (StructureGroup group : groups) {`
42+
          phosphosites.add(group.getPDBResidueNumber());
43+
      }`
44+
  }`
45+
  return phosphosites;
4346

4447
} ```
4548

@@ -53,28 +56,28 @@ org.biojava.nbio.protmod.structure.ProteinModificationIdentifier;
5356

5457
public static void main(String[] args) {
5558

56-
  try {`
57-
`       PDBFileReader reader = new PDBFileReader();`
58-
`       reader.setAutoFetch(true);`
59-
60-
      // identify all modificaitons from PDB:1CAD and print them`
61-
`       String pdbId = "1CAD";`
62-
`       Structure struc = reader.getStructureById(pdbId);`
63-
`       Set`<ModifiedCompound>mcs = identifyAllModfications(struc);`
64-
      for (ModifiedCompound mc : mcs) {`
65-
`           System.out.println(mc.toString());`
66-
      }`
67-
68-
      // identify all phosphosites from PDB:3MVJ and print them`
69-
`       pdbId = "3MVJ";`
70-
`       struc = reader.getStructureById(pdbId);`
71-
`       List`<ResidueNumber>psites = identifyPhosphosites(struc);`
72-
      for (ResidueNumber psite : psites) {`
73-
`           System.out.println(psite.toString());`
74-
      }`
75-
  } catch(Exception e) {`
76-
`       e.printStackTrace();`
77-
  }`
59+
  try {`
60+
      PDBFileReader reader = new PDBFileReader();
61+
      reader.setAutoFetch(true);
62+
63+
      // identify all modificaitons from PDB:1CAD and print them`
64+
      String pdbId = "1CAD";
65+
      Structure struc = reader.getStructureById(pdbId);
66+
      Set`<ModifiedCompound> mcs = identifyAllModfications(struc);
67+
      for (ModifiedCompound mc : mcs) {`
68+
          System.out.println(mc.toString());
69+
      }`
70+
71+
      // identify all phosphosites from PDB:3MVJ and print them`
72+
      pdbId = "3MVJ";
73+
      struc = reader.getStructureById(pdbId);
74+
      List`<ResidueNumber> psites = identifyPhosphosites(struc);
75+
      for (ResidueNumber psite : psites) {`
76+
          System.out.println(psite.toString());
77+
      }`
78+
  } catch(Exception e) {`
79+
      e.printStackTrace();
80+
  }`
7881

7982
} ```
8083

_wikis/BioJava:CookBook3:ParsingBlastXMLOutput.md

Lines changed: 79 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,41 @@ Command line usage example:
4747
<nowiki>xjc -d <output directory> -p <package name> -dtd http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd</nowiki>
4848
`
4949

50-
Maven plugin config example: <xml> <plugin>
51-
52-
` `<groupId>`org.jvnet.jaxb2.maven2`</groupId>
53-
` `<artifactId>`maven-jaxb2-plugin`</artifactId>
54-
` `<version>`0.8.0`</version>
55-
` `<executions>
56-
`   `<execution>
57-
`     `<goals>
58-
`       `<goal>`generate`</goal>
59-
`     `</goals>
60-
`     `<configuration>
61-
`       `<generatePackage>`ncbi.blast.result.generated`</generatePackage>
62-
`       `<generateDirectory>`${basedir}/src/main/java`</generateDirectory>
63-
`       `<schemaLanguage>`dtd`</schemaLanguage>
64-
`       `<schemaIncludes>
65-
`         `
66-
`         `<value>`schemaFolder/NCBI_BlastOutput.dtd`</value>
67-
`       `</schemaIncludes>
68-
`     `</configuration>
69-
`   `</execution>
70-
` `</executions>
71-
` `<dependencies>
72-
`   `<dependency>
73-
`     `<groupId>`org.jvnet.jaxb2-commons`</groupId>
74-
`     `<artifactId>`property-listener-injector`</artifactId>
75-
`     `<version>`1.0`</version>
76-
`   `</dependency>
77-
` `</dependencies>
78-
79-
</plugin> </xml>
50+
Maven plugin config example:
51+
52+
```xml
53+
54+
<plugin>
55+
56+
>groupId>org.jvnet.jaxb2.maven2>/groupId>
57+
>artifactId>maven-jaxb2-plugin>/artifactId>
58+
>version>`0.8.0>/version>
59+
>executions>
60+
  >execution>
61+
    >goals>
62+
      >goal>`generate>/goal>
63+
    >/goals>
64+
    >configuration>
65+
      >generatePackage>ncbi.blast.result.generated>/generatePackage>
66+
      >generateDirectory>${basedir}/src/main/java>/generateDirectory>
67+
      >schemaLanguage>dtd>/schemaLanguage>
68+
      >schemaIncludes>
69+
        
70+
        >value>schemaFolder/NCBI_BlastOutput.dtd>/value>
71+
      >/schemaIncludes>
72+
    >/configuration>
73+
  >/execution>
74+
>/executions>
75+
>dependencies>
76+
  >dependency>
77+
    >groupId>org.jvnet.jaxb2-commons>/groupId>
78+
    >artifactId>property-listener-injector>/artifactId>
79+
    >version>1.0>/version>
80+
  >/dependency>
81+
>/dependencies>
82+
83+
</plugin>
84+
```
8085

8186
### Create Java objects from Blast results XML
8287

@@ -92,52 +97,65 @@ File("blast-xml-output.xml")); ```
9297

9398
As a workaround, place the 3 schema files in the same folder where the
9499
generated classes are located and use the following code, which will
95-
then use those files: ```java JAXBContext jc =
96-
JAXBContext.newInstance(BlastOutput.class); Unmarshaller u =
97-
jc.createUnmarshaller();
100+
then use those files:
101+
102+
```java
103+
104+
JAXBContext jc = JAXBContext.newInstance(BlastOutput.class);
105+
Unmarshaller u = jc.createUnmarshaller();
98106

99107
XMLReader xmlreader = XMLReaderFactory.createXMLReader();
100108
xmlreader.setFeature("<http://xml.org/sax/features/namespaces>", true);
101109
xmlreader.setFeature("<http://xml.org/sax/features/namespace-prefixes>",
102110
true); xmlreader.setEntityResolver(new EntityResolver() {
103111

104-
`    public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {`
105-
`         String file = null;`
106-
`         if (systemId.contains("NCBI_BlastOutput.dtd")) {`
107-
`              file = "NCBI_BlastOutput.dtd";`
108-
`         }`
109-
`         if (systemId.contains("NCBI_Entity.mod.dtd")) {`
110-
`              file = "NCBI_Entity.mod.dtd";`
111-
`         }`
112-
`         if (systemId.contains("NCBI_BlastOutput.mod.dtd")) {`
113-
`              file = "NCBI_BlastOutput.mod.dtd";`
114-
`         }`
115-
`         return new InputSource(BlastOutput.class.getResourceAsStream(file));`
116-
`   }`
117-
118-
}); InputSource input = new InputSource(new FileReader(new
119-
File("blast-xml-output.xml"))); Source source = new SAXSource(xmlreader,
120-
input); return (BlastOutput) u.unmarshal(source); ```
112+
   public InputSource resolveEntity(String publicIdString systemIdthrows SAXExceptionIOException {
113+
        String file = null`
114+
        if (systemId.contains("NCBI_BlastOutput.dtd")) {
115+
             file = "NCBI_BlastOutput.dtd"`
116+
        
117+
        if (systemId.contains("NCBI_Entity.mod.dtd")) {
118+
             file = "NCBI_Entity.mod.dtd"`
119+
        
120+
        if (systemId.contains("NCBI_BlastOutput.mod.dtd")) {
121+
             file = "NCBI_BlastOutput.mod.dtd"`
122+
        
123+
        return new InputSource(BlastOutput.class.getResourceAsStream(file));
124+
  
125+
126+
});
127+
128+
InputSource input = new InputSource(new FileReader(new File("blast-xml-output.xml"))); Source source = new SAXSource(xmlreader, input);
129+
130+
return (BlastOutput) u.unmarshal(source);
131+
132+
```
121133

122134
### Use the created BlastOutput object
123135

124136
Finally, BlastOutput object, created in the previous step, can be used
125137
like any other Java object.
126138

127139
For example, you can get the matrix used for given Blast search like
128-
this: ```java BlastOutput blastOutput; // assign BlastOutput object,
140+
this:
141+
142+
```java BlastOutput blastOutput; // assign BlastOutput object,
129143
returned by Unmarshaller (see previous step) String matrix =
130144
blastOutput.getBlastOutputParam().getParameters().getParametersMatrix();
131-
``` Note that this corresponds to the XML structure: <xml>
145+
``` Note that this corresponds to the XML structure:
146+
147+
```xml
132148
<BlastOutput>
133149

134-
` ...`
135-
` `<BlastOutput_param>
136-
`   `<Parameters>
137-
`     `<Parameters_matrix>`BLOSUM62`</Parameters_matrix>
138-
`     ...`
139-
`   `</Parameters>
140-
` `</BlastOutput_param>
141-
` ...`
150+
...
151+
>BlastOutput_param>
152+
  >Parameters>
153+
    >Parameters_matrix>`BLOSUM62>/Parameters_matrix>
154+
    ...
155+
  >/Parameters>
156+
>/BlastOutput_param>
157+
...
158+
159+
</BlastOutput>
142160

143-
</BlastOutput> </xml>
161+
```

0 commit comments

Comments
 (0)