Get the linkage information from a LINK entry PDB line.
324484
def get_linkage(self, line):
        """"""
        conf1, id1, chain1, pos1 = line[16].strip(), line[17:20].strip(), line[21].strip(), int(line[22:26])
        conf2, id2, chain2, pos2 = line[46].strip(), line[47:50].strip(), line[51].strip(), int(line[52:56])
        return self.covlinkage(id1=id1, chain1=chain1, pos1=pos1, conf1=conf1,
                               id2=id2, chain2=chain2, pos2=pos2, conf2=conf2)
680234
def load_pdb(self, pdbpath, as_string=False):
        """"""
        if as_string:
            self.sourcefiles['pdbcomplex.original'] = None
            self.sourcefiles['pdbcomplex'] = None
            self.sourcefiles['pdbstring'] = pdbpath
        else:
            self.sourcefiles['pdbcomplex.original'] = pdbpath
            self.sourcefiles['pdbcomplex'] = pdbpath
        self.information['pdbfixes'] = False
        pdbparser = PDBParser(pdbpath, as_string=as_string)  # Parse PDB file to find errors and get additonal data
        # #@todo Refactor and rename here
        self.Mapper.proteinmap = pdbparser.proteinmap
        self.Mapper.reversed_proteinmap = {v: k for k, v in self.Mapper.proteinmap.items()}
        self.modres = pdbparser.modres
        self.covalent = pdbparser.covalent
        self.altconf = pdbparser.altconformations
        self.corrected_pdb = pdbparser.corrected_pdb

        if not config.PLUGIN_MODE:
            if pdbparser.num_fixed_lines > 0:
                write_message('%i lines automatically fixed in PDB input file.\n' % pdbparser.num_fixed_lines)
                # Save modified PDB file
                if not as_string:
                    basename = os.path.basename(pdbpath).split('.')[0]
                else:
                    basename = "from_stdin"
                pdbpath_fixed = tmpfile(prefix='plipfixed.' + basename + '_', direc=self.output_path)
                create_folder_if_not_exists(self.output_path)
                self.sourcefiles['pdbcomplex'] = pdbpath_fixed
                self.corrected_pdb = re.sub(r'[^\x00-\x7F]+', ' ', self.corrected_pdb)  # Strip non-unicode chars
                if not config.NOFIXFILE:  # Only write to file if this option is not activated
                    with open(pdbpath_fixed, 'w') as f:
                        f.write(self.corrected_pdb)
                self.information['pdbfixes'] = True

        if not as_string:
            self.sourcefiles['filename'] = os.path.basename(self.sourcefiles['pdbcomplex'])
        self.protcomplex, self.filetype = read_pdb(self.corrected_pdb, as_string=True)

        # Update the model in the Mapper class instance
        self.Mapper.original_structure = self.protcomplex.OBMol
        write_message('PDB structure successfully read.\n')

        # Determine (temporary) PyMOL Name from Filename
        self.pymol_name = pdbpath.split('/')[-1].split('.')[0] + '-Protein'
        # Replace characters causing problems in PyMOL
        self.pymol_name = self.pymol_name.replace(' ', '').replace('(', '').replace(')', '').replace('-', '_')
        # But if possible, name it after PDBID in Header
        if 'HEADER' in self.protcomplex.data:  # If the PDB file has a proper header
            potential_name = self.protcomplex.data['HEADER'][56:60].lower()
            if extract_pdbid(potential_name) != 'UnknownProtein':
                self.pymol_name = potential_name
        write_message("Pymol Name set as: '%s'\n" % self.pymol_name, mtype='debug')

        # Extract and prepare ligands
        ligandfinder = LigandFinder(self.protcomplex, self.altconf, self.modres, self.covalent, self.Mapper)
        self.ligands = ligandfinder.ligands
        self.excluded = ligandfinder.excluded

        # Add polar hydrogens
        self.protcomplex.OBMol.AddPolarHydrogens()
        for atm in self.protcomplex:
            self.atoms[atm.idx] = atm
        write_message("Assigned polar hydrogens\n", mtype='debug')

        if len(self.excluded) != 0:
            write_message("Excluded molecules as ligands: %s\n" % ','.join([lig for lig in self.excluded]))

        if config.DNARECEPTOR:
            self.resis = [obres for obres in pybel.ob.OBResidueIter(
                self.protcomplex.OBMol) if obres.GetName() in config.DNA+config.RNA]
        else:
            self.resis = [obres for obres in pybel.ob.OBResidueIter(
                self.protcomplex.OBMol) if obres.GetResidueProperty(0)]

        num_ligs = len(self.ligands)
        if num_ligs == 1:
            write_message("Analyzing one ligand...\n")
        elif num_ligs > 1:
            write_message("Analyzing %i ligands...\n" % num_ligs)
        else:
            write_message("Structure contains no ligands.\n\n")
1308009
def cp(args):
    
    p = OptionParser(cp.__doc__)
    fp = sys.stdin

    for link_name in fp:
        link_name = link_name.strip()
        if not op.exists(link_name):
            continue

        source = get_abs_path(link_name)
        link_name = op.basename(link_name)
        if not op.exists(link_name):
            os.symlink(source, link_name)
        logging.debug(" => ".join((source, link_name)))
571488
@Nullable
  private DirectoryEntry lookUp(
      File dir, Iterable<Name> names, Set<? super LinkOption> options, int linkDepth)
      throws IOException {
    Iterator<Name> nameIterator = names.iterator();
    Name name = nameIterator.next();
    while (nameIterator.hasNext()) {
      Directory directory = toDirectory(dir);
      if (directory == null) {
        return null;
      }

      DirectoryEntry entry = directory.get(name);
      if (entry == null) {
        return null;
      }

      File file = entry.file();
      if (file.isSymbolicLink()) {
        DirectoryEntry linkResult = followSymbolicLink(dir, (SymbolicLink) file, linkDepth);

        if (linkResult == null) {
          return null;
        }

        dir = linkResult.fileOrNull();
      } else {
        dir = file;
      }

      name = nameIterator.next();
    }

    return lookUpLast(dir, name, options, linkDepth);
  }
642335
def postprocess_link(self, entry):
        

        if not self.follow_links:
            return

        if type(entry.link) is not list:
            entry.link = [entry.link]

        for link in list(entry.link):
            if not os.path.exists(link):
                continue

            mime_type = magic.from_file(link, mime=True)
            if mime_type == 'application/pdf':
                structuredfeature = extract_pdf(link)
            elif mime_type == 'text/plain':
                structuredfeature = extract_text(link)
            else:
                structuredfeature = None

            if not structuredfeature:
                continue

            fset_name = mime_type.split('/')[-1] + '_text'
            if not fset_name in self.full_text:
                self.full_text[fset_name] = {}

            if hasattr(self, 'index_by'):
                ident = getattr(entry, self.index_by)
                if type(ident) is list:
                    ident = ident[0]
            else:   # If `index_by` is not set, use `uri` by default.
                ident = entry.uri

            self.full_text[fset_name][ident] = structuredfeature
910957
def linkHasRel(link_attrs, target_rel):
    """"""
    # XXX: TESTME
    rel_attr = link_attrs.get('rel')
    return rel_attr and relMatches(rel_attr, target_rel)
179983
def get_pfam_accession_numbers_from_pdb_id(self, pdb_id):
        ''''''
        pdb_id = pdb_id.lower()
        if self.pdb_chain_to_pfam_mapping.get(pdb_id):
            return self.pdb_chain_to_pfam_mapping[pdb_id].copy()
1299246
def get_string(self):
    """"""
    ostr = ''
    errtotal = self.deletions['total']+self.insertions['total']+self.mismatches
    ostr += 'from '+str(self.alignment_length)+' bp of alignment'+"\n"
    ostr += '  '+str(float(errtotal)/float(self.alignment_length))+" error rate\n"
    ostr += '    '+str(float(self.mismatches)/float(self.alignment_length))+ " mismatches\n"
    ostr += '    '+str(float(self.deletions['total'])/float(self.alignment_length))+ " deletions\n"
    ostr += '      '+str(float(self.deletions['specific'])/float(self.alignment_length))+ " total deletions\n"
    ostr += '      '+str(float(self.deletions['homopolymer'])/float(self.alignment_length))+ " homopolymer deletions\n"
    ostr += '    '+str(float(self.insertions['total'])/float(self.alignment_length))+ " insertions\n"
    ostr += '      '+str(float(self.insertions['specific'])/float(self.alignment_length))+ " total insertions\n"
    ostr += '      '+str(float(self.insertions['homopolymer'])/float(self.alignment_length))+ " homopolymer insertions\n"
    ostr += '  More specific errors'+"\n"
    poss = ['-','A','C','G','T']
    ostr += '  -    A    C    G    T'+"\n"
    t = 0
    for p1 in poss:
      ostr += p1
      for p2 in poss:
        val = float(self.matrix[p1][p2])/float(self.alignment_length)
        ostr += " "+str(round(val,3))
        t += val
      ostr += "\n"
    ostr += "\n"
    return ostr
1150696
def _GetLink(self):
    
    if self._link is None:
      self._link = ''
      if self.entry_type != definitions.FILE_ENTRY_TYPE_LINK:
        return self._link

      link = self._fsapfs_file_entry.symbolic_link_target
      if link and link[0] != self._file_system.PATH_SEPARATOR:
        # TODO: make link absolute.
        self._link = '/{0:s}'.format(link)

    return self._link
526634
public String getLinkerNotation() {
    String pSymbol = getPhosphateSymbol();
    String result = null;
    if (null == pSymbol || pSymbol.length() == 0) {
      result = "";
    } else {
      if (pSymbol.length() > 1)
        result = "[" + pSymbol + "]";
      else
        result = pSymbol;
    }
    return result;
  }
1217105
def get_line_str(self):
        """"""
        if self.from_string:
            return ' '.join([s for s in [self.merge_marker_str,
                                         self._datetime_str,
                                         self._line_str] if s])
        else:
            return ' '.join([s for s in [self._datetime_str,
                                         self._line_str] if s])
1060006
def parse_pdb_file(self):
        """"""
        self.pdb_parse_tree = {'info': {},
                               'data': {
                                   self.state: {}}
                               }
        try:
            for line in self.pdb_lines:
                self.current_line = line
                record_name = line[:6].strip()
                if record_name in self.proc_functions:
                    self.proc_functions[record_name]()
                else:
                    if record_name not in self.pdb_parse_tree['info']:
                        self.pdb_parse_tree['info'][record_name] = []
                    self.pdb_parse_tree['info'][record_name].append(line)
        except EOFError:
            # Raised by END record
            pass
        if self.new_labels:
            ampal_data_session.commit()
        return
185788
def getLinks(page):
    

    CheckParent(page)
    ln = page.firstLink
    links = []
    while ln:
        nl = getLinkDict(ln)
        if nl["kind"] == LINK_GOTO:
            if type(nl["to"]) is Point and nl["page"] >= 0:
                doc = page.parent
                target_page = doc[nl["page"]]
                ctm = target_page._getTransformation()
                point = nl["to"] * ctm
                nl["to"] = point
        links.append(nl)
        ln = ln.next
    if len(links) > 0:
        linkxrefs = page._getLinkXrefs()
        if len(linkxrefs) == len(links):
            for i in range(len(linkxrefs)):
                links[i]["xref"] = linkxrefs[i]
    return links
1065431
def extract_pp_helices(in_pdb):
    
    t_phi = -75.0
    t_phi_d = 29.0
    t_psi = 145.0
    t_psi_d = 29.0

    pph_dssp = subprocess.check_output(
        [global_settings['dssp']['path'], in_pdb])
    dssp_residues = []
    go = False
    for line in pph_dssp.splitlines():
        if go:
            res_num = int(line[:5].strip())
            chain = line[11:13].strip()
            ss_type = line[16]
            phi = float(line[103:109].strip())
            psi = float(line[109:116].strip())
            dssp_residues.append((res_num, ss_type, chain, phi, psi))
        else:
            if line[2] == '#':
                go = True
            pass
    pp_chains = []
    chain = []
    ch_on = False
    for item in dssp_residues:
        if (item[1] == ' ') and (
            t_phi - t_phi_d < item[3] < t_phi + t_phi_d) and (
            t_psi - t_psi_d < item[4] < t_psi + t_psi_d):
            chain.append(item)
            ch_on = True
        else:
            if ch_on:
                pp_chains.append(chain)
                chain = []
                ch_on = False
    pp_chains = [x for x in pp_chains if len(x) > 1]
    pp_helices = []
    with open(in_pdb, 'r') as pdb:
        pdb_atoms = split_pdb_lines(pdb.read())
    for pp_helix in pp_chains:
        chain_id = pp_helix[0][2]
        res_range = [x[0] for x in pp_helix]
        helix = []
        for atom in pdb_atoms:
            if (atom[2] == "CA") and (
                    atom[5] == chain_id) and (
                    atom[6] in res_range):
                helix.append(tuple(atom[8:11]))
        pp_helices.append(helix)
    return pp_helices
10532
def GetLinkedFileEntry(self):
    
    link = self._GetLink()
    if not link:
      return None

    # TODO: is there a way to determine the link inode number here?
    link_inode = None

    parent_path_spec = getattr(self.path_spec, 'parent', None)
    path_spec = tsk_path_spec.TSKPathSpec(
        location=link, parent=parent_path_spec)

    root_inode = self._file_system.GetRootInode()
    is_root = bool(
        link == self._file_system.LOCATION_ROOT or (
            link_inode is not None and root_inode is not None and
            link_inode == root_inode))

    return TSKFileEntry(
        self._resolver_context, self._file_system, path_spec, is_root=is_root)
452750
def _get_entry_link(self, entry):
        
        entry_link = None
        for link in entry.link:
            if '/data/' not in link.href and '/lh/' not in link.href:
                entry_link = link.href
                break
        return entry_link or entry.link[0].href
301193
def _GetDebuggeeDescription(self):
    """"""
    return '-'.join(self._debuggee_labels[label]
                    for label in _DESCRIPTION_LABELS
                    if label in self._debuggee_labels)