+ private final static int extractProteinFeatures( final boolean use_domain_architectures,
+ final SortedMap<Species, List<Protein>> protein_lists_per_species,
+ final String domain_id,
+ final Writer out,
+ final double ie_cutoff,
+ final String domain_separator )
+ throws IOException {
+ int counter = 0;
+ final String separator_for_output = "\t";
+ for( final Species species : protein_lists_per_species.keySet() ) {
+ final List<Protein> proteins_per_species = protein_lists_per_species.get( species );
+ for( final Protein protein : proteins_per_species ) {
+ if ( use_domain_architectures ) {
+ if ( domain_id.equals( protein.toDomainArchitectureString( domain_separator, ie_cutoff ) ) ) {
+ int from = Integer.MAX_VALUE;
+ int to = -1;
+ for( final Domain d : protein.getProteinDomains() ) {
+ if ( ( ie_cutoff <= -1 ) || ( d.getPerDomainEvalue() <= ie_cutoff ) ) {
+ if ( d.getFrom() < from ) {
+ from = d.getFrom();
+ }
+ if ( d.getTo() > to ) {
+ to = d.getTo();
+ }
+ }
+ }
+ out.write( protein.getSpecies().getSpeciesId() );
+ out.write( separator_for_output );
+ out.write( protein.getProteinId().getId() );
+ out.write( separator_for_output );
+ out.write( domain_id );
+ out.write( separator_for_output );
+ out.write( "/" );
+ out.write( from + "-" + to );
+ out.write( "/" );
+ out.write( SurfacingConstants.NL );
+ ++counter;
+ }
+ }
+ else {
+ final List<Domain> domains = protein.getProteinDomains( domain_id );
+ if ( domains.size() > 0 ) {
+ out.write( protein.getSpecies().getSpeciesId() );
+ out.write( separator_for_output );
+ out.write( protein.getProteinId().getId() );
+ out.write( separator_for_output );
+ out.write( domain_id );
+ out.write( separator_for_output );
+ for( final Domain domain : domains ) {
+ if ( ( ie_cutoff < 0 ) || ( domain.getPerDomainEvalue() <= ie_cutoff ) ) {
+ out.write( "/" );
+ out.write( domain.getFrom() + "-" + domain.getTo() );
+ }
+ }
+ out.write( "/" );
+ out.write( separator_for_output );
+ final List<Domain> domain_list = new ArrayList<Domain>();
+ for( final Domain domain : protein.getProteinDomains() ) {
+ if ( ( ie_cutoff < 0 ) || ( domain.getPerDomainEvalue() <= ie_cutoff ) ) {
+ domain_list.add( domain );
+ }
+ }
+ final Domain domain_ary[] = new Domain[ domain_list.size() ];
+ for( int i = 0; i < domain_list.size(); ++i ) {
+ domain_ary[ i ] = domain_list.get( i );
+ }
+ Arrays.sort( domain_ary, new DomainComparator( true ) );
+ out.write( "{" );
+ boolean first = true;
+ for( final Domain domain : domain_ary ) {
+ if ( first ) {
+ first = false;
+ }
+ else {
+ out.write( "," );
+ }
+ out.write( domain.getDomainId().toString() );
+ out.write( ":" + domain.getFrom() + "-" + domain.getTo() );
+ out.write( ":" + domain.getPerDomainEvalue() );
+ }
+ out.write( "}" );
+ if ( !( ForesterUtil.isEmpty( protein.getDescription() )
+ || protein.getDescription().equals( SurfacingConstants.NONE ) ) ) {
+ out.write( protein.getDescription() );
+ }
+ out.write( separator_for_output );
+ if ( !( ForesterUtil.isEmpty( protein.getAccession() )
+ || protein.getAccession().equals( SurfacingConstants.NONE ) ) ) {
+ out.write( protein.getAccession() );
+ }
+ out.write( SurfacingConstants.NL );
+ ++counter;
+ }
+ }
+ }
+ }
+ out.flush();
+ return counter;
+ }
+