예제 #1
0
def to_mmtf_MMTFDecoder(item,
                        atom_indices='all',
                        structure_indices='all',
                        check=True):

    if check:

        try:
            is_string_pdb_id(item)
        except:
            raise WrongFormError('string:pdb_id')

        try:
            atom_indices = digest_atom_indices(atom_indices)
        except:
            raise WrongAtomIndicesError()

        try:
            structure_indices = digest_structure_indices(structure_indices)
        except:
            raise WrongStructureIndicesError()

    from mmtf import fetch
    from ..mmtf_MMTFDecoder import extract as extract_mmtf_MMTFDecoder

    tmp_item = item.split(':')[-1]
    tmp_item = fetch(tmp_item)
    tmp_item = extract_mmtf_MMTFDecoder(tmp_item,
                                        atom_indices=atom_indices,
                                        structure_indices=structure_indices,
                                        copy_if_all=False)

    return tmp_item
예제 #2
0
    def get_structure_from_url(pdb_id):
        """Get a structure from a URL - given a PDB id.

        :param pdb_id: the input PDB id
        :return: the structure
        """
        decoder = fetch(pdb_id)
        return get_from_decoded(decoder)
예제 #3
0
 def round_trip(self,pdb_id):
     if _internet_on(BASE_URL):
         data_in = fetch(pdb_id)
         write_mmtf(pdb_id+".mmtf", data_in, MMTFDecoder.pass_data_on)
         data_rt = parse(pdb_id+".mmtf")
         self.check_equal(data_in, data_rt)
     else:
         print("Warning - cannot connect to "+BASE_URL)
예제 #4
0
    def from_id(cls, pdb_id):
        """
        Initialize structure by PDB ID (fetches
        structure from RCSB servers)

        Parameters
        ----------
        pdb_id : str
            PDB identifier (e.g. 1hzx)

        Returns
        -------
        PDB
            initialized PDB structure
        """
        try:
            return cls(fetch(pdb_id))
        except HTTPError as e:
            raise ResourceError(
                "Could not fetch MMTF data for {}".format(pdb_id)
            ) from e
예제 #5
0
파일: MMTF.py 프로젝트: kaplajon/mdanalysis
def fetch_mmtf(pdb_id):
    """Create a Universe from the RCSB Protein Data Bank using mmtf format

    Parameters
    ----------
    pdb_id : string
        PDB code of the desired data, eg '4UCP'


    Returns
    -------
    MDAnalysis Universe of the corresponding PDB system


    See Also
    --------
    mmtf.fetch : Function for fetching raw mmtf data


    .. versionadded:: 0.16.0
    """
    return Universe(mmtf.fetch(pdb_id))
예제 #6
0
def fetch_mmtf(pdb_id):
    """Create a Universe from the RCSB Protein Data Bank using mmtf format

    Parameters
    ----------
    pdb_id : string
        PDB code of the desired data, eg '4UCP'


    Returns
    -------
    Universe
        MDAnalysis Universe of the corresponding PDB system


    See Also
    --------
    mmtf.fetch : Function for fetching raw mmtf data


    .. versionadded:: 0.16.0
    """
    return Universe(mmtf.fetch(pdb_id))
예제 #7
0
    with open(input_args.pdb_id_list, 'r') as fh:
        pdb_ids = fh.readlines()
except IOError:
    print '\nYou did not give me an acceptable PDB ID file.\n'
    sys.exit()

# dump a .csv every 20 trials just in case
index = 0
# for each line (PDB ID) in the given file
for pdb_id in pdb_ids:
    # check pdb_id
    pdb_id = pdb_id.strip()

    # fetch the MMTF data of this pdb
    try:
        pdb_data = fetch(pdb_id)
    except:
        print '***** %s was not able to be downloaded' % pdb_id
        continue

    ## for each group in the entity_list of this pdb
    # check the description for each group of the pdb
    # has -L- or -D- as sugars should have these
    for ii in range(len(pdb_data.entity_list)):
        # reset data holders
        has_D = False
        has_L = False

        # pull out description and make it all lowercase
        description = pdb_data.entity_list[ii]['description'].lower()
        # only look at types that are not classified as polymers
예제 #8
0
    def from_pdbid(cls, pdbid):
        import mmtf

        return cls(mmtf.fetch(pdbid))
예제 #9
0
from mmtf import fetch

# Get the data for 4CUP
decoded_data = fetch("4CUP")

# Print the number of chains
print("PDB Code: " + str(decoded_data.structure_id) + " has " +
      str(decoded_data.num_chains) + " chains")

print(
    "Group name:" + str(decoded_data.group_list[0]["groupName"]) +
    "has the following atomic charges: " +
    ",".join([str(x) for x in decoded_data.group_list[0]["formalChargeList"]]))

print("PDB Code:" + str(decoded_data.structure_id) + " has " +
      str(len(decoded_data.bio_assembly)) + " bioassemblies")
예제 #10
0
 def test_fetch(self):
     if _internet_on(BASE_URL):
         decoded = fetch("4CUP")
     else:
         print("Warning - cannot connect to "+BASE_URL)
예제 #11
0
 def test_fetch(self):
     decoded = fetch("4CUP")
예제 #12
0
 def round_trip(self,pdb_id):
     data_in = fetch(pdb_id)
     write_mmtf(pdb_id+".mmtf", data_in, MMTFDecoder.pass_data_on)
     data_rt = parse(pdb_id+".mmtf")
     self.check_equal(data_in, data_rt)
예제 #13
0
 def test_fetch(self):
     decoded = fetch("4CUP")