Skip to content

Commit cecd292

Browse files
Sdg23 add getting started page md (#443)
* FIX broken links * add mamba instructions and refine installation quick start * add mamba instructions and refine installation quick start * address PR review comments * Add 'Getting Started' page with installation, basic example, and learning resources * Update basic_example.md slight changes to improve readability of the code example comments for new users * address PR review comments * Address PR review comments * address PR review comments and restyle code block * restyle code block in basic example page --------- Co-authored-by: Micaela Matta <[email protected]>
1 parent 30bdb38 commit cecd292

File tree

4 files changed

+84
-22
lines changed

4 files changed

+84
-22
lines changed

pages/basic_example.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
---
2-
layout: page
2+
layout: otherpage
33
title: Basic example
4-
order: 1
54
---
65

76
A typical usage pattern is to iterate through a trajectory and analyze
87
coordinates for every frame. In the following example the end-to-end
98
distance of a protein and the radius of gyration of the backbone atoms
109
are calculated:
1110

12-
{% highlight python %}
13-
import MDAnalysis
14-
from MDAnalysis.tests.datafiles import PSF, DCD # test trajectory
15-
import numpy.linalg
11+
<div class="wide-code">
12+
{% highlight python %}
13+
import MDAnalysis
14+
from MDAnalysis.tests.datafiles import PSF, DCD # test trajectory
15+
import numpy.linalg
1616

17-
u = MDAnalysis.Universe(PSF,DCD) # always start with a Universe
18-
# can access via segid (4AKE) and atom name
19-
# we take the first atom named N and the last atom named C
20-
nterm = u.select_atoms('segid 4AKE and name N')[0]
21-
cterm = u.select_atoms('segid 4AKE and name C')[-1]
17+
# load trajectory and topology into a Universe
18+
u = MDAnalysis.Universe(PSF,DCD)
19+
# from the 4AKE segid, select
20+
# the first atom named N and the last atom named C
21+
nterm = u.select_atoms('segid 4AKE and name N')[0]
22+
cterm = u.select_atoms('segid 4AKE and name C')[-1]
23+
# select the backbone atoms (AtomGroup)
24+
bb = u.select_atoms('protein and backbone')
2225

23-
bb = u.select_atoms('protein and backbone') # a selection (AtomGroup)
24-
25-
for ts in u.trajectory: # iterate through all frames
26-
r = cterm.position - nterm.position # end-to-end vector from atom positions
27-
d = numpy.linalg.norm(r) # end-to-end distance
28-
rgyr = bb.radius_of_gyration() # method of AtomGroup
29-
print("frame = {0}: d = {1} A, Rgyr = {2} A".format(
30-
ts.frame, d, rgyr))
31-
{% endhighlight %}
26+
for ts in u.trajectory: # iterate through all frames
27+
r = cterm.position - nterm.position # end-to-end vector from atom positions
28+
d = numpy.linalg.norm(r) # end-to-end distance
29+
rgyr = bb.radius_of_gyration() # method of AtomGroup
30+
print("frame = {0}: d = {1} A, Rgyr = {2} A".format(
31+
ts.frame, d, rgyr))
32+
{% endhighlight %}
33+
</div>
3234

3335
To find out what else you can do, head over to [learning
3436
MDAnalysis]({{ site.baseurl }}/pages/learning_MDAnalysis) to have a look

pages/getting_started.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
layout: page
3+
title: Getting Started
4+
order: 1
5+
---
6+
7+
MDAnalysis is a Python library for analyzing molecular dynamics (MD) simulations. This page will guide you through quickly installing MDAnalysis, exploring a basic example, and accessing learning resources to get started.
8+
9+
## Installation Instructions
10+
11+
Our [Installation Quick Start]({{ site.baseurl }}/pages/installation_quick_start) guide contains instructions to get MDAnalysis up and running in a few minutes. Try this guide first.
12+
13+
For a more thorough installation with advanced options, including dependencies and environment configurations, see the [installation instructions in the User Guide]({{ site.docs.userguide.url }}/stable/installation.html).
14+
15+
## Basic Example
16+
17+
Once MDAnalysis is installed, you can load a trajectory and perform a simple analysis. A typical usage pattern is to iterate through a trajectory and analyze
18+
coordinates for every frame.
19+
20+
In the following example, the end-to-end distance of a protein and the radius of gyration of the backbone atoms are calculated:
21+
22+
<div class="wide-code">
23+
{% highlight python %}
24+
import MDAnalysis
25+
from MDAnalysis.tests.datafiles import PSF, DCD # test trajectory
26+
import numpy.linalg
27+
28+
# load trajectory and topology into a Universe
29+
u = MDAnalysis.Universe(PSF,DCD)
30+
# from the 4AKE segid, select
31+
# the first atom named N and the last atom named C
32+
nterm = u.select_atoms('segid 4AKE and name N')[0]
33+
cterm = u.select_atoms('segid 4AKE and name C')[-1]
34+
# select the backbone atoms (AtomGroup)
35+
bb = u.select_atoms('protein and backbone')
36+
37+
for ts in u.trajectory: # iterate through all frames
38+
r = cterm.position - nterm.position # end-to-end vector from atom positions
39+
d = numpy.linalg.norm(r) # end-to-end distance
40+
rgyr = bb.radius_of_gyration() # method of AtomGroup
41+
print("frame = {0}: d = {1} A, Rgyr = {2} A".format(
42+
ts.frame, d, rgyr))
43+
{% endhighlight %}
44+
</div>
45+
46+
## Learning Resources
47+
48+
To find out what else you can do, head over to [Learning
49+
MDAnalysis]({{ site.baseurl }}/pages/learning_MDAnalysis) to explore
50+
tutorials and documentation.
51+
52+
If you have questions, visit our [Community]({{ site.baseurl }}/pages/community) page to learn about available discussion channels. Happy coding!
53+

pages/installation_quick_start.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
2-
layout: page
2+
layout: otherpage
33
title: Installation Quick Start
4-
order: 2
54
---
65

76
MDAnalysis can be installed using [mamba][], a faster drop-in replacement for [conda][], or [pip][].

public/css/local.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ but our YouTube videos seem to be natively widescreen.
4545
position: absolute;
4646
}
4747

48+
.wide-code pre {
49+
white-space: pre;
50+
overflow-x: auto;
51+
display: block;
52+
max-width: 100%;
53+
width: 100%;
54+
}
55+

0 commit comments

Comments
 (0)