<commit_before>/*
 *                  BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 * 
 * Created on Nov 7, 2005
 *
 */
package org.biojava.spice.das;

import java.io.IOException;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.List;
import java.util.ArrayList;

import org.biojava.bio.structure.Structure;
import org.biojava.bio.structure.io.DASStructureClient;
import org.biojava.bio.structure.io.PDBFileReader;
import org.biojava.spice.manypanel.eventmodel.StructureEvent;
import org.biojava.spice.manypanel.eventmodel.StructureListener;


/** a thread that gets the protein structure from a das server
 * 
 * @author <NAME>
 *
 */
public class StructureThread
extends Thread{
    
    
    SpiceDasSource[] dasSources;
    String accessionCode;
    static Logger logger = Logger.getLogger("org.biojava.spice");
    List structureListeners;
     
    public StructureThread(String accessionCode, SpiceDasSource ds) {
	SpiceDasSource[] dss = new SpiceDasSource[1];
	dss[0] = ds;
	dasSources = dss;
	this.accessionCode = accessionCode;
        structureListeners = new ArrayList();
    }


    public StructureThread(String accessionCode, SpiceDasSource[] dss) {
        super();
        dasSources = dss;
        this.accessionCode = accessionCode;
        structureListeners = new ArrayList();
    }
    
    public void addStructureListener(StructureListener li){
        structureListeners.add(li);
    }
    
    public void triggerNewStructure(StructureEvent event){
        
            Iterator iter = structureListeners.iterator();
            while (iter.hasNext()){
               //StructureListener li = (StructureListener) iter.next();
               //li.newStructure(event);
                StructureListener li = (StructureListener) iter.next();
                li.newStructure(event);
            }
    }
    
    public void run() {
        Structure structure = null ;
        for (int i=0 ; i < dasSources.length; i++){
            SpiceDasSource ds = dasSources[i];
            
            String url = ds.getUrl();
            logger.finest(url);<commit_msg>fixed a chain issue<commit_after>/*
 *                  BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 * 
 * Created on Nov 7, 2005
 *
 */
package org.biojava.spice.das;

import java.io.IOException;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.List;
import java.util.ArrayList;

import org.biojava.bio.structure.Structure;
import org.biojava.bio.structure.io.DASStructureClient;
import org.biojava.bio.structure.io.PDBFileReader;
import org.biojava.spice.manypanel.eventmodel.StructureEvent;
import org.biojava.spice.manypanel.eventmodel.StructureListener;


/** a thread that gets the protein structure from a das server
 * 
 * @author <NAME>
 *
 */
public class StructureThread
extends Thread{
    
    
    SpiceDasSource[] dasSources;
    String accessionCode;
    static Logger logger = Logger.getLogger("org.biojava.spice");
    List structureListeners;
     
    public StructureThread(String accessionCode, SpiceDasSource ds) {
	SpiceDasSource[] dss = new SpiceDasSource[1];
	dss[0] = ds;
	dasSources = dss;
	this.accessionCode = accessionCode;
	structureListeners = new ArrayList();
    }


    public StructureThread(String accessionCode, SpiceDasSource[] dss) {
        super();
        dasSources = dss;
        
        // if the accessioncode has a chain, remove it ...
        String code;
        String[] spl = accessionCode.split("\\.");
        if ( spl.length < 2)    
            code = accessionCode;
        else {
            code = spl[0];            
        }        
        this.accessionCode = code;
        structureListeners = new ArrayList();
    }
    
    public void addStructureListener(StructureListener li){
        structureListeners.add(li);
    }
    
    public void triggerNewStructure(StructureEvent event){
        
            Iterator iter = structureListeners.iterator();
            while (iter.hasNext()){
               //StructureListener li = (StructureListener) iter.next();
               //li.newStructure(event);
                StructureListener li = (StructureListener) iter.next();
                li.newStructure(event);
            }
    }
    
    public void run() {
        Structure structure = null ;
        for (int i=0 ; i < dasSources.length; i++){
            SpiceDasSource ds = dasSources[i];
            
            String url = ds.getUrl();
            logger.finest(url);
{'fraction_non_alphanumeric': 0.09587573647562936, 'fraction_numerical': 0.0032137118371719335, 'mean_word_length': 2.572704081632653, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5705872', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1539, 'n_words': 445}